Resolve Bug:681 - Fix config module registration to Service Registry. 64/5964/6
authorTomas Olvecky <tolvecky@cisco.com>
Tue, 8 Apr 2014 14:22:48 +0000 (16:22 +0200)
committerTomas Olvecky <tolvecky@cisco.com>
Wed, 23 Apr 2014 08:28:26 +0000 (10:28 +0200)
Rework OSGi service registration during second phase commit: only service references
will be registered into SR, instead of old behaviour when each module's service
interfaces were used. Only one key-value entry is persisted in registration:
{name: name of service reference} .

Change-Id: I25249fe8f9e51570cd3ea963e91145b7e44da57d
Signed-off-by: Tomas Olvecky <tolvecky@cisco.com>
43 files changed:
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/NeverReconnectStrategyModuleTest.java
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyModuleTest.java
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyModuleTest.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/CloseableServiceReferenceReadableRegistry.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerInternal.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DeadlockMonitor.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/SearchableServiceReferenceWritableRegistry.java [new file with mode: 0644]
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/ServiceReference.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BeanToOsgiServiceManager.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/ConfigRegistryImplTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImplTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionManagerImplTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImplTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/factoriesresolver/HardcodedModuleFactoriesResolver.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/DependentWiringTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/MockedDependenciesTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/scheduledthreadpool/test/AbstractScheduledTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/test/SimpleConfigurationTest.java
opendaylight/config/logback-config/src/test/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleTest.java
opendaylight/config/logback-config/src/test/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleWithInitialConfigurationTest.java
opendaylight/config/logback-config/src/test/java/org/opendaylight/controller/config/yang/logback/config/LogbackWithXmlConfigModuleTest.java
opendaylight/config/netty-event-executor-config/src/test/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModuleTest.java
opendaylight/config/netty-threadgroup-config/src/test/java/org/opendaylight/controller/config/yang/netty/threadgroup/NettyThreadgroupModuleTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/SyncEventBusConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java
opendaylight/config/yang-jmx-generator-it/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/it/ITTest.java
opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java
opendaylight/md-sal/sal-binding-it/src/test/resources/controller.xml
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/DefaultCommitNotificationProducer.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java

index d77c9aa962c21ed5267f30b49662d26bbb9cd775..1148c6bebe5f381d825be0003c6904b3b3e12153 100644 (file)
@@ -7,12 +7,6 @@
  */
 package org.opendaylight.controller.config.yang.protocol.framework;
 
  */
 package org.opendaylight.controller.config.yang.protocol.framework;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
@@ -23,6 +17,12 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
 
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
 
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 public class NeverReconnectStrategyModuleTest extends AbstractConfigTest {
 
     private static final String INSTANCE_NAME = "never-reconect-strategy-factory-impl";
 public class NeverReconnectStrategyModuleTest extends AbstractConfigTest {
 
     private static final String INSTANCE_NAME = "never-reconect-strategy-factory-impl";
@@ -30,7 +30,7 @@ public class NeverReconnectStrategyModuleTest extends AbstractConfigTest {
 
     @Before
     public void setUp() throws Exception {
 
     @Before
     public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 new NeverReconnectStrategyFactoryModuleFactory(), new GlobalEventExecutorModuleFactory()));
     }
 
                 new NeverReconnectStrategyFactoryModuleFactory(), new GlobalEventExecutorModuleFactory()));
     }
 
index 24a0e912a3263d676c9757b6f92583c2358ca5ee..9beadc4dbb2b7f8aa34a0390e9aa65614168d666 100644 (file)
@@ -29,7 +29,7 @@ public class ReconnectImmediatelyStrategyModuleTest extends AbstractConfigTest {
 
     @Before
     public void setUp() throws Exception {
 
     @Before
     public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 new ReconnectImmediatelyStrategyFactoryModuleFactory(), new GlobalEventExecutorModuleFactory()));
     }
 
                 new ReconnectImmediatelyStrategyFactoryModuleFactory(), new GlobalEventExecutorModuleFactory()));
     }
 
index d051a00a12f09a66ffb8c16db4b059f72d46e3c2..a8cdff711905ead55193384baed9362d1f7df909 100644 (file)
@@ -7,15 +7,6 @@
  */
 package org.opendaylight.controller.config.yang.protocol.framework;
 
  */
 package org.opendaylight.controller.config.yang.protocol.framework;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.math.BigDecimal;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
@@ -26,6 +17,14 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
 
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
 
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+import java.math.BigDecimal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 public class TimedReconnectStrategyModuleTest extends AbstractConfigTest {
 
     private static final String INSTANCE_NAME = "timed-reconect-stategy-facotry-impl";
 public class TimedReconnectStrategyModuleTest extends AbstractConfigTest {
 
     private static final String INSTANCE_NAME = "timed-reconect-stategy-facotry-impl";
@@ -33,7 +32,7 @@ public class TimedReconnectStrategyModuleTest extends AbstractConfigTest {
 
     @Before
     public void setUp() throws Exception {
 
     @Before
     public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 new TimedReconnectStrategyFactoryModuleFactory(), new GlobalEventExecutorModuleFactory()));
     }
 
                 new TimedReconnectStrategyFactoryModuleFactory(), new GlobalEventExecutorModuleFactory()));
     }
 
index 8c325079d30e185200398fbc537550d0d9b37682..bf010bb3a603e46d995bc8656a0d5f52ca368f31 100644 (file)
@@ -9,9 +9,12 @@ package org.opendaylight.controller.config.manager.impl;
 
 import org.opendaylight.controller.config.api.ServiceReferenceReadableRegistry;
 
 
 import org.opendaylight.controller.config.api.ServiceReferenceReadableRegistry;
 
+/**
+ * Interface exposing some internal state on top of ServiceReferenceReadableRegistry. This will
+ * not be exposed via JMX.
+ */
 public interface CloseableServiceReferenceReadableRegistry  extends AutoCloseable, ServiceReferenceReadableRegistry {
 
 public interface CloseableServiceReferenceReadableRegistry  extends AutoCloseable, ServiceReferenceReadableRegistry {
 
-
     void close();
 
 }
     void close();
 
 }
index e914162671e811682271d42bcbccbe4e89c47947..fbf18f7134ac274f4f963359054a7f9c70371379 100644 (file)
@@ -11,8 +11,8 @@ import com.google.common.collect.Maps;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
-import org.opendaylight.controller.config.api.ServiceReferenceWritableRegistry;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.impl.dependencyresolver.DestroyedModule;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.impl.dependencyresolver.DestroyedModule;
@@ -165,7 +165,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         // closed by transaction controller
         ConfigTransactionLookupRegistry txLookupRegistry = new ConfigTransactionLookupRegistry(new TransactionIdentifier(
                 transactionName), factory, allCurrentFactories);
         // closed by transaction controller
         ConfigTransactionLookupRegistry txLookupRegistry = new ConfigTransactionLookupRegistry(new TransactionIdentifier(
                 transactionName), factory, allCurrentFactories);
