2 * Copyright (c) 2013 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;
10 import javax.management.DynamicMBean;
12 import org.opendaylight.controller.config.api.DependencyResolver;
13 import org.opendaylight.controller.config.api.DependencyResolverFactory;
14 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
15 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
20 * Factory which creates {@link Module instances. An instance of this interface
21 * needs to be exported into the OSGi Service Registry. Such an instance
22 * provides metadata describing services which can be published from it.
24 * Each {@link Module } can optionally be instantiated with a
25 * {@link DynamicMBean} which represents the configuration of the currently
28 public interface ModuleFactory {
31 * Returns the human-friendly implementation name. This value needs to be
32 * unique within all implementations of all interfaces returned by
33 * getImplementedInterfaces().
35 * @return human-friendly implementation name
37 public String getImplementationName();
40 * Create a new Module instance. The returned object is expected to use the
41 * dependencyResolver provided when resolving ObjectNames to actual Module
44 * @param dependencyResolver
45 * This resolver will return actual config mbean based on its
47 * @return newly created module
50 public Module createModule(String instanceName,
51 DependencyResolver dependencyResolver);
54 * Create a new Module instance. The returned object is expected to use the
55 * dependencyResolver provided when resolving ObjectNames to actual Module
56 * instances. A reference to an abstract view of the previous configuration
57 * is also provided in the form of a {@link DynamicMBean}. Implementations
58 * should use the MBeanInfo interface to understand the structure of the
59 * configuration information.
61 * Structural information impacts hot-swap operations in that in order to
62 * perform such a swap the newly loaded code needs to understand the
63 * previously-running instance configuration layout and how to map it onto
66 * @param dependencyResolver
67 * This resolver will return actual config mbean based on its
70 * existing module from platform MBeanServer that is being
71 * reconfigured. Implementations should inspect its attributes
72 * using {@link DynamicMBean#getAttribute(String)} and set those
73 * attributes on newly created module. If reconfiguration of live
74 * instances is supported, this live instance can be retreived
76 * {@link org.opendaylight.controller.config.api.DynamicMBeanWithInstance#getInstance()}
77 * . It is possible that casting this old instance throws
78 * {@link ClassCastException} when OSGi bundle is being updated.
79 * In this case, implementation should revert to creating new
81 * @return newly created module
83 * if it is not possible to recover configuration from old. This
84 * leaves server in a running state but no configuration
85 * transaction can be created.
87 public Module createModule(String instanceName,
88 DependencyResolver dependencyResolver, DynamicMBeanWithInstance old)
91 boolean isModuleImplementingServiceInterface(
92 Class<? extends AbstractServiceInterface> serviceInterface);
95 * Called when ModuleFactory is registered to config manager.
96 * Useful for populating the registry with pre-existing state. Since
97 * the method is called for each ModuleFactory separately and transaction
98 * is committed automatically, returned modules MUST be valid and commitable
99 * without any manual intervention.
100 * @param dependencyResolverFactory factory for getting dependency resolvers for each module.
101 * @return set of default modules. Null is not allowed.
103 public Set<? extends Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory);