Search in sources :

Example 6 with YangModuleInfo

use of org.opendaylight.yangtools.yang.binding.YangModuleInfo in project controller by opendaylight.

the class ModuleInfoBundleTracker method addingBundle.

@Override
@SuppressWarnings("IllegalCatch")
public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(final Bundle bundle, final BundleEvent event) {
    URL resource = bundle.getEntry(YANG_MODULE_INFO_SERVICE_PATH);
    LOG.debug("Got addingBundle({}) with YangModelBindingProvider resource {}", bundle, resource);
    if (resource == null) {
        return Collections.emptyList();
    }
    List<ObjectRegistration<YangModuleInfo>> registrations = new LinkedList<>();
    try {
        for (String moduleInfoName : Resources.readLines(resource, StandardCharsets.UTF_8)) {
            LOG.trace("Retrieve ModuleInfo({}, {})", moduleInfoName, bundle);
            YangModuleInfo moduleInfo = retrieveModuleInfo(moduleInfoName, bundle);
            registrations.add(moduleInfoRegistry.registerModuleInfo(moduleInfo));
        }
        if (!starting) {
            moduleInfoRegistry.updateService();
        }
    } catch (final IOException e) {
        LOG.error("Error while reading {} from bundle {}", resource, bundle, e);
    } catch (final RuntimeException e) {
        LOG.error("Failed to process {} for bundle {}", resource, bundle, e);
    }
    LOG.trace("Got following registrations {}", registrations);
    return registrations;
}
Also used : YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) IOException(java.io.IOException) ObjectRegistration(org.opendaylight.yangtools.concepts.ObjectRegistration) URL(java.net.URL) LinkedList(java.util.LinkedList)

Example 7 with YangModuleInfo

use of org.opendaylight.yangtools.yang.binding.YangModuleInfo in project controller by opendaylight.

the class AbstractDataChangeListenerTest method setup.

@Before
public final void setup() throws Exception {
    final YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(TwoLevelList.class);
    final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
    context.registerModuleInfo(moduleInfo);
    this.schemaContext = context.tryToCreateSchemaContext().get();
    this.dclExecutorService = new TestDCLExecutorService(SpecialExecutors.newBlockingBoundedFastThreadPool(1, 10, "DCL", AbstractDataChangeListenerTest.class));
    this.datastore = new InMemoryDOMDataStore("TEST", this.dclExecutorService);
    this.datastore.onGlobalContextUpdated(this.schemaContext);
}
Also used : YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext) Before(org.junit.Before)

Aggregations

YangModuleInfo (org.opendaylight.yangtools.yang.binding.YangModuleInfo)7 ModuleInfoBackedContext (org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext)4 Before (org.junit.Before)2 BindingContextProvider (org.opendaylight.controller.config.manager.impl.osgi.mapping.BindingContextProvider)2 RefreshingSCPModuleInfoRegistry (org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry)2 IOException (java.io.IOException)1 URL (java.net.URL)1 Collection (java.util.Collection)1 Dictionary (java.util.Dictionary)1 LinkedList (java.util.LinkedList)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 Test (org.junit.Test)1 ConfigRegistryImpl (org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl)1 ConfigRegistryJMXRegistrator (org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator)1 JMXNotifierConfigRegistry (org.opendaylight.controller.config.manager.impl.jmx.JMXNotifierConfigRegistry)1 ModuleInfoBundleTracker (org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker)1 ModuleFactory (org.opendaylight.controller.config.spi.ModuleFactory)1 BindingBrokerTestFactory (org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory)1 ClassLoadingStrategy (org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy)1 ModuleInfoRegistry (org.opendaylight.mdsal.binding.generator.api.ModuleInfoRegistry)1