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