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);
30 * Function that is used to communicate to dependency manager the
31 * list of known implementations for services inside a container
34 * @return An array containing all the CLASS objects that will be
35 * instantiated in order to get an fully working implementation
39 public Object[] getGlobalImplementations() {
40 Object[] res = { ClusterManager.class, ClusterGlobalManager.class, ClusterManagerCLI.class };
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
54 public Object[] getImplementations() {
55 Object[] res = { ClusterContainerManager.class };
60 * Function that is called when configuration of the dependencies
63 * @param c dependency manager Component object, used for
64 * configuring the dependencies exported and imported
65 * @param imp Implementation class that is being configured,
66 * needed as long as the same routine can configure multiple
68 * @param containerName The containerName being configured, this allow
69 * also optional per-container different behavior if needed, usually
70 * should not be the case though.
73 public void configureInstance(Component c, Object imp, String containerName) {
74 if (imp.equals(ClusterContainerManager.class)) {
75 c.setInterface(new String[] { IClusterContainerServices.class.getName() },
78 c.add(createServiceDependency()
79 .setService(IClusterServices.class)
80 .setCallbacks("setClusterService", "unsetClusterService")
83 // CacheUpdate services will be none or many so the
84 // dependency is optional
85 c.add(createContainerServiceDependency(containerName)
86 .setService(ICacheUpdateAware.class)
87 .setCallbacks("setCacheUpdateAware", "unsetCacheUpdateAware")
90 // Coordinator change event can be one or many so
91 // dependency is optional
92 c.add(createContainerServiceDependency(containerName)
93 .setService(ICoordinatorChangeAware.class)
94 .setCallbacks("setCoordinatorChangeAware", "unsetCoordinatorChangeAware")
100 * Function that is called when configuration of the dependencies
103 * @param c dependency manager Component object, used for
104 * configuring the dependencies exported and imported
105 * @param imp Implementation class that is being configured,
106 * needed as long as the same routine can configure multiple
110 public void configureGlobalInstance(Component c, Object imp) {
111 if (imp.equals(ClusterManager.class)) {
112 // export the service for Apps and Plugins
113 c.setInterface(new String[] { IClusterServices.class.getName() }, null);
116 if (imp.equals(ClusterGlobalManager.class)) {
117 c.setInterface(new String[] { IClusterGlobalServices.class.getName() }, null);
119 c.add(createServiceDependency()
120 .setService(IClusterServices.class)
121 .setCallbacks("setClusterService", "unsetClusterService")
124 // CacheUpdate services will be none or many so the
125 // dependency is optional
126 c.add(createServiceDependency()
127 .setService(ICacheUpdateAware.class)
128 .setCallbacks("setCacheUpdateAware", "unsetCacheUpdateAware")
129 .setRequired(false));
131 // Coordinator change event can be one or many so
132 // dependency is optional
133 c.add(createServiceDependency()
134 .setService(ICoordinatorChangeAware.class)
135 .setCallbacks("setCoordinatorChangeAware", "unsetCoordinatorChangeAware")
136 .setRequired(false));