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.
37 * Function called when the activator stops just before the
38 * cleanup done by ComponentActivatorAbstractBase
41 public void destroy() {
45 * Function that is used to communicate to dependency manager the
46 * list of known implementations for services inside a container
49 * @return An array containing all the CLASS objects that will be
50 * instantiated in order to get an fully working implementation
53 public Object[] getGlobalImplementations() {
54 Object[] res = { ClusterManager.class, ClusterGlobalManager.class };
59 * Function that is used to communicate to dependency manager the
60 * list of known implementations for services inside a container
63 * @return An array containing all the CLASS objects that will be
64 * instantiated in order to get an fully working implementation
67 public Object[] getImplementations() {
68 Object[] res = { ClusterContainerManager.class };
73 * Function that is called when configuration of the dependencies
76 * @param c dependency manager Component object, used for
77 * configuring the dependencies exported and imported
78 * @param imp Implementation class that is being configured,
79 * needed as long as the same routine can configure multiple
81 * @param containerName The containerName being configured, this allow
82 * also optional per-container different behavior if needed, usually
83 * should not be the case though.
85 public void configureInstance(Component c, Object imp, String containerName) {
86 if (imp.equals(ClusterContainerManager.class)) {
87 c.setInterface(new String[] { IClusterContainerServices.class.getName() },
90 c.add(createServiceDependency()
91 .setService(IClusterServices.class)
92 .setCallbacks("setClusterService", "unsetClusterService")
95 // CacheUpdate services will be none or many so the
96 // dependency is optional
97 c.add(createContainerServiceDependency(containerName)
98 .setService(ICacheUpdateAware.class)
99 .setCallbacks("setCacheUpdateAware", "unsetCacheUpdateAware")
100 .setRequired(false));
102 // Coordinator change event can be one or many so
103 // dependency is optional
104 c.add(createContainerServiceDependency(containerName)
105 .setService(ICoordinatorChangeAware.class)
106 .setCallbacks("setCoordinatorChangeAware", "unsetCoordinatorChangeAware")
107 .setRequired(false));
112 * Function that is called when configuration of the dependencies
115 * @param c dependency manager Component object, used for
116 * configuring the dependencies exported and imported
117 * @param imp Implementation class that is being configured,
118 * needed as long as the same routine can configure multiple
121 public void configureGlobalInstance(Component c, Object imp) {
122 if (imp.equals(ClusterManager.class)) {
123 // export the service for Apps and Plugins
124 c.setInterface(new String[] { IClusterServices.class.getName() }, null);
127 if (imp.equals(ClusterGlobalManager.class)) {
128 c.setInterface(new String[] { IClusterGlobalServices.class.getName() }, null);
130 c.add(createServiceDependency()
131 .setService(IClusterServices.class)
132 .setCallbacks("setClusterService", "unsetClusterService")
135 // CacheUpdate services will be none or many so the
136 // dependency is optional
137 c.add(createServiceDependency()
138 .setService(ICacheUpdateAware.class)
139 .setCallbacks("setCacheUpdateAware", "unsetCacheUpdateAware")
140 .setRequired(false));
142 // Coordinator change event can be one or many so
143 // dependency is optional
144 c.add(createServiceDependency()
145 .setService(ICoordinatorChangeAware.class)
146 .setCallbacks("setCoordinatorChangeAware", "unsetCoordinatorChangeAware")
147 .setRequired(false));