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.usermanager.internal;
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
17 import org.apache.felix.dm.Component;
18 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
19 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
20 import org.opendaylight.controller.configuration.IConfigurationAware;
21 import org.opendaylight.controller.containermanager.IContainerAuthorization;
22 import org.opendaylight.controller.sal.authorization.IResourceAuthorization;
23 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
24 import org.opendaylight.controller.usermanager.IAAAProvider;
25 import org.opendaylight.controller.usermanager.IUserManager;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * UserManager Bundle Activator
34 public class Activator extends ComponentActivatorAbstractBase {
35 protected static final Logger logger = LoggerFactory
36 .getLogger(Activator.class);
39 * Function called when the activator starts just after some
40 * initializations are done by the
41 * ComponentActivatorAbstractBase.
49 * Function called when the activator stops just before the
50 * cleanup done by ComponentActivatorAbstractBase
53 public void destroy() {
58 * Function that is used to communicate to dependency manager the
59 * list of known implementations for services inside a container
62 * @return An array containing all the CLASS objects that will be
63 * instantiated in order to get an fully working implementation
66 public Object[] getImplementations() {
71 * Function that is called when configuration of the dependencies
74 * @param c dependency manager Component object, used for
75 * configuring the dependencies exported and imported
76 * @param imp Implementation class that is being configured,
77 * needed as long as the same routine can configure multiple
79 * @param containerName The containerName being configured, this allow
80 * also optional per-container different behavior if needed, usually
81 * should not be the case though.
83 public void configureInstance(Component c, Object imp, String containerName) {
87 * Method which tells how many global implementations are
88 * supported by the bundle. This way we can tune the number of
89 * components created. This components will be created ONLY at the
90 * time of bundle startup and will be destroyed only at time of
91 * bundle destruction, this is the major difference with the
92 * implementation retrieved via getImplementations where all of
93 * them are assumed to be in a container !
96 * @return The list of implementations the bundle will support,
99 protected Object[] getGlobalImplementations() {
100 Object[] res = { UserManagerImpl.class };
105 * Configure the dependency for a given instance Global
107 * @param c Component assigned for this instance, this will be
108 * what will be used for configuration
109 * @param imp implementation to be configured
110 * @param containerName container on which the configuration happens
112 protected void configureGlobalInstance(Component c, Object imp) {
113 if (imp.equals(UserManagerImpl.class)) {
114 // export the service
115 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
116 Set<String> propSet = new HashSet<String>();
117 propSet.add("usermanager.localUserSaveConfigEvent");
118 propSet.add("usermanager.remoteServerSaveConfigEvent");
119 propSet.add("usermanager.authorizationSaveConfigEvent");
120 props.put("cachenames", propSet);
122 // export the service
123 c.setInterface(new String[] { ICacheUpdateAware.class.getName(),
124 IUserManager.class.getName(),
125 IConfigurationAware.class.getName() }, props);
127 c.add(createServiceDependency().setService(
128 IClusterGlobalServices.class).setCallbacks(
129 "setClusterGlobalService", "unsetClusterGlobalService")
132 c.add(createServiceDependency().setService(IAAAProvider.class)
133 .setCallbacks("addAAAProvider", "removeAAAProvider")
134 .setRequired(false));
136 c.add(createServiceDependency().setService(
137 IContainerAuthorization.class).setCallbacks(
138 "setContainerAuthClient", "unsetContainerAuthClient")
139 .setRequired(false));
141 c.add(createServiceDependency().setService(
142 IResourceAuthorization.class).setCallbacks(
143 "setAppAuthClient", "unsetAppAuthClient")
144 .setRequired(false));