Add ModuleInfoBackedContext loading strategy to RuntimeGeneratedMapping service. 14/5414/2
authorMaros Marsalek <mmarsale@cisco.com>
Tue, 18 Feb 2014 15:51:09 +0000 (16:51 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 19 Feb 2014 14:45:27 +0000 (14:45 +0000)
RuntimeGeneratedMappingServiceImpl is now started by the config-manager.
ModuleInfoBackedContext is filled by BundleTracker in config-manager.

This fix allows use of yang identities in netconf and restconf.

Change-Id: Id59d9d2ce08bfc9216d90cb5673e2d02aafd9151
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
15 files changed:
opendaylight/config/config-manager/pom.xml
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BindingIndependentMappingServiceTracker.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtensibleBundleTracker.java [new file with mode: 0644]
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTracker.java [moved from opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtenderBundleTracker.java with 90% similarity]
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java [new file with mode: 0644]
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RuntimeGeneratedMappingServiceActivator.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/osgi/Activator.java with 56% similarity]
opendaylight/config/threadpool-config-impl/pom.xml
opendaylight/config/yang-test/src/main/yang/config-test-impl.yang
opendaylight/config/yang-test/src/main/yang/types/test-types.yang
opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/editConfig_identities.xml

index 52377ae..524cd1f 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>mockito-configuration</artifactId>
         </dependency>
+
+        <!--Dependencies regardign RuntimeGeneratedMappingService-->
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>binding-generator-impl</artifactId>
+        </dependency>
+        <!--End-->
+
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>config-util</artifactId>
index 16a0605..dbc862a 100644 (file)
@@ -44,7 +44,7 @@ public class BindingIndependentMappingServiceTracker implements ServiceTrackerCu
         this.service = service;
         CodecRegistry codecRegistry = service.getCodecRegistry();
         logger.debug("Codec registry acquired {}", codecRegistry);
-        activator.initConfigManager(ctx, codecRegistry);
+//        activator.initConfigManager(ctx, codecRegistry);
         return service;
     }
 
index e4e0708..d464cb9 100644 (file)
@@ -8,14 +8,18 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
 import java.lang.management.ManagementFactory;
+import java.util.Collection;
 
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanServer;
 
 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
 import org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator;
