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.opendaylight.controller.clustering.services.IClusterGlobalServices;
13 import org.opendaylight.controller.containermanager.IContainerManager;
14 import org.opendaylight.controller.sal.core.IContainerAware;
15 import org.opendaylight.controller.sal.core.IContainer;
16 import org.opendaylight.controller.sal.core.IContainerListener;
17 import org.apache.felix.dm.Component;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 public class Activator extends ComponentActivatorAbstractBase {
23 protected static final Logger logger = LoggerFactory
24 .getLogger(Activator.class);
27 * Function called when the activator starts just after some
28 * initializations are done by the
29 * ComponentActivatorAbstractBase.
36 * Function called when the activator stops just before the
37 * cleanup done by ComponentActivatorAbstractBase
40 public void destroy() {
44 * Function that is used to communicate to dependency manager the
45 * list of known implementations for services inside a container
48 * @return An array containing all the CLASS objects that will be
49 * instantiated in order to get an fully working implementation
52 public Object[] getImplementations() {
53 Object[] res = { ContainerImpl.class };
58 * Function that is called when configuration of the dependencies
61 * @param c dependency manager Component object, used for
62 * configuring the dependencies exported and imported
63 * @param imp Implementation class that is being configured,
64 * needed as long as the same routine can configure multiple
66 * @param containerName The containerName being configured, this allow
67 * also optional per-container different behavior if needed, usually
68 * should not be the case though.
70 public void configureInstance(Component c, Object imp, String containerName) {
71 if (imp.equals(ContainerImpl.class)) {
73 c.setInterface(new String[] { IContainer.class.getName() }, null);
78 * Method which tells how many Global implementations are
79 * supported by the bundle. This way we can tune the number of
80 * components created. This components will be created ONLY at the
81 * time of bundle startup and will be destroyed only at time of
82 * bundle destruction, this is the major difference with the
83 * implementation retrieved via getImplementations where all of
84 * them are assumed to be in a container!
87 * @return The list of implementations the bundle will support,
90 protected Object[] getGlobalImplementations() {
91 Object[] res = { ContainerManager.class };
96 * Configure the dependency for a given instance Global
98 * @param c Component assigned for this instance, this will be
99 * what will be used for configuration
100 * @param imp implementation to be configured
101 * @param containerName container on which the configuration happens
103 protected void configureGlobalInstance(Component c, Object imp) {
104 if (imp.equals(ContainerManager.class)) {
106 // export the service
107 c.setInterface(new String[] { IContainerManager.class.getName() },
110 c.add(createServiceDependency().setService(
111 IClusterGlobalServices.class).setCallbacks(
112 "setClusterServices", "unsetClusterServices").setRequired(
115 // Key kick-starter for container creation in each component
116 c.add(createServiceDependency().setService(IContainerAware.class)
117 .setCallbacks("setIContainerAware", "unsetIContainerAware")
118 .setRequired(false));
120 // Optional interface expected to be exported by the
121 // protocol plugins to setup proper filtering based on
123 c.add(createServiceDependency()
124 .setService(IContainerListener.class).setCallbacks(
125 "setIContainerListener", "unsetIContainerListener")
126 .setRequired(false));