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.clustering.services_implementation.internal;
12 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
13 import org.opendaylight.controller.sal.core.IContainerAware;
15 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
16 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
17 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
18 import org.opendaylight.controller.clustering.services.IClusterServices;
19 import org.opendaylight.controller.clustering.services.ICoordinatorChangeAware;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22 import org.apache.felix.dm.Component;
24 public class Activator extends ComponentActivatorAbstractBase {
25 protected static final Logger logger = LoggerFactory
26 .getLogger(Activator.class);
29 * Function called when the activator starts just after some
30 * initializations are done by the
31 * ComponentActivatorAbstractBase.
39 * Function called when the activator stops just before the
40 * cleanup done by ComponentActivatorAbstractBase
44 public void destroy() {
48 * Function that is used to communicate to dependency manager the
49 * list of known implementations for services inside a container
52 * @return An array containing all the CLASS objects that will be
53 * instantiated in order to get an fully working implementation
57 public Object[] getGlobalImplementations() {
58 Object[] res = { ClusterManager.class, ClusterGlobalManager.class };
63 * Function that is used to communicate to dependency manager the
64 * list of known implementations for services inside a container
67 * @return An array containing all the CLASS objects that will be
68 * instantiated in order to get an fully working implementation
72 public Object[] getImplementations() {
73 Object[] res = { ClusterContainerManager.class };
78 * Function that is called when configuration of the dependencies
81 * @param c dependency manager Component object, used for
82 * configuring the dependencies exported and imported
83 * @param imp Implementation class that is being configured,
84 * needed as long as the same routine can configure multiple
86 * @param containerName The containerName being configured, this allow
87 * also optional per-container different behavior if needed, usually
88 * should not be the case though.
91 public void configureInstance(Component c, Object imp, String containerName) {
92 if (imp.equals(ClusterContainerManager.class)) {
93 c.setInterface(new String[] { IClusterContainerServices.class.getName() },
96 c.add(createServiceDependency()
97 .setService(IClusterServices.class)
98 .setCallbacks("setClusterService", "unsetClusterService")
101 // CacheUpdate services will be none or many so the
102 // dependency is optional
103 c.add(createContainerServiceDependency(containerName)
104 .setService(ICacheUpdateAware.class)
105 .setCallbacks("setCacheUpdateAware", "unsetCacheUpdateAware")
106 .setRequired(false));
108 // Coordinator change event can be one or many so
109 // dependency is optional
110 c.add(createContainerServiceDependency(containerName)
111 .setService(ICoordinatorChangeAware.class)
112 .setCallbacks("setCoordinatorChangeAware", "unsetCoordinatorChangeAware")
113 .setRequired(false));
118 * Function that is called when configuration of the dependencies
121 * @param c dependency manager Component object, used for
122 * configuring the dependencies exported and imported
123 * @param imp Implementation class that is being configured,
124 * needed as long as the same routine can configure multiple
128 public void configureGlobalInstance(Component c, Object imp) {
129 if (imp.equals(ClusterManager.class)) {
130 // export the service for Apps and Plugins
131 c.setInterface(new String[] { IClusterServices.class.getName(), IContainerAware.class.getName() }, null);
134 if (imp.equals(ClusterGlobalManager.class)) {
135 c.setInterface(new String[] { IClusterGlobalServices.class.getName() }, null);
137 c.add(createServiceDependency()
138 .setService(IClusterServices.class)
139 .setCallbacks("setClusterService", "unsetClusterService")
142 // CacheUpdate services will be none or many so the
143 // dependency is optional
144 c.add(createServiceDependency()
145 .setService(ICacheUpdateAware.class)
146 .setCallbacks("setCacheUpdateAware", "unsetCacheUpdateAware")
147 .setRequired(false));
149 // Coordinator change event can be one or many so
150 // dependency is optional
151 c.add(createServiceDependency()
152 .setService(ICoordinatorChangeAware.class)
153 .setCallbacks("setCoordinatorChangeAware", "unsetCoordinatorChangeAware")
154 .setRequired(false));