2 * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.spi;
11 import org.opendaylight.controller.config.api.DependencyResolver;
12 import org.opendaylight.controller.config.api.DependencyResolverFactory;
13 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
14 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
15 import org.osgi.framework.BundleContext;
18 * Factory which creates {@link Module} instances. An instance of this interface
19 * needs to be exported into the OSGi Service Registry. Such an instance
20 * provides metadata describing services which can be published from it.
23 * Each {@link Module} can optionally be instantiated with a
24 * {@link javax.management.DynamicMBean} which represents the configuration of
25 * the currently running instance.
27 public interface ModuleFactory {
30 * Returns the human-friendly implementation name. This value needs to be unique
31 * within all implementations of all interfaces returned by
32 * getImplementedInterfaces().
34 * @return human-friendly implementation name
36 String getImplementationName();
39 * Create a new Module instance. The returned object is expected to use the
40 * dependencyResolver provided when resolving ObjectNames to actual Module
43 * @param dependencyResolver
44 * This resolver will return actual config mbean based on its
46 * @param bundleContext
47 * Reference to OSGi bundleContext that can be used to acquire OSGi
48 * services, startup configuration and other OSGi related
51 * @return newly created module
54 Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext);
57 * Create a new Module instance. The returned object is expected to use the
58 * dependencyResolver provided when resolving ObjectNames to actual Module
59 * instances. A reference to an abstract view of the previous configuration is
60 * also provided in the form of a {@link javax.management.DynamicMBean}.
61 * Implementations should use the MBeanInfo interface to understand the
62 * structure of the configuration information.
65 * Structural information impacts hot-swap operations in that in order to
66 * perform such a swap the newly loaded code needs to understand the
67 * previously-running instance configuration layout and how to map it onto
70 * @param dependencyResolver
71 * This resolver will return actual config mbean based on its
74 * existing module from platform MBeanServer that is being
75 * reconfigured. Implementations should inspect its attributes using
76 * {@link javax.management.DynamicMBean#getAttribute(String)} and set
77 * those attributes on newly created module. If reconfiguration of
78 * live instances is supported, this live instance can be retreived
80 * {@link org.opendaylight.controller.config.api.DynamicMBeanWithInstance#getInstance()}
81 * . It is possible that casting this old instance throws
82 * {@link ClassCastException} when OSGi bundle is being updated. In
83 * this case, implementation should revert to creating new instance.
84 * @param bundleContext
85 * Reference to OSGi bundleContext that can be used to acquire OSGi
86 * services, startup configuration and other OSGi related
89 * @return newly created module
91 * if it is not possible to recover configuration from old. This
92 * leaves server in a running state but no configuration transaction
95 Module createModule(String instanceName, DependencyResolver dependencyResolver, DynamicMBeanWithInstance old,
96 BundleContext bundleContext) throws Exception;
98 boolean isModuleImplementingServiceInterface(Class<? extends AbstractServiceInterface> serviceInterface);
100 Set<Class<? extends AbstractServiceInterface>> getImplementedServiceIntefaces();
103 * Called when ModuleFactory is registered to config manager. Useful for
104 * populating the registry with pre-existing state. Since the method is called
105 * for each ModuleFactory separately and transaction is committed automatically,
106 * returned modules MUST be valid and commitable without any manual
109 * @param dependencyResolverFactory
110 * factory for getting dependency resolvers for each module.
111 * @param bundleContext
112 * Reference to OSGi bundleContext that can be used to acquire OSGi
113 * services, startup configuration and other OSGi related
116 * @return set of default modules. Null is not allowed.
118 Set<? extends Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
119 BundleContext bundleContext);