+import org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker;
+import org.opendaylight.controller.config.manager.impl.osgi.mapping.RuntimeGeneratedMappingServiceActivator;
 import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -25,38 +29,40 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ConfigManagerActivator implements BundleActivator {
-    private static final Logger logger = LoggerFactory
-            .getLogger(ConfigManagerActivator.class);
+    private static final Logger logger = LoggerFactory.getLogger(ConfigManagerActivator.class);
 
-    private ExtenderBundleTracker extenderBundleTracker;
+    private ExtensibleBundleTracker<Collection<Registration<YangModuleInfo>>> bundleTracker;
     private ConfigRegistryImpl configRegistry;
     private ConfigRegistryJMXRegistrator configRegistryJMXRegistrator;
     private ServiceRegistration configRegistryServiceRegistration;
 
-    private ServiceTracker<BindingIndependentMappingService, BindingIndependentMappingService> tracker;
+    private final MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
+
+    private RuntimeGeneratedMappingServiceActivator mappingServiceActivator;
 
     @Override
     public void start(BundleContext context) throws Exception {
-        BindingIndependentMappingServiceTracker mappingServiceTracker = new BindingIndependentMappingServiceTracker(
-                context, this);
-        tracker = new ServiceTracker<BindingIndependentMappingService, BindingIndependentMappingService>(
-                context, BindingIndependentMappingService.class, mappingServiceTracker);
-
-        logger.debug("Waiting for codec registry");
-
-        tracker.open();
-    }
 
-    void initConfigManager(BundleContext context, CodecRegistry codecRegistry) {
-        BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver =
-                new BundleContextBackedModuleFactoriesResolver(context);
-        MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
+        // track bundles containing YangModuleInfo
+        ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker();
+        mappingServiceActivator = new RuntimeGeneratedMappingServiceActivator(moduleInfoBundleTracker);
+        CodecRegistry codecRegistry = mappingServiceActivator.startRuntimeMappingService(context).getCodecRegistry();
 
+        // start config registry
+        BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver(
+                context);
+        configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, configMBeanServer,
+                codecRegistry);
 
-        // TODO push codecRegistry/IdentityCodec to dependencyResolver
+        // track bundles containing factories
+        BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(
+                configRegistry);
+        ModuleFactoryBundleTracker moduleFactoryBundleTracker = new ModuleFactoryBundleTracker(
+                blankTransactionServiceTracker);
 
-        configRegistry = new ConfigRegistryImpl(
-                bundleContextBackedModuleFactoriesResolver, configMBeanServer, codecRegistry);
+        // start extensible tracker
+        bundleTracker = new ExtensibleBundleTracker<>(context, moduleInfoBundleTracker, moduleFactoryBundleTracker);
+        bundleTracker.open();
 
         // register config registry to OSGi
         configRegistryServiceRegistration = context.registerService(ConfigRegistryImpl.class, configRegistry, null);
@@ -69,29 +75,20 @@ public class ConfigManagerActivator implements BundleActivator {
             throw new RuntimeException("Config Registry was already registered to JMX", e);
         }
 
-        // track bundles containing factories
-        BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(configRegistry);
-        extenderBundleTracker = new ExtenderBundleTracker(context, blankTransactionServiceTracker);
-        extenderBundleTracker.open();
-
-        ServiceTracker<?, ?> serviceTracker = new ServiceTracker(context, ModuleFactory.class, blankTransactionServiceTracker);
+        ServiceTracker<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class,
+                blankTransactionServiceTracker);
         serviceTracker.open();
     }
 
     @Override
     public void stop(BundleContext context) throws Exception {
-        try {
-            tracker.close();
-        } catch (Exception e) {
-            logger.warn("Exception while closing tracker", e);
-        }
         try {
             configRegistry.close();
         } catch (Exception e) {
             logger.warn("Exception while closing config registry", e);
         }
         try {
-            extenderBundleTracker.close();
+            bundleTracker.close();
         } catch (Exception e) {
             logger.warn("Exception while closing extender", e);
         }
@@ -107,5 +104,10 @@ public class ConfigManagerActivator implements BundleActivator {
         } catch (Exception e) {
             logger.warn("Exception while unregistering config registry", e);
         }
+        try {
+            mappingServiceActivator.close();
+        } catch (Exception e) {
+            logger.warn("Exception while closing mapping service", e);
+        }
     }
 }
diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtensibleBundleTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtensibleBundleTracker.java
new file mode 100644 (file)
index 0000000..c1ebba7
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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.osgi;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * Extensible bundle tracker. Takes several BundleTrackerCustomizers and propagates bundle events to all of them.
+ * Primary customizer
+ *
+ * @param <T>
+ */
+public final class ExtensibleBundleTracker<T> extends BundleTracker<T> {
+
+    private final BundleTrackerCustomizer<T> primaryTracker;
+    private final BundleTrackerCustomizer<?>[] additionalTrackers;
+
+    private static final Logger logger = LoggerFactory.getLogger(ExtensibleBundleTracker.class);
+
+    public ExtensibleBundleTracker(BundleContext context, BundleTrackerCustomizer<T> primaryBundleTrackerCustomizer,
+                                   BundleTrackerCustomizer<?>... additionalBundleTrackerCustomizers) {
+        this(context, Bundle.ACTIVE, primaryBundleTrackerCustomizer, additionalBundleTrackerCustomizers);
+    }
+
+    public ExtensibleBundleTracker(BundleContext context, int bundleState,
+                                   BundleTrackerCustomizer<T> primaryBundleTrackerCustomizer,
+                                   BundleTrackerCustomizer<?>... additionalBundleTrackerCustomizers) {
+        super(context, bundleState, null);
+        this.primaryTracker = primaryBundleTrackerCustomizer;
+        this.additionalTrackers = additionalBundleTrackerCustomizers;
+        logger.trace("Registered as extender with context {} and bundle state {}", context, bundleState);
+    }
+
+    @Override
+    public T addingBundle(final Bundle bundle, final BundleEvent event) {
+        T primaryTrackerRetVal = primaryTracker.addingBundle(bundle, event);
+
+        forEachAdditionalBundle(new BundleStrategy() {
+            @Override
+            public void execute(BundleTrackerCustomizer<?> tracker) {
+                tracker.addingBundle(bundle, event);
+            }
+        });
+
+        return primaryTrackerRetVal;
+    }
+
+    @Override
+    public void modifiedBundle(final Bundle bundle, final BundleEvent event, final T object) {
+        primaryTracker.modifiedBundle(bundle, event, object);
+
+        forEachAdditionalBundle(new BundleStrategy() {
+            @Override
+            public void execute(BundleTrackerCustomizer<?> tracker) {
+                tracker.modifiedBundle(bundle, event, null);
+            }
+        });
+
+    }
+
+    @Override
+    public void removedBundle(final Bundle bundle, final BundleEvent event, final T object) {
+        primaryTracker.removedBundle(bundle, event, object);
+
+        forEachAdditionalBundle(new BundleStrategy() {
+            @Override
+            public void execute(BundleTrackerCustomizer<?> tracker) {
+                tracker.removedBundle(bundle, event, null);
+            }
+        });
+    }
+
+    private void forEachAdditionalBundle(BundleStrategy lambda) {
+        for (BundleTrackerCustomizer<?> trac : additionalTrackers) {
+            lambda.execute(trac);
+        }
+    }
+
+    private static interface BundleStrategy {
+        void execute(BundleTrackerCustomizer<?> tracker);
+    }
+
+}
@@ -16,10 +16,9 @@ import java.util.List;
 import org.apache.commons.io.IOUtils;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,14 +32,12 @@ import org.slf4j.LoggerFactory;
  * the services are unregistered automatically.
  * Code based on http://www.toedter.com/blog/?p=236
  */
