Search in sources :

Example 1 with ObjectRegistration

use of org.opendaylight.yangtools.concepts.ObjectRegistration 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)

Aggregations

IOException (java.io.IOException)1 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 ObjectRegistration (org.opendaylight.yangtools.concepts.ObjectRegistration)1 YangModuleInfo (org.opendaylight.yangtools.yang.binding.YangModuleInfo)1