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);
29 * Function that is used to communicate to dependency manager the
30 * list of known implementations for services inside a container
33 * @return An array containing all the CLASS objects that will be
34 * instantiated in order to get an fully working implementation
37 public Object[] getImplementations() {
38 Object[] res = { ContainerImpl.class };
43 * Function that is called when configuration of the dependencies
46 * @param c dependency manager Component object, used for
47 * configuring the dependencies exported and imported
48 * @param imp Implementation class that is being configured,
49 * needed as long as the same routine can configure multiple
51 * @param containerName The containerName being configured, this allow
52 * also optional per-container different behavior if needed, usually
53 * should not be the case though.
55 public void configureInstance(Component c, Object imp, String containerName) {
56 if (imp.equals(ContainerImpl.class)) {
58 c.setInterface(new String[] { IContainer.class.getName() }, null);
63 * Method which tells how many Global implementations are
64 * supported by the bundle. This way we can tune the number of
65 * components created. This components will be created ONLY at the
66 * time of bundle startup and will be destroyed only at time of
67 * bundle destruction, this is the major difference with the
68 * implementation retrieved via getImplementations where all of
69 * them are assumed to be in a container!
72 * @return The list of implementations the bundle will support,
75 protected Object[] getGlobalImplementations() {
76 Object[] res = { ContainerManager.class };
81 * Configure the dependency for a given instance Global
83 * @param c Component assigned for this instance, this will be
84 * what will be used for configuration
85 * @param imp implementation to be configured
86 * @param containerName container on which the configuration happens
88 protected void configureGlobalInstance(Component c, Object imp) {
89 if (imp.equals(ContainerManager.class)) {
92 c.setInterface(new String[] { IContainerManager.class.getName() },
95 c.add(createServiceDependency().setService(
96 IClusterGlobalServices.class).setCallbacks(
97 "setClusterServices", "unsetClusterServices").setRequired(
100 // Key kick-starter for container creation in each component
101 c.add(createServiceDependency().setService(IContainerAware.class)
102 .setCallbacks("setIContainerAware", "unsetIContainerAware")
103 .setRequired(false));
105 // Optional interface expected to be exported by the
106 // protocol plugins to setup proper filtering based on
108 c.add(createServiceDependency()
109 .setService(IContainerListener.class).setCallbacks(
110 "setIContainerListener", "unsetIContainerListener")
111 .setRequired(false));