-        ServiceReferenceWritableRegistry writableRegistry = ServiceReferenceRegistryImpl.createSRWritableRegistry(
+        SearchableServiceReferenceWritableRegistry writableRegistry = ServiceReferenceRegistryImpl.createSRWritableRegistry(
                 readableSRRegistry, txLookupRegistry, allCurrentFactories);
 
         ConfigTransactionControllerInternal transactionController = new ConfigTransactionControllerImpl(
                 readableSRRegistry, txLookupRegistry, allCurrentFactories);
 
         ConfigTransactionControllerInternal transactionController = new ConfigTransactionControllerImpl(
@@ -344,24 +344,20 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
 
             // register to JMX
             try {
 
             // register to JMX
             try {
-                newModuleJMXRegistrator.registerMBean(newReadableConfigBean,
-                        primaryReadOnlyON);
+                newModuleJMXRegistrator.registerMBean(newReadableConfigBean, primaryReadOnlyON);
             } catch (InstanceAlreadyExistsException e) {
             } catch (InstanceAlreadyExistsException e) {
-                throw new IllegalStateException(e);
+                throw new IllegalStateException("Possible code error, already registered:" + primaryReadOnlyON,e);
             }
 
             }
 
-            // register to OSGi
+            // register services to OSGi
+            Map<String, ServiceInterfaceAnnotation> annotationMapping = configTransactionController.getWritableRegistry().findServiceInterfaces(moduleIdentifier);
+            BundleContext bc = configTransactionController.getModuleFactoryBundleContext(
+                    entry.getModuleFactory().getImplementationName());
             if (osgiRegistration == null) {
             if (osgiRegistration == null) {
-                ModuleFactory moduleFactory = entry.getModuleFactory();
-                if (moduleFactory != null) {
-                    BundleContext bc = configTransactionController.
-                            getModuleFactoryBundleContext(moduleFactory.getImplementationName());
-                    osgiRegistration = beanToOsgiServiceManager.registerToOsgi(realModule.getClass(),
-                            newReadableConfigBean.getInstance(), entry.getIdentifier(), bc);
-                } else {
-                    throw new NullPointerException(entry.getIdentifier().getFactoryName() + " ModuleFactory not found.");
-                }
-
+                osgiRegistration = beanToOsgiServiceManager.registerToOsgi(
+                        newReadableConfigBean.getInstance(), moduleIdentifier, bc, annotationMapping);
+            } else {
+                osgiRegistration.updateRegistrations(annotationMapping, bc, instance);
             }
 
             RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator = runtimeRegistrators
             }
 
             RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator = runtimeRegistrators
index bc4de5cc156580741caf9e5abcbfbd32e07556ce..c549f52017e22572efeb47bd22e7e3ea65d2ca1c 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.config.manager.impl;
 
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.ServiceReferenceWritableRegistry;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.impl.dependencyresolver.DependencyResolverManager;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.impl.dependencyresolver.DependencyResolverManager;
@@ -82,13 +81,13 @@ class ConfigTransactionControllerImpl implements
     private final boolean blankTransaction;
 
     @GuardedBy("this")
     private final boolean blankTransaction;
 
     @GuardedBy("this")
-    private final ServiceReferenceWritableRegistry writableSRRegistry;
+    private final SearchableServiceReferenceWritableRegistry writableSRRegistry;
 
     public ConfigTransactionControllerImpl(ConfigTransactionLookupRegistry txLookupRegistry,
                                            long parentVersion, CodecRegistry codecRegistry, long currentVersion,
                                            Map<String, Entry<ModuleFactory, BundleContext>> currentlyRegisteredFactories,
                                            MBeanServer transactionsMBeanServer, MBeanServer configMBeanServer,
 
     public ConfigTransactionControllerImpl(ConfigTransactionLookupRegistry txLookupRegistry,
                                            long parentVersion, CodecRegistry codecRegistry, long currentVersion,
                                            Map<String, Entry<ModuleFactory, BundleContext>> currentlyRegisteredFactories,
                                            MBeanServer transactionsMBeanServer, MBeanServer configMBeanServer,
-                                           boolean blankTransaction, ServiceReferenceWritableRegistry writableSRRegistry) {
+                                           boolean blankTransaction, SearchableServiceReferenceWritableRegistry  writableSRRegistry) {
         this.txLookupRegistry = txLookupRegistry;
         String transactionName = txLookupRegistry.getTransactionIdentifier().getName();
         this.controllerON = ObjectNameUtil.createTransactionControllerON(transactionName);
         this.txLookupRegistry = txLookupRegistry;
         String transactionName = txLookupRegistry.getTransactionIdentifier().getName();
         this.controllerON = ObjectNameUtil.createTransactionControllerON(transactionName);
@@ -570,7 +569,7 @@ class ConfigTransactionControllerImpl implements
     }
 
     @Override
     }
 
     @Override
-    public ServiceReferenceWritableRegistry getWritableRegistry() {
+    public SearchableServiceReferenceWritableRegistry  getWritableRegistry() {
         return writableSRRegistry;
     }
 
         return writableSRRegistry;
     }
 
index f6164e32561d7ad5688abde93ac6cb4bc96cbec1..c9df3409db46366acbae22d44166e05202e844fc 100644 (file)
@@ -7,17 +7,15 @@
  */
 package org.opendaylight.controller.config.manager.impl;
 
  */
 package org.opendaylight.controller.config.manager.impl;
 
-import java.util.Collection;
-import java.util.List;
-
-import javax.management.ObjectName;
-
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.ServiceReferenceWritableRegistry;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.BundleContext;
 
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.BundleContext;
 
+import javax.management.ObjectName;
+import java.util.Collection;
+import java.util.List;
+
 /**
  * Defines contract between {@link ConfigTransactionControllerImpl} (producer)
  * and {@link ConfigRegistryImpl} (consumer).
 /**
  * Defines contract between {@link ConfigTransactionControllerImpl} (producer)
  * and {@link ConfigRegistryImpl} (consumer).
@@ -73,7 +71,7 @@ interface ConfigTransactionControllerInternal extends
 
     BundleContext getModuleFactoryBundleContext(String factoryName);
 
 
     BundleContext getModuleFactoryBundleContext(String factoryName);
 
-    ServiceReferenceWritableRegistry getWritableRegistry();
+    SearchableServiceReferenceWritableRegistry  getWritableRegistry();
 
     TransactionIdentifier getTransactionIdentifier();
 
 
     TransactionIdentifier getTransactionIdentifier();
 
index ba7ab7fcba924743c4ea579797f1dffbd117c7cb..d34a739703e8f8eba7d60a90ca6fa713a301f802 100644 (file)
@@ -6,6 +6,8 @@ import org.slf4j.LoggerFactory;
 
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.GuardedBy;
 
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.GuardedBy;
+import java.util.Deque;
+import java.util.LinkedList;
 import java.util.concurrent.TimeUnit;
 
 public class DeadlockMonitor implements AutoCloseable {
 import java.util.concurrent.TimeUnit;
 
 public class DeadlockMonitor implements AutoCloseable {
@@ -16,7 +18,9 @@ public class DeadlockMonitor implements AutoCloseable {
     private final TransactionIdentifier transactionIdentifier;
     private final DeadlockMonitorRunnable thread;
     @GuardedBy("this")
     private final TransactionIdentifier transactionIdentifier;
     private final DeadlockMonitorRunnable thread;
     @GuardedBy("this")
-    private ModuleIdentifierWithNanos moduleIdentifierWithNanos = new ModuleIdentifierWithNanos();
+    private final Deque<ModuleIdentifierWithNanos> moduleIdentifierWithNanosStack = new LinkedList<>();
+    @GuardedBy("this")
+    private ModuleIdentifierWithNanos top = ModuleIdentifierWithNanos.EMPTY;
 
     public DeadlockMonitor(TransactionIdentifier transactionIdentifier) {
         this.transactionIdentifier = transactionIdentifier;
 
     public DeadlockMonitor(TransactionIdentifier transactionIdentifier) {
         this.transactionIdentifier = transactionIdentifier;
@@ -25,7 +29,21 @@ public class DeadlockMonitor implements AutoCloseable {
     }
 
     public synchronized void setCurrentlyInstantiatedModule(ModuleIdentifier currentlyInstantiatedModule) {
     }
 
     public synchronized void setCurrentlyInstantiatedModule(ModuleIdentifier currentlyInstantiatedModule) {
-        this.moduleIdentifierWithNanos = new ModuleIdentifierWithNanos(currentlyInstantiatedModule);
+
+        boolean popping = currentlyInstantiatedModule == null;
+        if (popping) {
+            moduleIdentifierWithNanosStack.pop();
+            if (moduleIdentifierWithNanosStack.isEmpty()) {
+                top = ModuleIdentifierWithNanos.EMPTY;
+            } else {
+                top = moduleIdentifierWithNanosStack.peekLast();
+            }
+        } else {
+            ModuleIdentifierWithNanos current = new ModuleIdentifierWithNanos(currentlyInstantiatedModule);
+            moduleIdentifierWithNanosStack.push(current);
+            top = current;
+        }
+        logger.trace("setCurrentlyInstantiatedModule {}, top {}", currentlyInstantiatedModule, top);
     }
 
     public boolean isAlive() {
     }
 
     public boolean isAlive() {
@@ -52,11 +70,11 @@ public class DeadlockMonitor implements AutoCloseable {
         public void run() {
             ModuleIdentifierWithNanos old = new ModuleIdentifierWithNanos(); // null moduleId
             while (this.isInterrupted() == false) {
         public void run() {
             ModuleIdentifierWithNanos old = new ModuleIdentifierWithNanos(); // null moduleId
             while (this.isInterrupted() == false) {
-                ModuleIdentifierWithNanos copy = new ModuleIdentifierWithNanos(DeadlockMonitor.this.moduleIdentifierWithNanos);
-                if (old.moduleIdentifier == null) {
+                ModuleIdentifierWithNanos copy = new ModuleIdentifierWithNanos(DeadlockMonitor.this.top);
+                if (old.moduleIdentifier == null || old.equals(copy) == false) {
                     // started
                     old = copy;
                     // started
                     old = copy;
-                } else if (old.moduleIdentifier != null && old.equals(copy)) {
+                } else {
                     // is the getInstance() running longer than WARN_AFTER_MILLIS ?
                     long runningTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - copy.nanoTime);
                     if (runningTime > WARN_AFTER_MILLIS) {
                     // is the getInstance() running longer than WARN_AFTER_MILLIS ?
                     long runningTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - copy.nanoTime);
                     if (runningTime > WARN_AFTER_MILLIS) {
@@ -78,14 +96,18 @@ public class DeadlockMonitor implements AutoCloseable {
         }
     }
 
         }
     }
 
-    private class ModuleIdentifierWithNanos {
+
+
+
+    private static class ModuleIdentifierWithNanos {
+        private static ModuleIdentifierWithNanos EMPTY = new ModuleIdentifierWithNanos();
         @Nullable
         private final ModuleIdentifier moduleIdentifier;
         @Nullable
         private final ModuleIdentifier moduleIdentifier;
+
         private final long nanoTime;
 
         private ModuleIdentifierWithNanos() {
         private final long nanoTime;
 
         private ModuleIdentifierWithNanos() {
-            moduleIdentifier = null;
-            nanoTime = System.nanoTime();
+            this((ModuleIdentifier)null);
         }
 
         private ModuleIdentifierWithNanos(ModuleIdentifier moduleIdentifier) {
         }
 
         private ModuleIdentifierWithNanos(ModuleIdentifier moduleIdentifier) {
@@ -118,5 +140,12 @@ public class DeadlockMonitor implements AutoCloseable {
             result = 31 * result + (int) (nanoTime ^ (nanoTime >>> 32));
             return result;
         }
             result = 31 * result + (int) (nanoTime ^ (nanoTime >>> 32));
             return result;
         }
+
+        @Override
+        public String toString() {
+            return "ModuleIdentifierWithNanos{" +
+                    moduleIdentifier +
+                    '}';
+        }
     }
 }
     }
 }
diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/SearchableServiceReferenceWritableRegistry.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/SearchableServiceReferenceWritableRegistry.java
new file mode 100644 (file)
index 0000000..24ddf63
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2013 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.manager.impl;
+
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.api.ServiceReferenceWritableRegistry;
+import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
+
+import java.util.Map;
+
+public interface SearchableServiceReferenceWritableRegistry extends ServiceReferenceWritableRegistry {
+    /**
+     * Return mapping between service ref names and service interface annotation for given
+     * module.
+     * @throws java.lang.IllegalArgumentException if any of service qNames is not found
+     * @throws java.lang.NullPointerException if parameter is null
+     */
+    Map<String /* service ref */, ServiceInterfaceAnnotation> findServiceInterfaces(ModuleIdentifier moduleIdentifier);
+
+}
index bf35fd1ed86f6b8249dcb4a7ca386d85ad2a53d1..ed04779d9e43d392a8cdd77b3c9eb0fd405e66ed 100644 (file)
@@ -36,7 +36,9 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
 import java.util.Map.Entry;
 import java.util.Set;
 
-public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceReadableRegistry, ServiceReferenceWritableRegistry {
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceReadableRegistry, SearchableServiceReferenceWritableRegistry {
     private static final Logger logger = LoggerFactory.getLogger(ServiceReferenceRegistryImpl.class);
 
     private final Map<String, ModuleFactory> factories;
     private static final Logger logger = LoggerFactory.getLogger(ServiceReferenceRegistryImpl.class);
 
     private final Map<String, ModuleFactory> factories;
@@ -46,8 +48,11 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     private final ServiceReferenceRegistrator serviceReferenceRegistrator;
     // helper method for getting QName of SI from namespace + local name
     private final Map<String /* namespace */, Map<String /* local name */, ServiceInterfaceAnnotation>> namespacesToAnnotations;
     private final ServiceReferenceRegistrator serviceReferenceRegistrator;
     // helper method for getting QName of SI from namespace + local name
     private final Map<String /* namespace */, Map<String /* local name */, ServiceInterfaceAnnotation>> namespacesToAnnotations;
+    private final Map<String /* service qName */, ServiceInterfaceAnnotation> serviceQNamesToAnnotations;
     // all Service Interface qNames for sanity checking
     private final Set<String /* qName */> allQNames;
     // all Service Interface qNames for sanity checking
     private final Set<String /* qName */> allQNames;
+    Map<ModuleIdentifier, Map<String /* service ref name */, ServiceInterfaceAnnotation >> modulesToServiceRef = new HashMap<>();
+
 
     // actual reference database
     private final Map<ServiceReference, ModuleIdentifier> refNames = new HashMap<>();
 
     // actual reference database
     private final Map<ServiceReference, ModuleIdentifier> refNames = new HashMap<>();
@@ -124,7 +129,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     /**
      * Static constructor for transaction controller. Take current state as seen by config registry, allow writing new data.
      */
     /**
      * Static constructor for transaction controller. Take current state as seen by config registry, allow writing new data.
      */
-    public static ServiceReferenceWritableRegistry createSRWritableRegistry(ServiceReferenceReadableRegistry oldReadableRegistry,
+    public static SearchableServiceReferenceWritableRegistry createSRWritableRegistry(ServiceReferenceReadableRegistry oldReadableRegistry,
                                                     ConfigTransactionLookupRegistry txLookupRegistry,
                                                     Map<String, Map.Entry<ModuleFactory, BundleContext>> currentlyRegisteredFactories) {
 
                                                     ConfigTransactionLookupRegistry txLookupRegistry,
                                                     Map<String, Map.Entry<ModuleFactory, BundleContext>> currentlyRegisteredFactories) {
 
@@ -198,6 +203,8 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         Map<String, Set<String /* QName */>> modifiableFactoryNamesToQNames = new HashMap<>();
         Set<ServiceInterfaceAnnotation> allAnnotations = new HashSet<>();
         Set<String /* qName */> allQNames = new HashSet<>();
         Map<String, Set<String /* QName */>> modifiableFactoryNamesToQNames = new HashMap<>();
         Set<ServiceInterfaceAnnotation> allAnnotations = new HashSet<>();
         Set<String /* qName */> allQNames = new HashSet<>();
+
+
         for (Entry<String, ModuleFactory> entry : factories.entrySet()) {
             if (entry.getKey().equals(entry.getValue().getImplementationName()) == false) {
                 logger.error("Possible error in code: Mismatch between supplied and actual name of {}", entry);
         for (Entry<String, ModuleFactory> entry : factories.entrySet()) {
             if (entry.getKey().equals(entry.getValue().getImplementationName()) == false) {
                 logger.error("Possible error in code: Mismatch between supplied and actual name of {}", entry);
@@ -217,6 +224,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         // fill namespacesToAnnotations
         Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> modifiableNamespacesToAnnotations =
                 new HashMap<>();
         // fill namespacesToAnnotations
         Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> modifiableNamespacesToAnnotations =
                 new HashMap<>();
+        Map<String /* service qName*/, ServiceInterfaceAnnotation> modifiableServiceQNamesToAnnotations = new HashMap<>();
         for (ServiceInterfaceAnnotation sia : allAnnotations) {
             Map<String, ServiceInterfaceAnnotation> ofNamespace = modifiableNamespacesToAnnotations.get(sia.namespace());
             if (ofNamespace == null) {
         for (ServiceInterfaceAnnotation sia : allAnnotations) {
             Map<String, ServiceInterfaceAnnotation> ofNamespace = modifiableNamespacesToAnnotations.get(sia.namespace());
             if (ofNamespace == null) {
@@ -229,12 +237,21 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
                 throw new IllegalArgumentException("Conflict between local names in " + sia.namespace() + " : " + sia.localName());
             }
             ofNamespace.put(sia.localName(), sia);
                 throw new IllegalArgumentException("Conflict between local names in " + sia.namespace() + " : " + sia.localName());
             }
             ofNamespace.put(sia.localName(), sia);
+            modifiableServiceQNamesToAnnotations.put(sia.value(), sia);
         }
         this.namespacesToAnnotations = Collections.unmodifiableMap(modifiableNamespacesToAnnotations);
         }
         this.namespacesToAnnotations = Collections.unmodifiableMap(modifiableNamespacesToAnnotations);
-        // copy refNames
+        this.serviceQNamesToAnnotations = Collections.unmodifiableMap(modifiableServiceQNamesToAnnotations);
         logger.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
     }
 
         logger.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
     }
 
+    @Override
+    public Map<String /* service ref */, ServiceInterfaceAnnotation> findServiceInterfaces(ModuleIdentifier moduleIdentifier) {
+        Map<String, ServiceInterfaceAnnotation> result = modulesToServiceRef.get(moduleIdentifier);
+        if (result == null) {
+            return Collections.emptyMap();
+        }
+        return Collections.unmodifiableMap(result);
+    }
 
     @Override
     public synchronized Set<String> lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException {
 
     @Override
     public synchronized Set<String> lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException {
@@ -271,7 +288,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     public synchronized Map<String /* serviceInterfaceName */, Map<String/* refName */, ObjectName>> getServiceMapping() {
         Map<String /* serviceInterfaceName */, Map<String/* refName */, ObjectName>> result = new HashMap<>();
         for (Entry<ServiceReference, ModuleIdentifier> entry: refNames.entrySet()) {
     public synchronized Map<String /* serviceInterfaceName */, Map<String/* refName */, ObjectName>> getServiceMapping() {
         Map<String /* serviceInterfaceName */, Map<String/* refName */, ObjectName>> result = new HashMap<>();
         for (Entry<ServiceReference, ModuleIdentifier> entry: refNames.entrySet()) {
-            String qName = entry.getKey().getServiceInterfaceName();
+            String qName = entry.getKey().getServiceInterfaceQName();
             Map<String /* refName */, ObjectName> innerMap = result.get(qName);
             if (innerMap == null) {
                 innerMap = new HashMap<>();
             Map<String /* refName */, ObjectName> innerMap = result.get(qName);
             if (innerMap == null) {
                 innerMap = new HashMap<>();
@@ -379,9 +396,9 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
             throw new IllegalStateException("Possible error in code: cannot find annotations of existing factory " + moduleIdentifier.getFactoryName());
         }
         // supplied serviceInterfaceName must exist in this collection
             throw new IllegalStateException("Possible error in code: cannot find annotations of existing factory " + moduleIdentifier.getFactoryName());
         }
         // supplied serviceInterfaceName must exist in this collection
-        if (serviceInterfaceQNames.contains(serviceReference.getServiceInterfaceName()) == false) {
-            logger.error("Cannot find qName {} with factory name {}, found {}", serviceReference.getServiceInterfaceName(), moduleIdentifier.getFactoryName(), serviceInterfaceQNames);
-            throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceName() + " within factory " + moduleIdentifier.getFactoryName());
+        if (serviceInterfaceQNames.contains(serviceReference.getServiceInterfaceQName()) == false) {
+            logger.error("Cannot find qName {} with factory name {}, found {}", serviceReference.getServiceInterfaceQName(), moduleIdentifier.getFactoryName(), serviceInterfaceQNames);
+            throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName() + " within factory " + moduleIdentifier.getFactoryName());
         }
 
 
         }
 
 
@@ -404,6 +421,15 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         }
         // save to refNames
         refNames.put(serviceReference, moduleIdentifier);
         }
         // save to refNames
         refNames.put(serviceReference, moduleIdentifier);
+        Map<String, ServiceInterfaceAnnotation> refNamesToAnnotations = modulesToServiceRef.get(moduleIdentifier);
+        if (refNamesToAnnotations == null){
+            refNamesToAnnotations = new HashMap<>();
+            modulesToServiceRef.put(moduleIdentifier, refNamesToAnnotations);
+        }
+
+        ServiceInterfaceAnnotation annotation = serviceQNamesToAnnotations.get(serviceReference.getServiceInterfaceQName());
+        checkNotNull(annotation, "Possible error in code, cannot find annotation for " + serviceReference);
+        refNamesToAnnotations.put(serviceReference.getRefName(), annotation);
         return result;
     }
 
         return result;
     }
 
@@ -430,9 +456,9 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     private ObjectName getServiceON(ServiceReference serviceReference) {
         if (writable) {
             return ObjectNameUtil.createTransactionServiceON(serviceReferenceRegistrator.getNullableTransactionName(),
     private ObjectName getServiceON(ServiceReference serviceReference) {
         if (writable) {
             return ObjectNameUtil.createTransactionServiceON(serviceReferenceRegistrator.getNullableTransactionName(),
-                    serviceReference.getServiceInterfaceName(), serviceReference.getRefName());
+                    serviceReference.getServiceInterfaceQName(), serviceReference.getRefName());
         } else {
         } else {
-            return ObjectNameUtil.createReadOnlyServiceON(serviceReference.getServiceInterfaceName(), serviceReference.getRefName());
+            return ObjectNameUtil.createReadOnlyServiceON(serviceReference.getServiceInterfaceQName(), serviceReference.getRefName());
         }
     }
 
         }
     }
 
@@ -446,13 +472,13 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         logger.debug("Removing service reference {} from {}", serviceReference, this);
         assertWritable();
         // is the qName known?
         logger.debug("Removing service reference {} from {}", serviceReference, this);
         assertWritable();
         // is the qName known?
-        if (allQNames.contains(serviceReference.getServiceInterfaceName()) == false) {
-            logger.error("Cannot find qname {} in {}", serviceReference.getServiceInterfaceName(), allQNames);
-            throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceName());
+        if (allQNames.contains(serviceReference.getServiceInterfaceQName()) == false) {
+            logger.error("Cannot find qname {} in {}", serviceReference.getServiceInterfaceQName(), allQNames);
+            throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName());
         }
         ModuleIdentifier removed = refNames.remove(serviceReference);
         if (removed == null){
         }
         ModuleIdentifier removed = refNames.remove(serviceReference);
         if (removed == null){
-            throw new InstanceNotFoundException("Cannot find " + serviceReference.getServiceInterfaceName());
+            throw new InstanceNotFoundException("Cannot find " + serviceReference.getServiceInterfaceQName());
         }
         Entry<ServiceReferenceMXBeanImpl, ServiceReferenceJMXRegistration> entry = mBeans.remove(serviceReference);
         if (entry == null) {
         }
         Entry<ServiceReferenceMXBeanImpl, ServiceReferenceJMXRegistration> entry = mBeans.remove(serviceReference);
         if (entry == null) {
index cd74ddf7565a32fd74e650cde1d50e720966d506..3ad35ac5b5f48d27041244f795a35f32ca781972 100644 (file)
@@ -15,7 +15,7 @@ public class ServiceReference {
         this.refName = refName;
     }
 
         this.refName = refName;
     }
 
-    public String getServiceInterfaceName() {
+    public String getServiceInterfaceQName() {
         return serviceInterfaceName;
     }
 
         return serviceInterfaceName;
     }
 
@@ -50,4 +50,12 @@ public class ServiceReference {
         result = 31 * result + refName.hashCode();
         return result;
     }
         result = 31 * result + refName.hashCode();
         return result;
     }
+
+    @Override
+    public String toString() {
+        return "ServiceReference{" +
+                "serviceInterfaceName='" + serviceInterfaceName + '\'' +
+                ", refName='" + refName + '\'' +
+                '}';
+    }
 }
 }
index 41f577844af5ed448a322a9a21f2f410782632cd..01afe223bbc82c681be967f8e4a2add32ba676a4 100644 (file)
@@ -9,107 +9,103 @@ package org.opendaylight.controller.config.manager.impl.osgi;
 
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
 
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
-import org.opendaylight.controller.config.manager.impl.util.InterfacesHelper;
-import org.opendaylight.controller.config.spi.Module;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
+import javax.annotation.concurrent.GuardedBy;
 import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import java.util.Set;
 
+import static com.google.common.base.Preconditions.checkState;
+
 /**
  * Registers instantiated beans as OSGi services and unregisters these services
  * if beans are destroyed.
  */
 public class BeanToOsgiServiceManager {
 /**
  * Registers instantiated beans as OSGi services and unregisters these services
  * if beans are destroyed.
  */
 public class BeanToOsgiServiceManager {
-    // name of properties submitted to osgi
-    static final String INSTANCE_NAME_OSGI_PROP = "instanceName";
-    static final String IMPLEMENTATION_NAME_OSGI_PROP = "implementationName";
+    private static final String SERVICE_NAME_OSGI_PROP = "name";
 
     /**
      * To be called for every created, reconfigured and recreated config bean.
      * It is expected that before using this method OSGi service registry will
      * be cleaned from previous registrations.
      */
 
     /**
      * To be called for every created, reconfigured and recreated config bean.
      * It is expected that before using this method OSGi service registry will
      * be cleaned from previous registrations.
      */
-    public OsgiRegistration registerToOsgi(
-            Class<? extends Module> configBeanClass, AutoCloseable instance,
-            ModuleIdentifier moduleIdentifier, BundleContext bundleContext) {
-        try {
-            final Set<Class<?>> configuresInterfaces = InterfacesHelper
-                    .getOsgiRegistrationTypes(configBeanClass);
-            checkInstanceImplementing(instance, configuresInterfaces);
-
-            // bundleContext.registerService blows up with empty 'clazzes'
-            if (configuresInterfaces.isEmpty() == false) {
-                final Dictionary<String, ?> propertiesForOsgi = getPropertiesForOsgi(moduleIdentifier);
-                final ServiceRegistration<?> serviceRegistration = bundleContext
-                        .registerService(classesToNames(configuresInterfaces), instance, propertiesForOsgi);
-                return new OsgiRegistration(serviceRegistration);
-            } else {
-                return new OsgiRegistration();
-            }
-        } catch (IllegalStateException e) {
-            throw new IllegalStateException(
-                    "Error while registering instance into OSGi Service Registry: "
-                            + moduleIdentifier, e);
-        }
+    public OsgiRegistration registerToOsgi(AutoCloseable instance, ModuleIdentifier moduleIdentifier,
+                                           BundleContext bundleContext,
+                                           Map<String, ServiceInterfaceAnnotation> serviceNamesToAnnotations) {
+        return new OsgiRegistration(instance, moduleIdentifier, bundleContext, serviceNamesToAnnotations);
     }
 
     }
 
-    private static String[] classesToNames(Set<Class<?>> cfgs) {
-        String[] result = new String[cfgs.size()];
-        int i = 0;
-        for (Class<?> cfg : cfgs) {
-            result[i] = cfg.getName();
-            i++;
-        }
+    private static Dictionary<String, String> createProps(String serviceName) {
+        Hashtable<String, String> result = new Hashtable<>();
+        result.put(SERVICE_NAME_OSGI_PROP, serviceName);
         return result;
     }
 
         return result;
     }
 
-    private void checkInstanceImplementing(AutoCloseable instance,
-            Set<Class<?>> configures) {
-        Set<Class<?>> missing = new HashSet<>();
-        for (Class<?> requiredIfc : configures) {
-            if (requiredIfc.isInstance(instance) == false) {
-                missing.add(requiredIfc);
-            }
-        }
-        if (missing.isEmpty() == false) {
-            throw new IllegalStateException(
-                    instance.getClass()
-                            + " does not implement following interfaces as announced by "
-                            + ServiceInterfaceAnnotation.class.getName()
-                            + " annotation :" + missing);
-        }
-    }
-
-    private static Dictionary<String, ?> getPropertiesForOsgi(
-            ModuleIdentifier moduleIdentifier) {
-        Hashtable<String, String> table = new Hashtable<>();
-        table.put(IMPLEMENTATION_NAME_OSGI_PROP,
-                moduleIdentifier.getFactoryName());
-        table.put(INSTANCE_NAME_OSGI_PROP, moduleIdentifier.getInstanceName());
-        return table;
-    }
 
     public static class OsgiRegistration implements AutoCloseable {
 
     public static class OsgiRegistration implements AutoCloseable {
-        private final ServiceRegistration<?> serviceRegistration;
+        private static final Logger logger = LoggerFactory.getLogger(OsgiRegistration.class);
 
 
-        public OsgiRegistration(ServiceRegistration<?> serviceRegistration) {
-            this.serviceRegistration = serviceRegistration;
+        @GuardedBy("this")
+        private AutoCloseable instance;
+        private final ModuleIdentifier moduleIdentifier;
+        @GuardedBy("this")
+        private final Set<ServiceRegistration<?>> serviceRegistrations;
+        @GuardedBy("this")
+        private final Map<String, ServiceInterfaceAnnotation> serviceNamesToAnnotations;
+
+        public OsgiRegistration(AutoCloseable instance, ModuleIdentifier moduleIdentifier,
+                                BundleContext bundleContext,
+                                Map<String, ServiceInterfaceAnnotation> serviceNamesToAnnotations) {
+            this.instance = instance;
+            this.moduleIdentifier = moduleIdentifier;
+            this.serviceNamesToAnnotations = serviceNamesToAnnotations;
+            this.serviceRegistrations = registerToSR(instance, bundleContext, serviceNamesToAnnotations);
         }
 
         }
 
-        public OsgiRegistration() {
-            this.serviceRegistration = null;
+        private static Set<ServiceRegistration<?>> registerToSR(AutoCloseable instance, BundleContext bundleContext,
+                                                                Map<String, ServiceInterfaceAnnotation> serviceNamesToAnnotations) {
+            Set<ServiceRegistration<?>> serviceRegistrations = new HashSet<>();
+            for (Entry<String, ServiceInterfaceAnnotation> entry : serviceNamesToAnnotations.entrySet()) {
+                Class<?> requiredInterface = entry.getValue().osgiRegistrationType();
+                checkState(requiredInterface.isInstance(instance), instance.getClass().getName() +
+                        " instance should implement " + requiredInterface.getName());
+                Dictionary<String, String> propertiesForOsgi = createProps(entry.getKey());
+                ServiceRegistration<?> serviceRegistration = bundleContext
+                        .registerService(requiredInterface.getName(), instance, propertiesForOsgi);
+                serviceRegistrations.add(serviceRegistration);
+            }
+            return serviceRegistrations;
         }
 
         @Override
         }
 
         @Override
-        public void close() {
-            if (serviceRegistration != null) {
+        public synchronized void close() {
+            for (ServiceRegistration<?> serviceRegistration : serviceRegistrations) {
                 serviceRegistration.unregister();
             }
                 serviceRegistration.unregister();
             }
+            serviceRegistrations.clear();
         }
         }
-    }
 
 
+        public synchronized void updateRegistrations(Map<String, ServiceInterfaceAnnotation> newAnnotationMapping,
+                                                     BundleContext bundleContext, AutoCloseable newInstance) {
+            boolean notEquals = this.instance != newInstance;
+            notEquals |= newAnnotationMapping.equals(serviceNamesToAnnotations) == false;
+            if (notEquals) {
+                // FIXME: changing from old state to new state can be improved by computing the diff
+                logger.debug("Detected change in service registrations for {}: old: {}, new: {}", moduleIdentifier,
+                        serviceNamesToAnnotations, newAnnotationMapping);
+                close();
+                this.instance = newInstance;
+                Set<ServiceRegistration<?>> newRegs = registerToSR(instance, bundleContext, newAnnotationMapping);
+                serviceRegistrations.clear();
+                serviceRegistrations.addAll(newRegs);
+            }
+        }
+    }
 }
 }
index 9178dc40d0707501ef8696d279a7cfa1af6c22d1..7efd3ee0309fdfec46fbe9378975403637b43ff2 100644 (file)
@@ -7,13 +7,6 @@
  */
 package org.opendaylight.controller.config.manager;
 
  */
 package org.opendaylight.controller.config.manager;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verifyZeroInteractions;
-
-import java.lang.management.ManagementFactory;
-
 import org.junit.Test;
 import org.opendaylight.controller.config.manager.impl.AbstractLockedPlatformMBeanServerTest;
 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
 import org.junit.Test;
 import org.opendaylight.controller.config.manager.impl.AbstractLockedPlatformMBeanServerTest;
 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
@@ -25,6 +18,13 @@ import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.lang.management.ManagementFactory;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
 public class ConfigRegistryImplTest extends
         AbstractLockedPlatformMBeanServerTest {
     private static final Logger logger = LoggerFactory
 public class ConfigRegistryImplTest extends
         AbstractLockedPlatformMBeanServerTest {
     private static final Logger logger = LoggerFactory
@@ -36,7 +36,7 @@ public class ConfigRegistryImplTest extends
         BundleContext context = mock(BundleContext.class);
         ConfigRegistryImpl configRegistry = null;
         try {
         BundleContext context = mock(BundleContext.class);
         ConfigRegistryImpl configRegistry = null;
         try {
-            ModuleFactoriesResolver resolver = new HardcodedModuleFactoriesResolver(
+            ModuleFactoriesResolver resolver = new HardcodedModuleFactoriesResolver(mock(BundleContext.class),
                     factory, factory);
 
             configRegistry = new ConfigRegistryImpl(resolver,
                     factory, factory);
 
             configRegistry = new ConfigRegistryImpl(resolver,
index 001af7525bb28a915e7b9ec0306bbd03046f24f1..63a37de0c3783179ffaaf33ab535281dcab62290 100644 (file)
@@ -8,9 +8,11 @@
 package org.opendaylight.controller.config.manager.impl;
 
 import com.google.common.base.Preconditions;
 package org.opendaylight.controller.config.manager.impl;
 
 import com.google.common.base.Preconditions;
-import junit.framework.Assert;
 import org.junit.After;
 import org.junit.After;
+import org.junit.Before;
 import org.mockito.Matchers;
 import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
@@ -26,24 +28,18 @@ import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.RuntimeMBeanException;
 
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.RuntimeMBeanException;
-import java.io.Closeable;
-import java.io.InputStream;
 import java.lang.management.ManagementFactory;
 import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Dictionary;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Dictionary;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
 import java.util.List;
 import java.util.Set;
 
@@ -69,29 +65,58 @@ public abstract class AbstractConfigTest extends
     protected ConfigRegistryJMXClient configRegistryClient;
     protected BaseJMXRegistrator baseJmxRegistrator;
     protected InternalJMXRegistrator internalJmxRegistrator;
     protected ConfigRegistryJMXClient configRegistryClient;
     protected BaseJMXRegistrator baseJmxRegistrator;
     protected InternalJMXRegistrator internalJmxRegistrator;
-    protected BundleContext mockedContext = mock(BundleContext.class);
+    @Mock
+    protected BundleContext mockedContext;
+    @Mock
     protected ServiceRegistration<?> mockedServiceRegistration;
 
     protected ServiceRegistration<?> mockedServiceRegistration;
 
-    private static final Logger logger = LoggerFactory.getLogger(AbstractConfigTest.class);
+    @Before
+    public void setUpMocks() {
+        MockitoAnnotations.initMocks(this);
+    }
+
 
     // Default handler for OSGi service registration
 
     // Default handler for OSGi service registration
-    private static final BundleContextServiceRegistrationHandler noopServiceRegHandler = new BundleContextServiceRegistrationHandler() {
+    protected static class RecordingBundleContextServiceRegistrationHandler implements BundleContextServiceRegistrationHandler {
+        private final List<RegistrationHolder> registrations = new LinkedList<>();
         @Override
         @Override
-        public void handleServiceRegistration(Object serviceInstance) {}
-    };
+        public void handleServiceRegistration(Class<?> clazz, Object serviceInstance, Dictionary<String, ?> props) {
+
+            registrations.add(new RegistrationHolder(clazz, serviceInstance, props));
+        }
+
+        public List<RegistrationHolder> getRegistrations() {
+            return registrations;
+        }
+
+        protected static class RegistrationHolder {
+            protected final Class<?> clazz;
+            protected final Object instance;
+            protected final Dictionary<String, ?> props;
+
+            public RegistrationHolder(Class<?> clazz, Object instance, Dictionary<String, ?> props) {
+                this.clazz = clazz;
+                this.instance = instance;
+                this.props = props;
+            }
+        }
+
+    }
+
+    protected BundleContextServiceRegistrationHandler currentBundleContextServiceRegistrationHandler;
 
     protected BundleContextServiceRegistrationHandler getBundleContextServiceRegistrationHandler(Class<?> serviceType) {
 
     protected BundleContextServiceRegistrationHandler getBundleContextServiceRegistrationHandler(Class<?> serviceType) {
-        return noopServiceRegHandler;
+        return currentBundleContextServiceRegistrationHandler;
     }
 
     // this method should be called in @Before
     protected void initConfigTransactionManagerImpl(
             ModuleFactoriesResolver resolver) {
     }
 
     // this method should be called in @Before
     protected void initConfigTransactionManagerImpl(
             ModuleFactoriesResolver resolver) {
+
         final MBeanServer platformMBeanServer = ManagementFactory
                 .getPlatformMBeanServer();
 
         final MBeanServer platformMBeanServer = ManagementFactory
                 .getPlatformMBeanServer();
 
-        configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(
-                platformMBeanServer);
+        configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(platformMBeanServer);
         initBundleContext();
 
         internalJmxRegistrator = new InternalJMXRegistrator(platformMBeanServer);
         initBundleContext();
 
         internalJmxRegistrator = new InternalJMXRegistrator(platformMBeanServer);
@@ -106,35 +131,14 @@ public abstract class AbstractConfigTest extends
             throw new RuntimeException(e);
         }
         configRegistryClient = new ConfigRegistryJMXClient(platformMBeanServer);
             throw new RuntimeException(e);
         }
         configRegistryClient = new ConfigRegistryJMXClient(platformMBeanServer);
+        currentBundleContextServiceRegistrationHandler = new RecordingBundleContextServiceRegistrationHandler();
     }
 
     private void initBundleContext() {
     }
 
     private void initBundleContext() {
-        this.mockedServiceRegistration = mock(ServiceRegistration.class);
         doNothing().when(mockedServiceRegistration).unregister();
         doNothing().when(mockedServiceRegistration).unregister();
-
         RegisterServiceAnswer answer = new RegisterServiceAnswer();
         RegisterServiceAnswer answer = new RegisterServiceAnswer();
-
-        doAnswer(answer).when(mockedContext).registerService(Matchers.any(String[].class),
-                any(Closeable.class), Matchers.<Dictionary<String, ?>>any());
-        doAnswer(answer).when(mockedContext).registerService(Matchers.<Class<Closeable>>any(), any(Closeable.class),
-                Matchers.<Dictionary<String, ?>>any());
-    }
-
-
-    public Collection<InputStream> getFilesAsInputStreams(List<String> paths) {
-        final Collection<InputStream> resources = new ArrayList<>();
-        List<String> failedToFind = new ArrayList<>();
-        for (String path : paths) {
-            InputStream resourceAsStream = getClass().getResourceAsStream(path);
-            if (resourceAsStream == null) {
-                failedToFind.add(path);
-            } else {
-                resources.add(resourceAsStream);
-            }
-        }
-        Assert.assertEquals("Some files were not found", Collections.<String>emptyList(), failedToFind);
-
-        return resources;
+        doAnswer(answer).when(mockedContext).registerService(Matchers.<String>any(), any(), Matchers.<Dictionary<String, ?>>any());
+        doAnswer(answer).when(mockedContext).registerService(Matchers.<Class>any(), any(), Matchers.<Dictionary<String, ?>>any());
     }
 
     @After
     }
 
     @After
@@ -161,13 +165,6 @@ public abstract class AbstractConfigTest extends
         transaction.commit();
     }
 
         transaction.commit();
     }
 
-    protected void assertSame(ObjectName oN1, ObjectName oN2) {
-        assertEquals(oN1.getKeyProperty("instanceName"),
-                oN2.getKeyProperty("instanceName"));
-        assertEquals(oN1.getKeyProperty("interfaceName"),
-                oN2.getKeyProperty("interfaceName"));
-    }
-
     protected void assertStatus(CommitStatus status, int expectedNewInstances,
             int expectedRecreatedInstances, int expectedReusedInstances) {
         assertEquals("New instances mismatch in " + status, expectedNewInstances, status.getNewInstances().size());
     protected void assertStatus(CommitStatus status, int expectedNewInstances,
             int expectedRecreatedInstances, int expectedReusedInstances) {
         assertEquals("New instances mismatch in " + status, expectedNewInstances, status.getNewInstances().size());
@@ -177,25 +174,12 @@ public abstract class AbstractConfigTest extends
                 .size());
     }
 
                 .size());
     }
 
-    protected ObjectName createTestConfigBean(
-            ConfigTransactionJMXClient transaction, String implementationName,
-            String name) throws InstanceAlreadyExistsException {
-        return transaction.createModule(implementationName,
-                name);
-    }
 
     protected void assertBeanCount(int i, String configMXBeanName) {
         assertEquals(i, configRegistry.lookupConfigBeans(configMXBeanName)
                 .size());
     }
 
 
     protected void assertBeanCount(int i, String configMXBeanName) {
         assertEquals(i, configRegistry.lookupConfigBeans(configMXBeanName)
                 .size());
     }
 
-    protected void assertBeanExists(int count, String moduleName,
-            String instanceName) {
-        assertEquals(1,
-                configRegistry.lookupConfigBeans(moduleName, instanceName)
-                        .size());
-    }
-
     /**
      *
      * @param configBeanClass
     /**
      *
      * @param configBeanClass
@@ -215,7 +199,7 @@ public abstract class AbstractConfigTest extends
 
     public static interface BundleContextServiceRegistrationHandler {
 
 
     public static interface BundleContextServiceRegistrationHandler {
 
-       void handleServiceRegistration(Object serviceInstance);
+       void handleServiceRegistration(Class<?> clazz, Object serviceInstance, Dictionary<String, ?> props);
 
     }
 
 
     }
 
@@ -229,32 +213,40 @@ public abstract class AbstractConfigTest extends
 
             Object serviceTypeRaw = args[0];
             Object serviceInstance = args[1];
 
             Object serviceTypeRaw = args[0];
             Object serviceInstance = args[1];
+            Dictionary<String, ?> props = (Dictionary) args[2];
 
             if (serviceTypeRaw instanceof Class) {
                 Class<?> serviceType = (Class<?>) serviceTypeRaw;
 
             if (serviceTypeRaw instanceof Class) {
                 Class<?> serviceType = (Class<?>) serviceTypeRaw;
-                invokeServiceHandler(serviceInstance, serviceType);
+                invokeServiceHandler(serviceInstance, serviceType, props);
 
             } else if(serviceTypeRaw instanceof String[]) {
                 for (String className : (String[]) serviceTypeRaw) {
 
             } else if(serviceTypeRaw instanceof String[]) {
                 for (String className : (String[]) serviceTypeRaw) {
-                    try {
-                        Class<?> serviceType = Class.forName(className);
-                        invokeServiceHandler(serviceInstance, serviceType);
-                    } catch (ClassNotFoundException e) {
-                        logger.warn("Not handling service registration of type {} ", className, e);
-                    }
+                    invokeServiceHandler(serviceInstance, className, props);
                 }
                 }
+            } else if (serviceTypeRaw instanceof String) {
+                invokeServiceHandler(serviceInstance, (String) serviceTypeRaw, props);
+            } else {
+                throw new IllegalStateException("Not handling service registration of type, Unknown type" +  serviceTypeRaw);
+            }
 
 
-            } else
-                logger.debug("Not handling service registration of type {}, Unknown type", serviceTypeRaw);
 
             return mockedServiceRegistration;
         }
 
 
             return mockedServiceRegistration;
         }
 
-        private void invokeServiceHandler(Object serviceInstance, Class<?> serviceType) {
+        public void invokeServiceHandler(Object serviceInstance, String className, Dictionary<String, ?> props) {
+            try {
+                Class<?> serviceType = Class.forName(className);
+                invokeServiceHandler(serviceInstance, serviceType, props);
+            } catch (ClassNotFoundException e) {
+                throw new IllegalStateException("Not handling service registration of type " +  className, e);
+            }
+        }
+
+        private void invokeServiceHandler(Object serviceInstance, Class<?> serviceType, Dictionary<String, ?> props) {
             BundleContextServiceRegistrationHandler serviceRegistrationHandler = getBundleContextServiceRegistrationHandler(serviceType);
 
             if (serviceRegistrationHandler != null) {
             BundleContextServiceRegistrationHandler serviceRegistrationHandler = getBundleContextServiceRegistrationHandler(serviceType);
 
             if (serviceRegistrationHandler != null) {
-                serviceRegistrationHandler.handleServiceRegistration(serviceType.cast(serviceInstance));
+                serviceRegistrationHandler.handleServiceRegistration(serviceType, serviceInstance, props);
             }
         }
     }
             }
         }
     }
index 09aea0895fe6e4c6b965d68605e7f86d5ae6fc03..5a3747ee142c7fd35ddef29bde078aef134d290c 100644 (file)
@@ -11,7 +11,6 @@ import com.google.common.collect.Sets;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.api.ServiceReferenceWritableRegistry;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.impl.jmx.BaseJMXRegistrator;
 import org.opendaylight.controller.config.manager.impl.jmx.TransactionJMXRegistrator;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.impl.jmx.BaseJMXRegistrator;
 import org.opendaylight.controller.config.manager.impl.jmx.TransactionJMXRegistrator;
@@ -70,7 +69,7 @@ public class ConfigTransactionControllerImplTest extends
             }
         }, currentlyRegisteredFactories);
 
             }
         }, currentlyRegisteredFactories);
 
-        ServiceReferenceWritableRegistry writableRegistry = ServiceReferenceRegistryImpl.createSRWritableRegistry(
+        SearchableServiceReferenceWritableRegistry writableRegistry = ServiceReferenceRegistryImpl.createSRWritableRegistry(
                 ServiceReferenceRegistryImpl.createInitialSRLookupRegistry(), txLookupRegistry, currentlyRegisteredFactories);
 
 
                 ServiceReferenceRegistryImpl.createInitialSRLookupRegistry(), txLookupRegistry, currentlyRegisteredFactories);
 
 
index bbb3784b33b02e49be8929d39e983e2c4cb7d33a..9595e60ff64ccc325f7d8079cd64fd51ba26ed3c 100644 (file)
@@ -23,7 +23,7 @@ public class ConfigTransactionManagerImplTest extends
 
     @Before
     public void setUp() {
 
     @Before
     public void setUp() {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver());
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext));
 
     }
 
 
     }
 
index 6d0b340cd3c1c0720fbe78ee6823098bf92b17ca..3e7b65e1bdcf8f25cfe6c255e43072edc2382f6a 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.collect.ImmutableMap;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest.RecordingBundleContextServiceRegistrationHandler.RegistrationHolder;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBean;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBean;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
@@ -18,6 +19,7 @@ import org.opendaylight.controller.config.manager.testingservices.parallelapsp.t
 import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
 import javax.management.Attribute;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
 import javax.management.Attribute;
@@ -27,7 +29,7 @@ import javax.management.JMX;
 import javax.management.MBeanException;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
 import javax.management.MBeanException;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
-
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import java.util.Map;
 import java.util.Set;
 
@@ -41,6 +43,7 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest {
     @Before
     public void setUp() {
         super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
     @Before
     public void setUp() {
         super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+                mockedContext,
                 new TestingFixedThreadPoolModuleFactory(),
                 new TestingParallelAPSPModuleFactory(),
                 new TestingScheduledThreadPoolModuleFactory()));
                 new TestingFixedThreadPoolModuleFactory(),
                 new TestingParallelAPSPModuleFactory(),
                 new TestingScheduledThreadPoolModuleFactory()));
@@ -71,11 +74,19 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest {
         // create apsp-parallel
         createParallelAPSP(transaction1, serviceReference);
         transaction1.commit();
         // create apsp-parallel
         createParallelAPSP(transaction1, serviceReference);
         transaction1.commit();
+
         // check fixed1 is used
         ServiceReferenceMXBean serviceReferenceMXBean = JMX.newMXBeanProxy(platformMBeanServer,
                 withoutTransactionName(serviceReference), ServiceReferenceMXBean.class);
         assertEquals(withoutTransactionName(fixedTPTransactionON), serviceReferenceMXBean.getCurrentImplementation());
         checkApspThreadCount(fixedNrOfThreads);
         // check fixed1 is used
         ServiceReferenceMXBean serviceReferenceMXBean = JMX.newMXBeanProxy(platformMBeanServer,
                 withoutTransactionName(serviceReference), ServiceReferenceMXBean.class);
         assertEquals(withoutTransactionName(fixedTPTransactionON), serviceReferenceMXBean.getCurrentImplementation());
         checkApspThreadCount(fixedNrOfThreads);
+        // check OSGi SR
+        List<RegistrationHolder> registrations =
+                ((RecordingBundleContextServiceRegistrationHandler) currentBundleContextServiceRegistrationHandler).getRegistrations();
+        assertEquals(1, registrations.size());
+        RegistrationHolder record = registrations.get(0);
+        assertEquals(TestingThreadPoolIfc.class, record.clazz);
+        assertEquals(ImmutableMap.of("name","ref"), (Map<String, String>) record.props);
 
         // switch reference to scheduled
         ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction();
 
         // switch reference to scheduled
         ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction();
index 3c2230735eee0c41589e33dfb03b9e7c5972a0d8..dd6588f3f63cb7c0f06589f1890cb68c3f94b619 100644 (file)
@@ -60,10 +60,6 @@ public class HardcodedModuleFactoriesResolver implements ModuleFactoriesResolver
         }
     }
 
         }
     }
 
-    public HardcodedModuleFactoriesResolver(ModuleFactory... list) {
-        this(mockBundleContext(),list);
-    }
-
     private static BundleContext mockBundleContext() {
         BundleContext bundleContext = Mockito.mock(BundleContext.class);
         ServiceRegistration<ModuleFactory> serviceRegistration = mock(ServiceRegistration.class);
     private static BundleContext mockBundleContext() {
         BundleContext bundleContext = Mockito.mock(BundleContext.class);
         ServiceRegistration<ModuleFactory> serviceRegistration = mock(ServiceRegistration.class);
index 978d375cd24df6aff7cb508d4087c9cc1580b696..f42b9559c4bb7e5a562aead7b7a60c0bc692602f 100644 (file)
@@ -37,7 +37,7 @@ public class DependentWiringTest extends AbstractParallelAPSPTest {
 
     @Before
     public void setUp() {
 
     @Before
     public void setUp() {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 new TestingFixedThreadPoolModuleFactory(),
                 new TestingParallelAPSPModuleFactory()));
     }
                 new TestingFixedThreadPoolModuleFactory(),
                 new TestingParallelAPSPModuleFactory()));
     }
index 642f526efd703730e7c19931496cfb803d0e91cb..0d4fc91a51760963b5b1b6a7f7dae1792544b698 100644 (file)
@@ -7,12 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.parallelapsp.test;
 
  */
 package org.opendaylight.controller.config.manager.testingservices.parallelapsp.test;
 
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.concurrent.Executor;
-
-import javax.management.ObjectName;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
@@ -27,6 +21,11 @@ import org.opendaylight.controller.config.manager.testingservices.threadpool.Tes
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
+import javax.management.ObjectName;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.concurrent.Executor;
+
 public class MockedDependenciesTest extends AbstractParallelAPSPTest {
     private final String threadPoolImplementationName = "mockedthreadpool";
 
 public class MockedDependenciesTest extends AbstractParallelAPSPTest {
     private final String threadPoolImplementationName = "mockedthreadpool";
 
@@ -36,7 +35,7 @@ public class MockedDependenciesTest extends AbstractParallelAPSPTest {
         ClassBasedModuleFactory mockedThreadPoolConfigFactory = new ClassBasedModuleFactory(
                 threadPoolImplementationName, MockedThreadPoolModule.class);
 
         ClassBasedModuleFactory mockedThreadPoolConfigFactory = new ClassBasedModuleFactory(
                 threadPoolImplementationName, MockedThreadPoolModule.class);
 
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 new TestingParallelAPSPModuleFactory(),
                 mockedThreadPoolConfigFactory));
     }
                 new TestingParallelAPSPModuleFactory(),
                 mockedThreadPoolConfigFactory));
     }
