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