2 * Copyright (c) 2013 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(ModuleIdentifier name, Module proxiedModule,
34 ModuleFactory moduleFactory,
35 ModuleInternalInfo maybeOldInternalInfo,
36 TransactionModuleJMXRegistration transactionModuleJMXRegistration,
37 boolean isDefaultBean, Module realModule, BundleContext bundleContext) {
39 this.proxiedModule = proxiedModule;
40 this.moduleFactory = moduleFactory;
41 this.maybeOldInternalInfo = maybeOldInternalInfo;
42 this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
43 this.isDefaultBean = isDefaultBean;
44 this.realModule = realModule;
45 this.bundleContext = bundleContext;
49 public boolean hasOldModule() {
50 return maybeOldInternalInfo != null;
53 public DestroyedModule toDestroyedModule() {
54 if (maybeOldInternalInfo == null) {
55 throw new IllegalStateException("Cannot destroy uncommitted module");
57 DynamicReadableWrapper oldModule = maybeOldInternalInfo
59 return new DestroyedModule(name, oldModule.getInstance(),
60 maybeOldInternalInfo.getModuleJMXRegistrator(),
61 maybeOldInternalInfo.getOsgiRegistration(),
62 maybeOldInternalInfo.getOrderingIdx(), maybeOldInternalInfo.getRuntimeBeanRegistrator());
66 public Module getProxiedModule() {
70 public ModuleFactory getModuleFactory() {
74 @Nonnull public ModuleInternalInfo getOldInternalInfo() {
75 return Preconditions.checkNotNull(maybeOldInternalInfo);
78 public void clearOldInternalInfo() {
79 Preconditions.checkState(maybeOldInternalInfo != null, "No old internal info present");
80 maybeOldInternalInfo = null;
83 public TransactionModuleJMXRegistration getTransactionModuleJMXRegistration() {
84 return transactionModuleJMXRegistration;
88 public ModuleIdentifier getIdentifier() {
92 public boolean isDefaultBean() {
96 public Module getRealModule() {
100 public BundleContext getBundleContext() {
101 return bundleContext;