Merge "Supply from filesystem infinispan configuration"
[controller.git] / opendaylight / switchmanager / implementation / src / main / java / org / opendaylight / controller / switchmanager / 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.switchmanager.internal;
11
12 import org.apache.felix.dm.Component;
13 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
14 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
15 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
16 import org.opendaylight.controller.sal.inventory.IInventoryService;
17 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
18 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
19 import org.opendaylight.controller.switchmanager.IInventoryListener;
20 import org.opendaylight.controller.switchmanager.ISpanAware;
21 import org.opendaylight.controller.switchmanager.ISwitchManager;
22 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 /**
27  * SwitchManager Bundle Activator
28  *
29  *
30  */
31 public class Activator extends ComponentActivatorAbstractBase {
32     protected static final Logger logger = LoggerFactory
33             .getLogger(Activator.class);
34
35     /**
36      * Function called when the activator starts just after some
37      * initializations are done by the
38      * ComponentActivatorAbstractBase.
39      *
40      */
41     @Override
42     public void init() {
43
44     }
45
46     /**
47      * Function called when the activator stops just before the
48      * cleanup done by ComponentActivatorAbstractBase
49      *
50      */
51     @Override
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     @Override
66     public Object[] getImplementations() {
67         Object[] res = { SwitchManager.class };
68         return res;
69     }
70
71     /**
72      * Function that is called when configuration of the dependencies
73      * is required.
74      *
75      * @param c dependency manager Component object, used for
76      * configuring the dependencies exported and imported
77      * @param imp Implementation class that is being configured,
78      * needed as long as the same routine can configure multiple
79      * implementations
80      * @param containerName The containerName being configured, this allow
81      * also optional per-container different behavior if needed, usually
82      * should not be the case though.
83      */
84     @Override
85     public void configureInstance(Component c, Object imp, String containerName) {
86         if (imp.equals(SwitchManager.class)) {
87             // export the service
88             c.setInterface(new String[] {
89                     IListenInventoryUpdates.class.getName(),
90                     ISwitchManager.class.getName(),
91                     IConfigurationContainerAware.class.getName() }, null);
92
93             // Now lets add a service dependency to make sure the
94             // provider of service exists
95             c.add(createContainerServiceDependency(containerName).setService(
96                     IInventoryService.class).setCallbacks(
97                     "setInventoryService", "unsetInventoryService")
98                     .setRequired(false));
99             c.add(createContainerServiceDependency(containerName).setService(
100                     IStatisticsManager.class).setCallbacks(
101                     "setStatisticsManager", "unsetStatisticsManager")
102                     .setRequired(false));
103             c.add(createContainerServiceDependency(containerName).setService(
104                     ISwitchManagerAware.class).setCallbacks(
105                     "setSwitchManagerAware", "unsetSwitchManagerAware")
106                     .setRequired(false));
107             c.add(createContainerServiceDependency(containerName).setService(
108                     IInventoryListener.class).setCallbacks(
109                     "setInventoryListener", "unsetInventoryListener")
110                     .setRequired(false));
111             c.add(createContainerServiceDependency(containerName).setService(
112                     ISpanAware.class).setCallbacks("setSpanAware",
113                     "unsetSpanAware").setRequired(false));
114             c.add(createContainerServiceDependency(containerName).setService(
115                     IClusterContainerServices.class).setCallbacks(
116                     "setClusterContainerService",
117                     "unsetClusterContainerService").setRequired(true));
118         }
119     }
120
121     @Override
122     protected Object[] getGlobalImplementations() {
123         final Object[] res = { SwitchManagerCLI.class };
124         return res;
125     }
126 }