Search in sources :

Example 26 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class ConfigRegistryImplLookupTest method registerRuntimeBean.

private static void registerRuntimeBean(final RuntimeBean object, final BaseJMXRegistrator baseJMXRegistrator, final ObjectName runtimeON) throws InstanceAlreadyExistsException {
    String factoryName = ObjectNameUtil.getFactoryName(runtimeON);
    String instanceName = ObjectNameUtil.getInstanceName(runtimeON);
    Map<String, String> properties = ObjectNameUtil.getAdditionalPropertiesOfRuntimeBeanName(runtimeON);
    RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator = baseJMXRegistrator.createRuntimeBeanRegistrator(new ModuleIdentifier(factoryName, instanceName));
    assertThat(properties.isEmpty(), is(true));
    runtimeBeanRegistrator.registerRoot(object);
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) RootRuntimeBeanRegistratorImpl(org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl)

Example 27 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class TestingScheduledThreadPoolModuleFactory method createModule.

@Override
public Module createModule(final String instanceName, final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
    TestingScheduledThreadPoolImpl oldInstance;
    try {
        oldInstance = (TestingScheduledThreadPoolImpl) old.getInstance();
    } catch (final ClassCastException e) {
        // happens after OSGi update
        oldInstance = null;
    }
    TestingScheduledThreadPoolModule configBean = new TestingScheduledThreadPoolModule(new ModuleIdentifier(NAME, instanceName), old.getInstance(), oldInstance);
    // copy attributes
    configBean.setRecreate((Boolean) old.getAttribute("Recreate"));
    return configBean;
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier)

Example 28 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class TestingParallelAPSPModuleFactory method createModule.

@Override
public TestingParallelAPSPModule createModule(final String instanceName, final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old, final BundleContext context) throws Exception {
    TestingParallelAPSPImpl oldInstance;
    try {
        oldInstance = (TestingParallelAPSPImpl) old.getInstance();
    } catch (final ClassCastException e) {
        oldInstance = null;
    }
    TestingParallelAPSPModule result = new TestingParallelAPSPModule(new ModuleIdentifier(NAME, instanceName), dependencyResolver, old.getInstance(), oldInstance);
    // copy attributes
    String someParam = (String) old.getAttribute("SomeParam");
    result.setSomeParam(someParam);
    ObjectName threadPool = (ObjectName) old.getAttribute("ThreadPool");
    result.setThreadPool(threadPool);
    return result;
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) ObjectName(javax.management.ObjectName)

Example 29 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class BlankTransactionServiceTrackerTest method testValidationException.

@Test
public void testValidationException() throws Exception {
    IllegalArgumentException argumentException = new IllegalArgumentException();
    ValidationException validationException = ValidationException.createForSingleException(new ModuleIdentifier("m", "i"), argumentException);
    doThrow(validationException).when(blankTx).hit();
    tracker.addingService(getMockServiceReference());
    verify(blankTx, times(10)).hit();
}
Also used : ValidationException(org.opendaylight.controller.config.api.ValidationException) ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) Test(org.junit.Test)

Example 30 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class TestingFixedThreadPoolModuleFactory method createModule.

@Override
public Module createModule(final String instanceName, final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
    int threadCount = (Integer) old.getAttribute("ThreadCount");
    // is the instance compatible?
    TestingFixedThreadPool oldInstance;
    try {
        // reconfigure existing instance
        oldInstance = (TestingFixedThreadPool) old.getInstance();
    } catch (final ClassCastException e) {
        // old instance will be closed, new needs to be created
        oldInstance = null;
    }
    TestingFixedThreadPoolModule result = new TestingFixedThreadPoolModule(new ModuleIdentifier(NAME, instanceName), old.getInstance(), oldInstance);
    result.setThreadCount(threadCount);
    return result;
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier)

Aggregations

ModuleIdentifier (org.opendaylight.controller.config.api.ModuleIdentifier)30 Module (org.opendaylight.controller.config.spi.Module)11 ObjectName (javax.management.ObjectName)9 AbstractModule (org.opendaylight.controller.config.spi.AbstractModule)6 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)5 InstanceNotFoundException (javax.management.InstanceNotFoundException)5 ModuleFactory (org.opendaylight.controller.config.spi.ModuleFactory)5 DependencyResolver (org.opendaylight.controller.config.api.DependencyResolver)4 BundleContext (org.osgi.framework.BundleContext)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ValidationException (org.opendaylight.controller.config.api.ValidationException)3 ServiceInterfaceAnnotation (org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ModuleFactoryNotFoundException (org.opendaylight.controller.config.api.ModuleFactoryNotFoundException)2 ModuleInternalTransactionalInfo (org.opendaylight.controller.config.manager.impl.dependencyresolver.ModuleInternalTransactionalInfo)2 RootRuntimeBeanRegistratorImpl (org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl)2 ServiceReference (org.opendaylight.controller.config.manager.impl.jmx.ServiceReference)2 ServiceReferenceMXBeanImpl (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBeanImpl)2