Merge "Migrating caches to TRANSACTIONAL Caches and enabled use1PcForAutoCommitTransa...
[controller.git] / opendaylight / usermanager / implementation / src / main / java / org / opendaylight / controller / usermanager / internal / Activator.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.usermanager.internal;
11
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
15 import java.util.Set;
16
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;
27
28 /**
29  * UserManager Bundle Activator
30  *
31  *
32  */
33 public class Activator extends ComponentActivatorAbstractBase {
34     protected static final Logger logger = LoggerFactory
35             .getLogger(Activator.class);
36
37     /**
38      * Function called when the activator starts just after some
39      * initializations are done by the
40      * ComponentActivatorAbstractBase.
41      *
42      */
43     public void init() {
44
45     }
46
47     /**
48      * Function called when the activator stops just before the
49      * cleanup done by ComponentActivatorAbstractBase
50      *
51      */
52     public void destroy() {
53
54     }
55
56     /**
57      * Function that is used to communicate to dependency manager the
58      * list of known implementations for services inside a container
59      *
60      *
61      * @return An array containing all the CLASS objects that will be
62      * instantiated in order to get an fully working implementation
63      * Object
64      */
65     public Object[] getImplementations() {
66         return null;
67     }
68
69     /**
70      * Function that is called when configuration of the dependencies
71      * is required.
72      *
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
77      * implementations
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.
81      */
82     public void configureInstance(Component c, Object imp, String containerName) {
83     }
84
85     /**
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 !
93      *
94      *
95      * @return The list of implementations the bundle will support,
96      * in Global version
97      */
98     protected Object[] getGlobalImplementations() {
99         Object[] res = { UserManagerImpl.class };
100         return res;
101     }
102
103     /**
104      * Configure the dependency for a given instance Global
105      *
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
110      */
111     protected void configureGlobalInstance(Component c, Object imp) {
112         if (imp.equals(UserManagerImpl.class)) {
113
114             // export the service
115             c.setInterface(new String[] {
116                     IUserManager.class.getName(),
117                     IConfigurationAware.class.getName() }, null);
118
119             c.add(createServiceDependency().setService(
120                     IClusterGlobalServices.class).setCallbacks(
121                     "setClusterGlobalService", "unsetClusterGlobalService")
122                     .setRequired(true));
123
124             c.add(createServiceDependency().setService(IAAAProvider.class)
125                     .setCallbacks("addAAAProvider", "removeAAAProvider")
126                     .setRequired(false));
127
128             c.add(createServiceDependency().setService(
129                     IContainerAuthorization.class).setCallbacks(
130                     "setContainerAuthClient", "unsetContainerAuthClient")
131                     .setRequired(false));
132
133             c.add(createServiceDependency().setService(
134                     IResourceAuthorization.class).setCallbacks(
135                     "setAppAuthClient", "unsetAppAuthClient")
136                     .setRequired(false));
137         }
138     }
139 }