index 28fea454fe44ef4b472eba4b4e86d9364dfe9c72..340e19480175a124bb8408cead317fe05624f08f 100644 (file)
@@ -7,18 +7,17 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.test;
 
  */
 package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.test;
 
-import static org.junit.Assert.assertEquals;
-
 import org.junit.After;
 import org.junit.Before;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolImpl;
 import org.junit.After;
 import org.junit.Before;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolImpl;
-import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool
-        .TestingScheduledThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
 
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
 
+import static org.junit.Assert.assertEquals;
+
 public abstract class AbstractScheduledTest extends AbstractConfigTest {
     protected static final String scheduled1 = "scheduled1";
 
 public abstract class AbstractScheduledTest extends AbstractConfigTest {
     protected static final String scheduled1 = "scheduled1";
 
@@ -26,7 +25,7 @@ public abstract class AbstractScheduledTest extends AbstractConfigTest {
     public final void setUp() {
         assertEquals(0,
                 TestingScheduledThreadPoolImpl.getNumberOfCloseMethodCalls());
     public final void setUp() {
         assertEquals(0,
                 TestingScheduledThreadPoolImpl.getNumberOfCloseMethodCalls());
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 new TestingScheduledThreadPoolModuleFactory(),
                 new TestingFixedThreadPoolModuleFactory(),
                 new TestingParallelAPSPModuleFactory()));
                 new TestingScheduledThreadPoolModuleFactory(),
                 new TestingFixedThreadPoolModuleFactory(),
                 new TestingParallelAPSPModuleFactory()));
index 9852a45853b1fad9f0bbd9ab4e3011bb06f8d29b..547d421c9276f96a2acfa3b2ece4971998aefce6 100644 (file)
@@ -68,7 +68,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
 
     @Before
     public void setUp() {
 
     @Before
     public void setUp() {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 new TestingFixedThreadPoolModuleFactory()));
     }
 
                 new TestingFixedThreadPoolModuleFactory()));
     }
 
