X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fspi%2FModuleFactory.java;h=c86b38149377733fdc59d3281f97a49d31dcd3d6;hb=a812fd97808299ed90e388e83c469d5f3d8348c3;hp=00db2c2cd4182d0d888c92a4f7f6ef10c2d56524;hpb=9fb64948564e252018f9b1e13e7cea2c92f991aa;p=controller.git diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/ModuleFactory.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/ModuleFactory.java index 00db2c2cd4..c86b381493 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/ModuleFactory.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/ModuleFactory.java @@ -7,11 +7,13 @@ */ package org.opendaylight.controller.config.spi; -import javax.management.DynamicMBean; - import org.opendaylight.controller.config.api.DependencyResolver; +import org.opendaylight.controller.config.api.DependencyResolverFactory; import org.opendaylight.controller.config.api.DynamicMBeanWithInstance; import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface; +import org.osgi.framework.BundleContext; + +import java.util.Set; /** * Factory which creates {@link Module instances. An instance of this interface @@ -41,11 +43,15 @@ public interface ModuleFactory { * @param dependencyResolver * This resolver will return actual config mbean based on its * ObjectName. + * @param bundleContext Reference to OSGi bundleContext that can be used to + * acquire OSGi services, startup configuration and other + * OSGi related information. + * * @return newly created module * */ public Module createModule(String instanceName, - DependencyResolver dependencyResolver); + DependencyResolver dependencyResolver, BundleContext bundleContext); /** * Create a new Module instance. The returned object is expected to use the @@ -75,17 +81,39 @@ public interface ModuleFactory { * {@link ClassCastException} when OSGi bundle is being updated. * In this case, implementation should revert to creating new * instance. + * @param bundleContext Reference to OSGi bundleContext that can be used to + * acquire OSGi services, startup configuration and other + * OSGi related information. + * * @return newly created module * @throws Exception * if it is not possible to recover configuration from old. This * leaves server in a running state but no configuration * transaction can be created. */ - public Module createModule(String instanceName, - DependencyResolver dependencyResolver, DynamicMBeanWithInstance old) - throws Exception; + public Module createModule(String instanceName, DependencyResolver dependencyResolver, + DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception; boolean isModuleImplementingServiceInterface( Class serviceInterface); + Set> getImplementedServiceIntefaces(); + + /** + * Called when ModuleFactory is registered to config manager. + * Useful for populating the registry with pre-existing state. Since + * the method is called for each ModuleFactory separately and transaction + * is committed automatically, returned modules MUST be valid and commitable + * without any manual intervention. + * + * @param dependencyResolverFactory factory for getting dependency resolvers for each module. + * @param bundleContext Reference to OSGi bundleContext that can be used to + * acquire OSGi services, startup configuration and other + * OSGi related information. + * + * @return set of default modules. Null is not allowed. + */ + public Set getDefaultModules(DependencyResolverFactory dependencyResolverFactory, + BundleContext bundleContext); + }