2 * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
10 import com.google.common.base.Preconditions;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.controller.config.api.ModuleIdentifier;
14 import org.opendaylight.controller.config.manager.impl.ModuleInternalInfo;
15 import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
16 import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator.TransactionModuleJMXRegistration;
17 import org.opendaylight.controller.config.spi.Module;
18 import org.opendaylight.controller.config.spi.ModuleFactory;
19 import org.opendaylight.yangtools.concepts.Identifiable;
20 import org.osgi.framework.BundleContext;
22 public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
23 private final ModuleIdentifier name;
24 private final Module proxiedModule;
25 private final Module realModule;
26 private final ModuleFactory moduleFactory;
28 private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
29 private final boolean isDefaultBean;
30 private final BundleContext bundleContext;
31 @Nullable private ModuleInternalInfo maybeOldInternalInfo;
33 public ModuleInternalTransactionalInfo(final ModuleIdentifier name, final Module proxiedModule,
34 final ModuleFactory moduleFactory,
35 final ModuleInternalInfo maybeOldInternalInfo,
36 final TransactionModuleJMXRegistration transactionModuleJMXRegistration,
37 final boolean isDefaultBean,
38 final Module realModule,
39 final BundleContext bundleContext) {
41 this.proxiedModule = proxiedModule;
42 this.moduleFactory = moduleFactory;
43 this.maybeOldInternalInfo = maybeOldInternalInfo;
44 this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
45 this.isDefaultBean = isDefaultBean;
46 this.realModule = realModule;
47 this.bundleContext = bundleContext;
51 public boolean hasOldModule() {
52 return maybeOldInternalInfo != null;
55 public DestroyedModule toDestroyedModule() {
56 if (maybeOldInternalInfo == null) {
57 throw new IllegalStateException("Cannot destroy uncommitted module");
59 DynamicReadableWrapper oldModule = maybeOldInternalInfo
61 return new DestroyedModule(name, oldModule.getInstance(),
62 maybeOldInternalInfo.getModuleJMXRegistrator(),
63 maybeOldInternalInfo.getOsgiRegistration(),
64 maybeOldInternalInfo.getOrderingIdx(), maybeOldInternalInfo.getRuntimeBeanRegistrator());
68 public Module getProxiedModule() {
72 public ModuleFactory getModuleFactory() {
76 @Nonnull public ModuleInternalInfo getOldInternalInfo() {
77 return Preconditions.checkNotNull(maybeOldInternalInfo);
80 public void clearOldInternalInfo() {
81 Preconditions.checkState(maybeOldInternalInfo != null, "No old internal info present");
82 maybeOldInternalInfo = null;
85 public TransactionModuleJMXRegistration getTransactionModuleJMXRegistration() {
86 return transactionModuleJMXRegistration;
90 public ModuleIdentifier getIdentifier() {
94 public boolean isDefaultBean() {
98 public Module getRealModule() {
102 public BundleContext getBundleContext() {
103 return bundleContext;