use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project controller by opendaylight.
the class ConfigManagerActivator method start.
@Override
public void start(final BundleContext context) {
LOG.info("Config manager starting...");
try {
// the inner strategy is backed by thread context cl?
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
final BindingContextProvider bindingContextProvider = new BindingContextProvider();
final RefreshingSCPModuleInfoRegistry moduleInfoRegistryWrapper = new RefreshingSCPModuleInfoRegistry(moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, bindingContextProvider, context);
final ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(moduleInfoRegistryWrapper);
// start config registry
final BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver(context);
this.configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, this.configMBeanServer, bindingContextProvider);
// track bundles containing factories
final BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(this.configRegistry);
final ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker(blankTransactionServiceTracker);
BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE, moduleInfoBundleTracker);
ExtensibleBundleTracker<?> moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context, moduleFactoryTracker);
moduleInfoBundleTracker.open(moduleInfoResolvedBundleTracker);
// start extensible tracker
moduleFactoryBundleTracker.open();
// Wrap config registry with JMX notification publishing adapter
final JMXNotifierConfigRegistry notifyingConfigRegistry = new JMXNotifierConfigRegistry(this.configRegistry, this.configMBeanServer);
// register config registry to OSGi
final AutoCloseable clsReg = OsgiRegistrationUtil.registerService(context, moduleInfoBackedContext, ClassLoadingStrategy.class);
final AutoCloseable configRegReg = OsgiRegistrationUtil.registerService(context, notifyingConfigRegistry, ConfigRegistry.class);
// register config registry to jmx
final ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(this.configMBeanServer);
try {
configRegistryJMXRegistrator.registerToJMXNoNotifications(this.configRegistry);
} catch (final InstanceAlreadyExistsException e) {
configRegistryJMXRegistrator.close();
throw new IllegalStateException("Config Registry was already registered to JMX", e);
}
// register config registry to jmx
final ConfigRegistryJMXRegistrator configRegistryJMXRegistratorWithNotifications = new ConfigRegistryJMXRegistrator(this.configMBeanServer);
try {
configRegistryJMXRegistrator.registerToJMX(notifyingConfigRegistry);
} catch (final InstanceAlreadyExistsException e) {
configRegistryJMXRegistrator.close();
configRegistryJMXRegistratorWithNotifications.close();
throw new IllegalStateException("Config Registry was already registered to JMX", e);
}
// TODO wire directly via moduleInfoBundleTracker
final ServiceTracker<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class, blankTransactionServiceTracker);
serviceTracker.open();
final AutoCloseable configMgrReg = OsgiRegistrationUtil.registerService(context, this, ConfigSystemService.class);
final List<AutoCloseable> list = Arrays.asList(bindingContextProvider, clsReg, OsgiRegistrationUtil.wrap(moduleFactoryBundleTracker), moduleInfoBundleTracker, configRegReg, configRegistryJMXRegistrator, configRegistryJMXRegistratorWithNotifications, OsgiRegistrationUtil.wrap(serviceTracker), moduleInfoRegistryWrapper, notifyingConfigRegistry, configMgrReg);
this.autoCloseable = OsgiRegistrationUtil.aggregate(list);
context.addBundleListener(this);
} catch (final IllegalStateException e) {
LOG.error("Error starting config manager", e);
}
LOG.info("Config manager start complete");
}
use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project controller by opendaylight.
the class BindingTestContext method getContext.
private SchemaContext getContext(final ImmutableSet<YangModuleInfo> moduleInfos) {
final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
ctx.addModuleInfos(moduleInfos);
return ctx.tryToCreateSchemaContext().get();
}
use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project controller by opendaylight.
the class AbstractSchemaAwareTest method getSchemaContext.
protected SchemaContext getSchemaContext() throws Exception {
final Iterable<YangModuleInfo> moduleInfos = getModuleInfos();
final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
moduleContext.addModuleInfos(moduleInfos);
return moduleContext.tryToCreateSchemaContext().get();
}
use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project controller by opendaylight.
the class SchemaUpdateForTransactionTest method loadSchemas.
public void loadSchemas(final Class<?>... classes) throws Exception {
final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
for (final Class<?> clz : classes) {
YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(clz);
context.registerModuleInfo(moduleInfo);
}
this.schemaContext = context.tryToCreateSchemaContext().get();
this.domStore.onGlobalContextUpdated(this.schemaContext);
}
use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project bgpcep by opendaylight.
the class AbstractAddPathTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
this.ribActivator = new RIBActivator();
this.ribExtension = new SimpleRIBExtensionProviderContext();
this.ribActivator.startRIBExtensionProvider(this.ribExtension);
this.bgpActivator = new BGPActivator();
this.inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
this.context = new SimpleBGPExtensionProviderContext();
this.bgpActivator.start(this.context);
this.inetActivator.start(this.context);
this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpRib.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Attributes1.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MpReachNlri.class));
this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
this.schemaContext = moduleInfoBackedContext.getSchemaContext();
if (!Epoll.isAvailable()) {
this.worker = new NioEventLoopGroup();
this.boss = new NioEventLoopGroup();
}
this.serverRegistry = new StrictBGPPeerRegistry();
this.serverDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker, this.serverRegistry);
doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
this.codecsRegistry = CodecsRegistryImpl.create(this.mappingService.getCodecFactory(), this.ribExtension.getClassLoadingStrategy());
}
Aggregations