Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / 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.configuration.IConfigurationService;
16 import org.opendaylight.controller.containermanager.IContainerAuthorization;
17 import org.opendaylight.controller.sal.authorization.IResourceAuthorization;
18 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
19 import org.opendaylight.controller.usermanager.IAAAProvider;
20 import org.opendaylight.controller.usermanager.IUserManager;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * UserManager Bundle Activator
26  *
27  *
28  */
29 public class Activator extends ComponentActivatorAbstractBase {
30     protected static final Logger logger = LoggerFactory
31             .getLogger(Activator.class);
32
33
34     /**
35      * Function that is used to communicate to dependency manager the
36      * list of known implementations for services inside a container
37      *
38      *
39      * @return An array containing all the CLASS objects that will be
40      * instantiated in order to get an fully working implementation
41      * Object
42      */
43     @Override
44     public Object[] getImplementations() {
45         return new Object[]{};
46     }
47
48     /**
49      * Function that is called when configuration of the dependencies
50      * is required.
51      *
52      * @param c dependency manager Component object, used for
53      * configuring the dependencies exported and imported
54      * @param imp Implementation class that is being configured,
55      * needed as long as the same routine can configure multiple
56      * implementations
57      * @param containerName The containerName being configured, this allow
58      * also optional per-container different behavior if needed, usually
59      * should not be the case though.
60      */
61     @Override
62     public void configureInstance(Component c, Object imp, String containerName) {
63     }
64
65     /**
66      * Method which tells how many global implementations are
67      * supported by the bundle. This way we can tune the number of
68      * components created. This components will be created ONLY at the
69      * time of bundle startup and will be destroyed only at time of
70      * bundle destruction, this is the major difference with the
71      * implementation retrieved via getImplementations where all of
72      * them are assumed to be in a container !
73      *
74      *
75      * @return The list of implementations the bundle will support,
76      * in Global version
77      */
78     @Override
79     protected Object[] getGlobalImplementations() {
80         Object[] res = { UserManager.class };
81         return res;
82     }
83
84     /**
85      * Configure the dependency for a given instance Global
86      *
87      * @param c Component assigned for this instance, this will be
88      * what will be used for configuration
89      * @param imp implementation to be configured
90      * @param containerName container on which the configuration happens
91      */
92     @Override
93     protected void configureGlobalInstance(Component c, Object imp) {
94         if (imp.equals(UserManager.class)) {
95
96             // export the service
97             c.setInterface(new String[] {
98                     IUserManager.class.getName(),
99                     IConfigurationAware.class.getName() }, null);
100
101             c.add(createServiceDependency().setService(
102                     IClusterGlobalServices.class).setCallbacks(
103                     "setClusterGlobalService", "unsetClusterGlobalService")
104                     .setRequired(true));
105
106             c.add(createServiceDependency().setService(
107                     IConfigurationService.class).setCallbacks(
108                     "setConfigurationService",
109                     "unsetConfigurationService").setRequired(true));
110
111             c.add(createServiceDependency().setService(IAAAProvider.class)
112                     .setCallbacks("addAAAProvider", "removeAAAProvider")
113                     .setRequired(false));
114
115             c.add(createServiceDependency().setService(
116                     IContainerAuthorization.class).setCallbacks(
117                     "setContainerAuthClient", "unsetContainerAuthClient")
118                     .setRequired(false));
119
120             c.add(createServiceDependency().setService(
121                     IResourceAuthorization.class).setCallbacks(
122                     "setAppAuthClient", "unsetAppAuthClient")
123                     .setRequired(false));
124         }
125     }
126 }