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