index 296ce79f6e9cefeb5723107a59cef9b4cc0f3194..d9c9dada6202be0a4eac69d138329cb5f69c745f 100644 (file)
@@ -35,7 +35,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     public void setUp() throws Exception {
 
         factory = new LogbackModuleFactory();
     public void setUp() throws Exception {
 
         factory = new LogbackModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory));
     }
 
     @Test
     }
 
     @Test
index e543f752e17b44ee6ab2a1851b54168fccb422d6..37bfb6d9578920c62115fd4deebaf7dc8c2cf750 100644 (file)
@@ -49,7 +49,7 @@ public class LogbackModuleWithInitialConfigurationTest extends AbstractConfigTes
     public void setUp() throws IOException, ClassNotFoundException {
 
         factory = new LogbackModuleFactory();
     public void setUp() throws IOException, ClassNotFoundException {
 
         factory = new LogbackModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory));
     }
 
     /**
     }
 
     /**
index 814965981226aa2ee71fa2184843ad741cc7d414..3c21e57f6e8aed1f298fd917bf434eda93d5647c 100644 (file)
@@ -42,7 +42,7 @@ public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
     public void setUp() throws JoranException, IOException {
 
         factory = new LogbackModuleFactory();
     public void setUp() throws JoranException, IOException {
 
         factory = new LogbackModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory));
 
         lc = (LoggerContext) LoggerFactory.getILoggerFactory();
         JoranConfigurator configurator = new JoranConfigurator();
 
         lc = (LoggerContext) LoggerFactory.getILoggerFactory();
         JoranConfigurator configurator = new JoranConfigurator();
index f29895c6d00c3428c0329b5aae5be1d494b2530f..e89d82a28fd6b3f8876e89724d254691bf90fad3 100644 (file)
@@ -31,7 +31,7 @@ public class GlobalEventExecutorModuleTest extends AbstractConfigTest {
     @Before
     public void setUp() {
         factory = new GlobalEventExecutorModuleFactory();
     @Before
     public void setUp() {
         factory = new GlobalEventExecutorModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory));
     }
 
     @Test
     }
 
     @Test
index 590bd9185e67ae1480da0527545fddc953e476bb..76134b025cf0c1a975338eb35c0644e8ba2d47db 100644 (file)
@@ -28,7 +28,7 @@ public class NettyThreadgroupModuleTest extends AbstractConfigTest {
     @Before
     public void setUp() {
         factory = new NettyThreadgroupModuleFactory();
     @Before
     public void setUp() {
         factory = new NettyThreadgroupModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory));
     }
 
     @Test
     }
 
     @Test
index 177adc1588d0ce2697a010ce37eb747f5879d7ff..0b339fc6007834f9c8fad9cc9619457ee60fa9f1 100644 (file)
@@ -40,7 +40,7 @@ public class AsyncEventBusConfigBeanTest extends AbstractConfigTest {
                 TestingScheduledThreadPoolModule.class, poolImplName);
 
         factory = new AsyncEventBusModuleFactory();
                 TestingScheduledThreadPoolModule.class, poolImplName);
 
         factory = new AsyncEventBusModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory,
                 scheduledThreadPoolConfigFactory));
     }
 
                 scheduledThreadPoolConfigFactory));
     }
 
index bc5e98bcb358ec419685823e0403fefe4f6f2e2d..aeb6d6b959ab3ce70a662b7d2a6efbf773ce58f5 100644 (file)
@@ -7,14 +7,6 @@
  */
 package org.opendaylight.controller.config.threadpool.eventbus;
 
  */
 package org.opendaylight.controller.config.threadpool.eventbus;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
