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
90 c.add(createServiceDependency().setService(IClusterServices.class)
91 .setCallbacks("setClusterService", "unsetClusterService")
94 // CacheUpdate services will be none or many so the
95 // dependency is optional
96 c.add(createContainerServiceDependency(containerName).setService(
97 ICacheUpdateAware.class).setCallbacks(
98 "setCacheUpdateAware", "unsetCacheUpdateAware")
101 // Coordinator change event can be one or many so
102 // dependency is optional
103 c.add(createContainerServiceDependency(containerName).setService(
104 ICoordinatorChangeAware.class).setCallbacks(
105 "setCoordinatorChangeAware", "unsetCoordinatorChangeAware")
106 .setRequired(false));
111 * Function that is called when configuration of the dependencies
114 * @param c dependency manager Component object, used for
115 * configuring the dependencies exported and imported
116 * @param imp Implementation class that is being configured,
117 * needed as long as the same routine can configure multiple
120 public void configureGlobalInstance(Component c, Object imp) {
121 if (imp.equals(ClusterManager.class)) {
122 // export the service for Apps and Plugins
123 c.setInterface(new String[] { IClusterServices.class.getName() },
127 if (imp.equals(ClusterGlobalManager.class)) {
128 c.setInterface(new String[] { IClusterGlobalServices.class
131 c.add(createServiceDependency().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().setService(ICacheUpdateAware.class)
138 .setCallbacks("setCacheUpdateAware",
139 "unsetCacheUpdateAware").setRequired(false));
141 // Coordinator change event can be one or many so
142 // dependency is optional
143 c.add(createServiceDependency().setService(
144 ICoordinatorChangeAware.class).setCallbacks(
145 "setCoordinatorChangeAware", "unsetCoordinatorChangeAware")
146 .setRequired(false));