0e7e2a37a73f19aefda0919ea8304ac8b375d34f
[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 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;
22
23 /**
24  * UserManager Bundle Activator
25  *
26  *
27  */
28 public class Activator extends ComponentActivatorAbstractBase {
29     protected static final Logger logger = LoggerFactory
30             .getLogger(Activator.class);
31
32     /**
33      * Function called when the activator starts just after some
34      * initializations are done by the
35      * ComponentActivatorAbstractBase.
36      *
37      */
38     @Override
39     public void init() {
40
41     }
42
43     /**
44      * Function called when the activator stops just before the
45      * cleanup done by ComponentActivatorAbstractBase
46      *
47      */
48     @Override
49     public void destroy() {
50
51     }
52
53     /**
54      * Function that is used to communicate to dependency manager the
55      * list of known implementations for services inside a container
56      *
57      *
58      * @return An array containing all the CLASS objects that will be
59      * instantiated in order to get an fully working implementation
60      * Object
61      */
62     @Override
63     public Object[] getImplementations() {
64         return null;
65     }
66
67     /**
68      * Function that is called when configuration of the dependencies
69      * is required.
70      *
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
75      * implementations
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.
79      */
80     @Override
81     public void configureInstance(Component c, Object imp, String containerName) {
82     }
83
84     /**
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 !
92      *
93      *
94      * @return The list of implementations the bundle will support,
95      * in Global version
96      */
97     @Override
98     protected Object[] getGlobalImplementations() {
99         Object[] res = { UserManager.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     @Override
112     protected void configureGlobalInstance(Component c, Object imp) {
113         if (imp.equals(UserManager.class)) {
114
115             // export the service
116             c.setInterface(new String[] {
117                     IUserManager.class.getName(),
118                     IConfigurationAware.class.getName() }, null);
119
120             c.add(createServiceDependency().setService(
121                     IClusterGlobalServices.class).setCallbacks(
122                     "setClusterGlobalService", "unsetClusterGlobalService")
123                     .setRequired(true));
124
125             c.add(createServiceDependency().setService(IAAAProvider.class)
126                     .setCallbacks("addAAAProvider", "removeAAAProvider")
127                     .setRequired(false));
128
129             c.add(createServiceDependency().setService(
130                     IContainerAuthorization.class).setCallbacks(
131                     "setContainerAuthClient", "unsetContainerAuthClient")
132                     .setRequired(false));
133
134             c.add(createServiceDependency().setService(
135                     IResourceAuthorization.class).setCallbacks(
136                     "setAppAuthClient", "unsetAppAuthClient")
137                     .setRequired(false));
138         }
139     }
140 }