@@ -25,6 +17,14 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleFactory;
 
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleFactory;
 
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
 public class SyncEventBusConfigBeanTest extends AbstractConfigTest {
 
     private EventBusModuleFactory factory;
 public class SyncEventBusConfigBeanTest extends AbstractConfigTest {
 
     private EventBusModuleFactory factory;
@@ -34,7 +34,7 @@ public class SyncEventBusConfigBeanTest extends AbstractConfigTest {
     public void setUp() {
 
         factory = new EventBusModuleFactory();
     public void setUp() {
 
         factory = new EventBusModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory));
     }
 
     @Test
     }
 
     @Test
index 781215da43ef18063a2408a1478234b03df3fad2..c95661d9c95b7470ca45156b56c6bc2df3fe7fe6 100644 (file)
@@ -36,7 +36,7 @@ public class FixedThreadPoolConfigBeanTest extends AbstractConfigTest {
     @Before
     public void setUp() {
         factory = new FixedThreadPoolModuleFactory();
     @Before
     public void setUp() {
         factory = new FixedThreadPoolModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory,
                 new NamingThreadFactoryModuleFactory()));
     }
 
                 new NamingThreadFactoryModuleFactory()));
     }
 
index f0e8a108e74c76c43b14dfee998c60faee9fdd98..a1d1c40655ec867f8d0d7404a1c3e65e80cab66c 100644 (file)
@@ -38,7 +38,7 @@ public class FlexibleThreadPoolConfigBeanTest extends AbstractConfigTest {
     public void setUp() {
 
         flexibleFactory = new FlexibleThreadPoolModuleFactory();
     public void setUp() {
 
         flexibleFactory = new FlexibleThreadPoolModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(flexibleFactory,
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,flexibleFactory,
                 new NamingThreadFactoryModuleFactory()));
     }
 
                 new NamingThreadFactoryModuleFactory()));
     }
 
