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;
13 import java.util.Dictionary;
14 import java.util.HashSet;
16 import java.util.Hashtable;
17 import org.opendaylight.controller.containermanager.IContainerManager;
18 import org.apache.felix.dm.Component;
19 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
20 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
21 import org.opendaylight.controller.configuration.IConfigurationAware;
22 import org.opendaylight.controller.configuration.IConfigurationService;
23 import org.opendaylight.controller.containermanager.IContainerAuthorization;
24 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
25 import org.opendaylight.controller.sal.core.IContainer;
26 import org.opendaylight.controller.sal.core.IContainerAware;
27 import org.opendaylight.controller.sal.core.IContainerListener;
28 import org.opendaylight.controller.sal.core.IContainerLocalListener;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 public class Activator extends ComponentActivatorAbstractBase {
34 protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
38 * Function that is used to communicate to dependency manager the list of
39 * known implementations for containerd-services
42 * @return An array containing all the CLASS objects that will be
43 * instantiated in order to get an fully working implementation
47 public Object[] getImplementations() {
48 Object[] res = { ContainerImpl.class };
53 * Function that is called when configuration of the dependencies is
57 * dependency manager Component object, used for configuring the
58 * dependencies exported and imported
60 * Implementation class that is being configured, needed as long
61 * as the same routine can configure multiple implementations
62 * @param containerName
63 * The containername being configured, this allow also optional
64 * per-container different behavior if needed, usually should not be
68 public void configureInstance(Component c, Object imp, String containerName) {
69 if (imp.equals(ContainerImpl.class)) {
71 c.setInterface(new String[] { IContainer.class.getName() }, null);
73 // private interface exported by ContainerManager to retrieve
74 // internal data, this is mandatory to implement the
75 // IContainer functionality
76 c.add(createServiceDependency().setService(IContainerInternal.class)
77 .setCallbacks("setIContainerInternal", "unsetIContainerInternal")
83 * Method which tells how many NON-containerd implementations are supported by
84 * the bundle. This way we can tune the number of components created. This
85 * components will be created ONLY at the time of bundle startup and will be
86 * destroyed only at time of bundle destruction, this is the major
87 * difference with the implementation retrieved via getImplementations where
88 * all of them are assumed to be containerd!
91 * @return The list of implementations the bundle will support, in
92 * non-containerd version
95 protected Object[] getGlobalImplementations() {
96 Object[] res = { ContainerManager.class };
101 * Configure the dependency for a given instance non-containerd
104 * Component assigned for this instance, this will be what will
105 * be used for configuration
107 * implementation to be configured
108 * @param containerName
109 * container on which the configuration happens
112 protected void configureGlobalInstance(Component c, Object imp) {
113 if (imp.equals(ContainerManager.class)) {
114 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
115 Set<String> propSet = new HashSet<String>();
116 propSet.add("containermgr.event.containerChange");
117 props.put("cachenames", propSet);
119 // export the service
121 new String[] { IContainerManager.class.getName(),
122 IContainerManager.class.getName(),
123 IConfigurationAware.class.getName(),
124 CommandProvider.class.getName(),
125 IContainerInternal.class.getName(),
126 IContainerAuthorization.class.getName(),
127 ICacheUpdateAware.class.getName()}, props);
129 c.add(createServiceDependency()
130 .setService(IClusterGlobalServices.class)
131 .setCallbacks("setClusterServices", "unsetClusterServices")
134 c.add(createServiceDependency().setService(
135 IConfigurationService.class).setCallbacks(
136 "setConfigurationService",
137 "unsetConfigurationService").setRequired(true));
139 // Key kick-starter for container creation in each component
140 c.add(createServiceDependency().setService(IContainerAware.class)
141 .setCallbacks("setIContainerAware", "unsetIContainerAware")
142 .setRequired(false));
144 // Optional interface expected to be exported by the
145 // protocol plugins to setup proper filtering based on
147 c.add(createServiceDependency()
148 .setService(IContainerListener.class)
149 .setCallbacks("setIContainerListener", "unsetIContainerListener")
150 .setRequired(false));
152 // Interface expected to be exported by the Functional Modules
153 c.add(createServiceDependency()
154 .setService(IContainerLocalListener.class)
155 .setCallbacks("setIContainerLocalListener", "unsetIContainerLocalListener")
156 .setRequired(false));