Remove yang-test
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / dependencyresolver / ModuleInternalTransactionalInfo.java
index e9f573a05def40ec079dc3a45522698358ed8ee0..e8a6d512a47aae35602fa27138c91e6e45bbf943 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
+import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.manager.impl.ModuleInternalInfo;
 import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
@@ -14,23 +17,26 @@ import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXR
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.yangtools.concepts.Identifiable;
-
-import javax.annotation.Nullable;
+import org.osgi.framework.BundleContext;
 
 public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
     private final ModuleIdentifier name;
-    private final Module proxiedModule, realModule;
+    private final Module proxiedModule;
+    private final Module realModule;
     private final ModuleFactory moduleFactory;
-    @Nullable
-    private final ModuleInternalInfo maybeOldInternalInfo;
+
     private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
     private final boolean isDefaultBean;
+    private final BundleContext bundleContext;
+    @Nullable private ModuleInternalInfo maybeOldInternalInfo;
 
-    public ModuleInternalTransactionalInfo(ModuleIdentifier name, Module proxiedModule,
-                                           ModuleFactory moduleFactory,
-                                           ModuleInternalInfo maybeOldInternalInfo,
-                                           TransactionModuleJMXRegistration transactionModuleJMXRegistration,
-                                           boolean isDefaultBean, Module realModule) {
+    public ModuleInternalTransactionalInfo(final ModuleIdentifier name, final Module proxiedModule,
+                                           final ModuleFactory moduleFactory,
+                                           final ModuleInternalInfo maybeOldInternalInfo,
+                                           final TransactionModuleJMXRegistration transactionModuleJMXRegistration,
+                                           final boolean isDefaultBean,
+                                           final Module realModule,
+                                           final BundleContext bundleContext) {
         this.name = name;
         this.proxiedModule = proxiedModule;
         this.moduleFactory = moduleFactory;
@@ -38,6 +44,7 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
         this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
         this.isDefaultBean = isDefaultBean;
         this.realModule = realModule;
+        this.bundleContext = bundleContext;
     }
 
 
@@ -54,7 +61,7 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
         return new DestroyedModule(name, oldModule.getInstance(),
                 maybeOldInternalInfo.getModuleJMXRegistrator(),
                 maybeOldInternalInfo.getOsgiRegistration(),
-                maybeOldInternalInfo.getOrderingIdx());
+                maybeOldInternalInfo.getOrderingIdx(), maybeOldInternalInfo.getRuntimeBeanRegistrator());
     }
 
 
@@ -66,12 +73,13 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
         return moduleFactory;
     }
 
-    @Nullable
-    public ModuleInternalInfo getOldInternalInfo() {
-        if (maybeOldInternalInfo == null) {
-            throw new NullPointerException();
-        }
-        return maybeOldInternalInfo;
+    @Nonnull public ModuleInternalInfo getOldInternalInfo() {
+        return Preconditions.checkNotNull(maybeOldInternalInfo);
+    }
+
+    public void clearOldInternalInfo() {
+        Preconditions.checkState(maybeOldInternalInfo != null, "No old internal info present");
+        maybeOldInternalInfo = null;
     }
 
     public TransactionModuleJMXRegistration getTransactionModuleJMXRegistration() {
@@ -90,4 +98,8 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
     public Module getRealModule() {
         return realModule;
     }
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
 }