index 6dea96e21f3cf42d64f5ab1ed17b8981a61f5e2d..499beced5f4511906f2d7cf0ecaffd4335eae63d 100644 (file)
@@ -16,7 +16,6 @@ import static org.junit.matchers.JUnitMatchers.containsString;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
@@ -38,7 +37,7 @@ public class NamingThreadPoolFactoryConfigBeanTest extends AbstractConfigTest {
     public void setUp() {
 
         factory = new NamingThreadFactoryModuleFactory();
     public void setUp() {
 
         factory = new NamingThreadFactoryModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory));
     }
 
     @Test
     }
 
     @Test
index 538d43726b1119f7a913da4a328ddbc2c5b08011..ef06e43d2f291b87f994d04612c0f9f5488ea86b 100644 (file)
@@ -39,7 +39,7 @@ public class ScheduledThreadPoolConfigBeanTest extends AbstractConfigTest {
     public void setUp() {
 
         factory = new ScheduledThreadPoolModuleFactory();
     public void setUp() {
 
         factory = new ScheduledThreadPoolModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory,
                 new NamingThreadFactoryModuleFactory()));
     }
 
                 new NamingThreadFactoryModuleFactory()));
     }
 
index 598b6b3d5b5ca6cf7f19b79b56de11f6cfa82c06..7505fcf485c62431fc29ee28b8d635cb5a7e6519 100644 (file)
@@ -7,11 +7,6 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.it;
 
  */
 package org.opendaylight.controller.config.yangjmxgenerator.it;
 
