3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.containermanager.internal;
12 import org.eclipse.osgi.framework.console.CommandProvider;
14 import java.util.Dictionary;
15 import java.util.HashSet;
17 import java.util.Hashtable;
19 import org.opendaylight.controller.containermanager.IContainerManager;
20 import org.opendaylight.controller.containermanager.IContainerManagerShell;
21 import org.apache.felix.dm.Component;
22 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
23 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
24 import org.opendaylight.controller.configuration.IConfigurationAware;
25 import org.opendaylight.controller.configuration.IConfigurationService;
26 import org.opendaylight.controller.containermanager.IContainerAuthorization;
27 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
28 import org.opendaylight.controller.sal.core.IContainer;
29 import org.opendaylight.controller.sal.core.IContainerAware;
30 import org.opendaylight.controller.sal.core.IContainerListener;
31 import org.opendaylight.controller.sal.core.IContainerLocalListener;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
36 public class Activator extends ComponentActivatorAbstractBase {
37 protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
41 * Function that is used to communicate to dependency manager the list of
42 * known implementations for containerd-services
45 * @return An array containing all the CLASS objects that will be
46 * instantiated in order to get an fully working implementation
50 public Object[] getImplementations() {
51 Object[] res = { ContainerImpl.class };
56 * Function that is called when configuration of the dependencies is
60 * dependency manager Component object, used for configuring the
61 * dependencies exported and imported
63 * Implementation class that is being configured, needed as long
64 * as the same routine can configure multiple implementations
65 * @param containerName
66 * The containername being configured, this allow also optional
67 * per-container different behavior if needed, usually should not be
71 public void configureInstance(Component c, Object imp, String containerName) {
72 if (imp.equals(ContainerImpl.class)) {
74 c.setInterface(new String[] { IContainer.class.getName() }, null);
76 // private interface exported by ContainerManager to retrieve
77 // internal data, this is mandatory to implement the
78 // IContainer functionality
79 c.add(createServiceDependency().setService(IContainerInternal.class)
80 .setCallbacks("setIContainerInternal", "unsetIContainerInternal")
86 * Method which tells how many NON-containerd implementations are supported by
87 * the bundle. This way we can tune the number of components created. This
88 * components will be created ONLY at the time of bundle startup and will be
89 * destroyed only at time of bundle destruction, this is the major
90 * difference with the implementation retrieved via getImplementations where
91 * all of them are assumed to be containerd!
94 * @return The list of implementations the bundle will support, in
95 * non-containerd version
98 protected Object[] getGlobalImplementations() {
99 Object[] res = { ContainerManager.class };
104 * Configure the dependency for a given instance non-containerd
107 * Component assigned for this instance, this will be what will
108 * be used for configuration
110 * implementation to be configured
111 * @param containerName
112 * container on which the configuration happens
115 protected void configureGlobalInstance(Component c, Object imp) {
116 if (imp.equals(ContainerManager.class)) {
117 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
118 Set<String> propSet = new HashSet<String>();
119 propSet.add("containermgr.event.containerChange");
120 props.put("cachenames", propSet);
122 // export the service
124 new String[] { IContainerManager.class.getName(),
125 IContainerManager.class.getName(),
126 IConfigurationAware.class.getName(),
127 CommandProvider.class.getName(),
128 IContainerInternal.class.getName(),
129 IContainerAuthorization.class.getName(),
130 ICacheUpdateAware.class.getName(),
131 IContainerManagerShell.class.getName()}, props);
133 c.add(createServiceDependency()
134 .setService(IClusterGlobalServices.class)
135 .setCallbacks("setClusterServices", "unsetClusterServices")
138 c.add(createServiceDependency().setService(
139 IConfigurationService.class).setCallbacks(
140 "setConfigurationService",
141 "unsetConfigurationService").setRequired(true));
143 // Key kick-starter for container creation in each component
144 c.add(createServiceDependency().setService(IContainerAware.class)
145 .setCallbacks("setIContainerAware", "unsetIContainerAware")
146 .setRequired(false));
148 // Optional interface expected to be exported by the
149 // protocol plugins to setup proper filtering based on
151 c.add(createServiceDependency()
152 .setService(IContainerListener.class)
153 .setCallbacks("setIContainerListener", "unsetIContainerListener")
154 .setRequired(false));
156 // Interface expected to be exported by the Functional Modules
157 c.add(createServiceDependency()
158 .setService(IContainerLocalListener.class)
159 .setCallbacks("setIContainerLocalListener", "unsetIContainerLocalListener")
160 .setRequired(false));