-public class ExtenderBundleTracker extends BundleTracker<Object> {
+public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Object> {
     private final BlankTransactionServiceTracker blankTransactionServiceTracker;
-    private static final Logger logger = LoggerFactory.getLogger(ExtenderBundleTracker.class);
+    private static final Logger logger = LoggerFactory.getLogger(ModuleFactoryBundleTracker.class);
 
-    public ExtenderBundleTracker(BundleContext context, BlankTransactionServiceTracker blankTransactionServiceTracker) {
-        super(context, Bundle.ACTIVE, null);
+    public ModuleFactoryBundleTracker(BlankTransactionServiceTracker blankTransactionServiceTracker) {
         this.blankTransactionServiceTracker = blankTransactionServiceTracker;
-        logger.trace("Registered as extender with context {}", context);
     }
 
     @Override
@@ -62,9 +59,13 @@ public class ExtenderBundleTracker extends BundleTracker<Object> {
         return bundle;
     }
 
+    @Override
+    public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
+        // NOOP
+    }
+
     @Override
     public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
-        super.removedBundle(bundle,event,object);
         // workaround for service tracker not getting removed service event
         blankTransactionServiceTracker.blankTransaction();
     }
diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java
new file mode 100644 (file)
index 0000000..8ba290f
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * 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.osgi.mapping;
+
+import org.apache.commons.io.IOUtils;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import static java.lang.String.format;
+
+/**
+ * Tracks bundles and attempts to retrieve YangModuleInfo.
+ */
+public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Collection<Registration<YangModuleInfo>>> {
+
+    private static final Logger logger = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
+    public static final String GET_MODULE_INFO_METHOD = "getModuleInfo";
+
+    public static final String MODULE_INFO_PROVIDER_PATH_PREFIX = "META-INF/services/";
+
+    private ModuleInfoBackedContext moduleInfoLoadingStrategy = ModuleInfoBackedContext.create();
+
+    public GeneratedClassLoadingStrategy getModuleInfoLoadingStrategy() {
+        return moduleInfoLoadingStrategy;
+    }
+
+    @Override
+    public Collection<Registration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
+        URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
+
+        if(resource==null) {
+            return null;
+        }
+
+        List<Registration<YangModuleInfo>> registrations = new LinkedList<>();
+
+        try (InputStream inputStream = resource.openStream()) {
+            List<String> lines = IOUtils.readLines(inputStream);
+            for (String moduleInfoName : lines) {
+                YangModuleInfo moduleInfo = retrieveModuleInfo(moduleInfoName, bundle);
+                registrations.add(moduleInfoLoadingStrategy.registerModuleInfo(moduleInfo));
+            }
+
+
+        } catch (Exception e) {
+            logger.error("Error while reading {}", resource, e);
+            throw new RuntimeException(e);
+        }
+
+        return registrations;
+    }
+
+    @Override
+    public void modifiedBundle(Bundle bundle, BundleEvent event, Collection<Registration<YangModuleInfo>> object) {
+        // NOOP
+    }
+
+    @Override
+    public void removedBundle(Bundle bundle, BundleEvent event, Collection<Registration<YangModuleInfo>> regs) {
+        if(regs == null) {
+            return;
+        }
+
+        for (Registration<YangModuleInfo> reg : regs) {
+            try {
+                reg.close();
+            } catch (Exception e) {
+                throw new RuntimeException("Unable to unregister YangModuleInfo " + reg.getInstance(), e);
+            }
+        }
+    }
+
+    private static YangModuleInfo retrieveModuleInfo(String moduleInfoClass, Bundle bundle) {
+        String errorMessage;
+        Class<?> clazz = loadClass(moduleInfoClass, bundle);
+
+        if (YangModelBindingProvider.class.isAssignableFrom(clazz) == false) {
+            errorMessage = logMessage("Class {} does not implement {} in bundle {}", clazz, YangModelBindingProvider.class, bundle);
+            throw new IllegalStateException(errorMessage);
+        }
+
+        try {
+            Object instance = clazz.newInstance();
+            Object result = clazz.getMethod(GET_MODULE_INFO_METHOD).invoke(instance);
+
+            if (YangModuleInfo.class.isAssignableFrom(result.getClass()) == false) {
+                errorMessage = logMessage("Error invoking method not found {} in bundle {}, reason {}",
+                        GET_MODULE_INFO_METHOD, bundle, "Not assignable from " + YangModuleInfo.class);
+            } else {
+                return (YangModuleInfo) result;
+            }
+
+        } catch (InstantiationException e) {
+            errorMessage = logMessage("Could not instantiate {} in bundle {}, reason {}", moduleInfoClass, bundle, e);
+        } catch (IllegalAccessException e) {
+            errorMessage = logMessage("Illegal access during instatiation of class {} in bundle {}, reason {}",
+                    moduleInfoClass, bundle, e);
+        } catch (NoSuchMethodException e) {
+            errorMessage = logMessage("Method not found {} in bundle {}, reason {}", GET_MODULE_INFO_METHOD, bundle, e);
+        } catch (InvocationTargetException e) {
+            errorMessage = logMessage("Error invoking method {} in bundle {}, reason {}", GET_MODULE_INFO_METHOD,
+                    bundle, e);
+        }
+
+        throw new IllegalStateException(errorMessage);
+    }
+
+    private static Class<?> loadClass(String moduleInfoClass, Bundle bundle) {
+        try {
+            return bundle.loadClass(moduleInfoClass);
+        } catch (ClassNotFoundException e) {
+            String errorMessage = logMessage("Could not find class {} in bunde {}, reason {}", moduleInfoClass, bundle, e);
+            throw new IllegalStateException(errorMessage);
+        }
+    }
+
+    public static String logMessage(String slfMessage, Object... params) {
+        logger.info(slfMessage, params);
+        String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
+        return format(formatMessage, params);
+    }
+}
@@ -1,50 +1,51 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 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.sal.binding.osgi;
+package org.opendaylight.controller.config.manager.impl.osgi.mapping;
 
-import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
+import javassist.ClassPool;
 import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
-import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
 import java.util.Hashtable;
 
-public class Activator implements BundleActivator {
+public class RuntimeGeneratedMappingServiceActivator implements AutoCloseable {
+
+    private static final ClassPool CLASS_POOL = ClassPool.getDefault();
 
-    private ServiceRegistration<?> reg;
     private ServiceRegistration<SchemaServiceListener> listenerReg;
     private ServiceRegistration<BindingIndependentMappingService> mappingReg;
+    private ModuleInfoBundleTracker moduleInfoBundleTracker;
 
-    @Override
-    public void start(BundleContext context) throws Exception {
-                RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
-        service.setPool(SingletonHolder.CLASS_POOL);
+    public RuntimeGeneratedMappingServiceActivator(ModuleInfoBundleTracker moduleInfoBundleTracker) {
+        this.moduleInfoBundleTracker = moduleInfoBundleTracker;
+    }
+
+    public RuntimeGeneratedMappingServiceImpl startRuntimeMappingService(BundleContext context) {
+        RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl(moduleInfoBundleTracker.getModuleInfoLoadingStrategy());
+        service.setPool(CLASS_POOL);
         service.init();
         startRuntimeMappingService(service, context);
+        return service;
     }
 
     private void startRuntimeMappingService(RuntimeGeneratedMappingServiceImpl service, BundleContext context) {
         Hashtable<String, String> properties = new Hashtable<String, String>();
         listenerReg = context.registerService(SchemaServiceListener.class, service, properties);
         mappingReg = context.registerService(BindingIndependentMappingService.class, service, properties);
-        
+
     }
 
     @Override
-    public void stop(BundleContext context) throws Exception {
-        if(listenerReg != null) {
-            listenerReg.unregister();
-        }
-        if(mappingReg != null) {
-            mappingReg.unregister();
-        }
+    public void close() throws Exception {
+        mappingReg.unregister();
+        listenerReg.unregister();
     }
 }
index 49a0181..08f1d55 100644 (file)
@@ -71,7 +71,7 @@
                   </Private-Package>
                   <Export-Package>
                       org.opendaylight.controller.config.threadpool.util,
-                      org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.threadpool.impl.rev130405.*,
+                      org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.threadpool.impl.*,
                   </Export-Package>
                </instructions>
             </configuration>
index 6ee3796..c82da58 100644 (file)
@@ -41,28 +41,20 @@ module config-test-impl {
         config:java-name-prefix IdentityTest;
     }
 
-    identity test-identity1 {
-
-    }
-
-    identity test-identity2 {
-        base test-identity1;
-    }
-
     augment "/config:modules/config:module/config:configuration" {
             case impl-identity-test {
                 when "/config:modules/config:module/config:type = 'impl-identity-test'";
 
                 leaf afi {
                     type identityref {
-                        base test-identity1;
+                        base tt:test-identity1;
                     }
                 }
 
                 container identities-container {
                     leaf afi {
                         type identityref {
-                            base test-identity1;
+                            base tt:test-identity1;
                         }
                     }
                 }
@@ -70,19 +62,19 @@ module config-test-impl {
                 list identities {
                     leaf afi {
                         type identityref {
-                            base test-identity1;
+                            base tt:test-identity1;
                         }
                     }
                     leaf safi {
                         type identityref {
-                            base test-identity1;
+                            base tt:test-identity1;
                         }
                     }
 
                     container identities-inner {
                         leaf afi {
                             type identityref {
-                                base test-identity1;
+                                base tt:test-identity1;
                             }
                         }
                     }
index 8c086d8..df5387b 100644 (file)
@@ -31,4 +31,13 @@ module test-types {
         }
       }
 
+
+
+    identity test-identity1 {
+
+    }
+
+    identity test-identity2 {
+        base test-identity1;
+    }
 }
index 31b4c78..281c1aa 100644 (file)
@@ -19,8 +19,8 @@ import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.test.impl.rev130403.TestIdentity1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.test.impl.rev130403.TestIdentity2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
 import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
 import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec;
 
index 5367498..28ffff8 100644 (file)
@@ -91,7 +91,6 @@
                 <configuration>
                     <instructions>
                         <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
-                        <Bundle-Activator>org.opendaylight.controller.sal.binding.osgi.Activator</Bundle-Activator>
                         <Export-package>
                             org.opendaylight.controller.sal.binding.spi.*,
                         </Export-package>
index 790c1fc..4deef69 100644 (file)
@@ -25,7 +25,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
 public class SingletonHolder {
 
-    public static final ClassPool CLASS_POOL = new ClassPool();
+    public static final ClassPool CLASS_POOL = ClassPool.getDefault();
     public static final org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator(
             CLASS_POOL);
     public static final RuntimeCodeGenerator RPC_GENERATOR = RPC_GENERATOR_IMPL;
index d699d22..72d62ef 100644 (file)
@@ -78,8 +78,8 @@ import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.test.impl.rev130403.TestIdentity1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.test.impl.rev130403.TestIdentity2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
 import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
 import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec;
 import org.opendaylight.yangtools.yang.model.api.Module;
index 62c6a20..8062f52 100644 (file)
                     </type>
                     <name>id-test</name>
                     <identities>
-                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity1</afi>
-                        <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity2</safi>
+                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+                        <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</safi>
                     </identities>
                     <identities>
-                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity2</afi>
-                        <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity1</safi>
+                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+                        <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</safi>
                     </identities>
                     <identities-container>
-                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity2</afi>
+                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
                     </identities-container>
-                    <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity1</afi>
+                    <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
                 </module>
             </modules>
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.