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 org.apache.felix.dm.Component;
13 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
14 import org.opendaylight.controller.configuration.IConfigurationAware;
15 import org.opendaylight.controller.containermanager.IContainerAuthorization;
16 import org.opendaylight.controller.sal.authorization.IResourceAuthorization;
17 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
18 import org.opendaylight.controller.usermanager.IAAAProvider;
19 import org.opendaylight.controller.usermanager.IUserManager;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * UserManager Bundle Activator
28 public class Activator extends ComponentActivatorAbstractBase {
29 protected static final Logger logger = LoggerFactory
30 .getLogger(Activator.class);
33 * Function called when the activator starts just after some
34 * initializations are done by the
35 * ComponentActivatorAbstractBase.
44 * Function called when the activator stops just before the
45 * cleanup done by ComponentActivatorAbstractBase
49 public void destroy() {
54 * Function that is used to communicate to dependency manager the
55 * list of known implementations for services inside a container
58 * @return An array containing all the CLASS objects that will be
59 * instantiated in order to get an fully working implementation
63 public Object[] getImplementations() {
68 * Function that is called when configuration of the dependencies
71 * @param c dependency manager Component object, used for
72 * configuring the dependencies exported and imported
73 * @param imp Implementation class that is being configured,
74 * needed as long as the same routine can configure multiple
76 * @param containerName The containerName being configured, this allow
77 * also optional per-container different behavior if needed, usually
78 * should not be the case though.
81 public void configureInstance(Component c, Object imp, String containerName) {
85 * Method which tells how many global implementations are
86 * supported by the bundle. This way we can tune the number of
87 * components created. This components will be created ONLY at the
88 * time of bundle startup and will be destroyed only at time of
89 * bundle destruction, this is the major difference with the
90 * implementation retrieved via getImplementations where all of
91 * them are assumed to be in a container !
94 * @return The list of implementations the bundle will support,
98 protected Object[] getGlobalImplementations() {
99 Object[] res = { UserManager.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
112 protected void configureGlobalInstance(Component c, Object imp) {
113 if (imp.equals(UserManager.class)) {
115 // export the service
116 c.setInterface(new String[] {
117 IUserManager.class.getName(),
118 IConfigurationAware.class.getName() }, null);
120 c.add(createServiceDependency().setService(
121 IClusterGlobalServices.class).setCallbacks(
122 "setClusterGlobalService", "unsetClusterGlobalService")
125 c.add(createServiceDependency().setService(IAAAProvider.class)
126 .setCallbacks("addAAAProvider", "removeAAAProvider")
127 .setRequired(false));
129 c.add(createServiceDependency().setService(
130 IContainerAuthorization.class).setCallbacks(
131 "setContainerAuthClient", "unsetContainerAuthClient")
132 .setRequired(false));
134 c.add(createServiceDependency().setService(
135 IResourceAuthorization.class).setCallbacks(
136 "setAppAuthClient", "unsetAppAuthClient")
137 .setRequired(false));