-import static org.junit.Assert.fail;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -26,6 +21,11 @@ import org.opendaylight.controller.config.yang.test.impl.DtoB;
 import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
 import org.opendaylight.controller.config.yang.test.impl.TestImplModuleMXBean;
 
 import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
 import org.opendaylight.controller.config.yang.test.impl.TestImplModuleMXBean;
 
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+
+import static org.junit.Assert.fail;
+
 @Ignore
 // ietf beans are not JMX compliant beans:
 // Do not know how to make a
 @Ignore
 // ietf beans are not JMX compliant beans:
 // Do not know how to make a
@@ -42,7 +42,7 @@ public class ITTest extends AbstractConfigTest {
     public void setUp() {
 
         factory = new TestImplModuleFactory();
     public void setUp() {
 
         factory = new TestImplModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 factory));
     }
 
                 factory));
     }
 
index 281c1aade55db8972553f578595d89e3128d5d46..13a31f59766c7e4ecb1936aa8ca64c3d7c8b85ee 100644 (file)
@@ -48,7 +48,7 @@ public class NetconfTestImplModuleTest  extends AbstractConfigTest {
     public void setUp() {
 
         factory = new NetconfTestImplModuleFactory();
     public void setUp() {
 
         factory = new NetconfTestImplModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory,
                 new DepTestImplModuleFactory(), new IdentityTestModuleFactory()));
     }
 
                 new DepTestImplModuleFactory(), new IdentityTestModuleFactory()));
     }
 
