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.IClusterGlobalServices;
19 import org.opendaylight.controller.configuration.IConfigurationAware;
20 import org.opendaylight.controller.containermanager.IContainerAuthorization;
21 import org.opendaylight.controller.sal.authorization.IResourceAuthorization;
22 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
23 import org.opendaylight.controller.usermanager.IAAAProvider;
24 import org.opendaylight.controller.usermanager.IUserManager;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
29 * UserManager Bundle Activator
33 public class Activator extends ComponentActivatorAbstractBase {
34 protected static final Logger logger = LoggerFactory
35 .getLogger(Activator.class);
38 * Function called when the activator starts just after some
39 * initializations are done by the
40 * ComponentActivatorAbstractBase.
48 * Function called when the activator stops just before the
49 * cleanup done by ComponentActivatorAbstractBase
52 public void destroy() {
57 * Function that is used to communicate to dependency manager the
58 * list of known implementations for services inside a container
61 * @return An array containing all the CLASS objects that will be
62 * instantiated in order to get an fully working implementation
65 public Object[] getImplementations() {
70 * Function that is called when configuration of the dependencies
73 * @param c dependency manager Component object, used for
74 * configuring the dependencies exported and imported
75 * @param imp Implementation class that is being configured,
76 * needed as long as the same routine can configure multiple
78 * @param containerName The containerName being configured, this allow
79 * also optional per-container different behavior if needed, usually
80 * should not be the case though.
82 public void configureInstance(Component c, Object imp, String containerName) {
86 * Method which tells how many global implementations are
87 * supported by the bundle. This way we can tune the number of
88 * components created. This components will be created ONLY at the
89 * time of bundle startup and will be destroyed only at time of
90 * bundle destruction, this is the major difference with the
91 * implementation retrieved via getImplementations where all of
92 * them are assumed to be in a container !
95 * @return The list of implementations the bundle will support,
98 protected Object[] getGlobalImplementations() {
99 Object[] res = { UserManagerImpl.class };
104 * Configure the dependency for a given instance Global
106 * @param c Component assigned for this instance, this will be
107 * what will be used for configuration
108 * @param imp implementation to be configured
109 * @param containerName container on which the configuration happens
111 protected void configureGlobalInstance(Component c, Object imp) {
112 if (imp.equals(UserManagerImpl.class)) {
114 // export the service
115 c.setInterface(new String[] {
116 IUserManager.class.getName(),
117 IConfigurationAware.class.getName() }, null);
119 c.add(createServiceDependency().setService(
120 IClusterGlobalServices.class).setCallbacks(
121 "setClusterGlobalService", "unsetClusterGlobalService")
124 c.add(createServiceDependency().setService(IAAAProvider.class)
125 .setCallbacks("addAAAProvider", "removeAAAProvider")
126 .setRequired(false));
128 c.add(createServiceDependency().setService(
129 IContainerAuthorization.class).setCallbacks(
130 "setContainerAuthClient", "unsetContainerAuthClient")
131 .setRequired(false));
133 c.add(createServiceDependency().setService(
134 IResourceAuthorization.class).setCallbacks(
135 "setAppAuthClient", "unsetAppAuthClient")
136 .setRequired(false));