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);
34 * Function that is used to communicate to dependency manager the
35 * list of known implementations for services inside a container
38 * @return An array containing all the CLASS objects that will be
39 * instantiated in order to get an fully working implementation
43 public Object[] getImplementations() {
44 return new Object[]{};
48 * Function that is called when configuration of the dependencies
51 * @param c dependency manager Component object, used for
52 * configuring the dependencies exported and imported
53 * @param imp Implementation class that is being configured,
54 * needed as long as the same routine can configure multiple
56 * @param containerName The containerName being configured, this allow
57 * also optional per-container different behavior if needed, usually
58 * should not be the case though.
61 public void configureInstance(Component c, Object imp, String containerName) {
65 * Method which tells how many global implementations are
66 * supported by the bundle. This way we can tune the number of
67 * components created. This components will be created ONLY at the
68 * time of bundle startup and will be destroyed only at time of
69 * bundle destruction, this is the major difference with the
70 * implementation retrieved via getImplementations where all of
71 * them are assumed to be in a container !
74 * @return The list of implementations the bundle will support,
78 protected Object[] getGlobalImplementations() {
79 Object[] res = { UserManager.class };
84 * Configure the dependency for a given instance Global
86 * @param c Component assigned for this instance, this will be
87 * what will be used for configuration
88 * @param imp implementation to be configured
89 * @param containerName container on which the configuration happens
92 protected void configureGlobalInstance(Component c, Object imp) {
93 if (imp.equals(UserManager.class)) {
96 c.setInterface(new String[] {
97 IUserManager.class.getName(),
98 IConfigurationAware.class.getName() }, null);
100 c.add(createServiceDependency().setService(
101 IClusterGlobalServices.class).setCallbacks(
102 "setClusterGlobalService", "unsetClusterGlobalService")
105 c.add(createServiceDependency().setService(IAAAProvider.class)
106 .setCallbacks("addAAAProvider", "removeAAAProvider")
107 .setRequired(false));
109 c.add(createServiceDependency().setService(
110 IContainerAuthorization.class).setCallbacks(
111 "setContainerAuthClient", "unsetContainerAuthClient")
112 .setRequired(false));
114 c.add(createServiceDependency().setService(
115 IResourceAuthorization.class).setCallbacks(
116 "setAppAuthClient", "unsetAppAuthClient")
117 .setRequired(false));