index 08d22b96d67bcee2331ca6512904154cc11b6868..37ef257224d30ad749a6030557fab85f7fb734c6 100644 (file)
                                 </provider>
                             </instance>
                         </service>
                                 </provider>
                             </instance>
                         </service>
+
                         <service>
                             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
                                 binding:binding-broker-osgi-registry
                         <service>
                             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
                                 binding:binding-broker-osgi-registry
                                 </provider>
                             </instance>
                         </service>
                                 </provider>
                             </instance>
                         </service>
+                        <service>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+                            <instance>
+                                <name>binding-rpc-broker</name>
+                                <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+                            </instance>
+                        </service>
                         <service>
                             <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
                                 binding-impl:binding-dom-mapping-service
                         <service>
                             <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
                                 binding-impl:binding-dom-mapping-service
index cd38d3babef700c8cb5b55529bbac71fb5e4c943..5950f3ded81c0ec8771f13e93b4b755cd88d9256 100644 (file)
@@ -147,7 +147,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
         this.factory = new NetconfTestImplModuleFactory();
         this.factory2 = new DepTestImplModuleFactory();
         this.factory3 = new IdentityTestModuleFactory();
         this.factory = new NetconfTestImplModuleFactory();
         this.factory2 = new DepTestImplModuleFactory();
         this.factory3 = new IdentityTestModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, this.factory2,
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, this.factory, this.factory2,
                 this.factory3));
 
         transactionProvider = new TransactionProvider(this.configRegistryClient, NETCONF_SESSION_ID);
                 this.factory3));
 
         transactionProvider = new TransactionProvider(this.configRegistryClient, NETCONF_SESSION_ID);
index 0cc55719e12875ece51220073657867fc3a9c21f..cd4e1f05ad223258b0ce72cf12f91ad09311514c 100644 (file)
@@ -61,7 +61,7 @@ public class ConfigPersisterActivator implements BundleActivator {
         long maxWaitForCapabilitiesMillis = getMaxWaitForCapabilitiesMillis(propertiesProvider);
         List<ConfigSnapshotHolder> configs = persisterAggregator.loadLastConfigs();
         long conflictingVersionTimeoutMillis = getConflictingVersionTimeoutMillis(propertiesProvider);
         long maxWaitForCapabilitiesMillis = getMaxWaitForCapabilitiesMillis(propertiesProvider);
         List<ConfigSnapshotHolder> configs = persisterAggregator.loadLastConfigs();
         long conflictingVersionTimeoutMillis = getConflictingVersionTimeoutMillis(propertiesProvider);
-        logger.trace("Following configs will be pushed: {}", configs);
+        logger.debug("Following configs will be pushed: {}", configs);
 
         InnerCustomizer innerCustomizer = new InnerCustomizer(configs, maxWaitForCapabilitiesMillis,
                 conflictingVersionTimeoutMillis, persisterAggregator);
 
         InnerCustomizer innerCustomizer = new InnerCustomizer(configs, maxWaitForCapabilitiesMillis,
                 conflictingVersionTimeoutMillis, persisterAggregator);
index 4461054437ce61ef47fd2eea76a9b23ae15b5ef3..60c2e5292156ee235e391689f8c8d9a41fdedddb 100644 (file)
@@ -35,6 +35,7 @@ public class DefaultCommitNotificationProducer extends NotificationBroadcasterSu
 
     public DefaultCommitNotificationProducer(MBeanServer mBeanServer) {
         this.mbeanServer = mBeanServer;
 
     public DefaultCommitNotificationProducer(MBeanServer mBeanServer) {
         this.mbeanServer = mBeanServer;
+        logger.debug("Registering to JMX under {}", on);
         registerMBean(this, mbeanServer, on);
     }
 
         registerMBean(this, mbeanServer, on);
     }
 
index 8b2af393439e932ac069481ad3670b3b154fe0cb..af83fe46027ee6816855ab1a6e051139fea5603d 100644 (file)
@@ -78,7 +78,7 @@ public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest {
 
     @Before
     public void setUp() throws Exception {
 
     @Before
     public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(NetconfITTest.getModuleFactoriesS().toArray(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,NetconfITTest.getModuleFactoriesS().toArray(
                 new ModuleFactory[0])));
 
         NetconfMonitoringServiceImpl monitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider());
                 new ModuleFactory[0])));
 
         NetconfMonitoringServiceImpl monitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider());
index e45a249ad4e1f901075060451c6865a5fd54b585..cc9e8c367a9f3d2871842510daddd29aa95ea441 100644 (file)
@@ -46,7 +46,7 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest {
 
     @Before
     public void setUp() throws Exception {
 
     @Before
     public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(getModuleFactories().toArray(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,getModuleFactories().toArray(
                 new ModuleFactory[0])));
 
         NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
                 new ModuleFactory[0])));
 
         NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
index d169858d35ff90a720d039f8d8ecc0fa85aa60e3..cfe69d4dfd3b514eae9096286a146dfbe54d0cd2 100644 (file)
@@ -95,7 +95,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Before
     public void setUp() throws Exception {
 
     @Before
     public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(getModuleFactories().toArray(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,getModuleFactories().toArray(
                 new ModuleFactory[0])));
 
         loadMessages();
                 new ModuleFactory[0])));
 
         loadMessages();
index 92caea17d5eaea998d5d62ab6682c765287c5329..a771e27946aa11d5297b354f6df7e7c6da2c96d2 100644 (file)
@@ -72,7 +72,7 @@ public class NetconfMonitoringITTest extends AbstractNetconfConfigTest {
 
     @Before
     public void setUp() throws Exception {
 
     @Before
     public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(NetconfITTest.getModuleFactoriesS().toArray(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, NetconfITTest.getModuleFactoriesS().toArray(
                 new ModuleFactory[0])));
 
         monitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider());
                 new ModuleFactory[0])));
 
         monitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider());