Refactor frontend JS
[controller.git] / opendaylight / forwardingrulesmanager / src / main / java / org / opendaylight / controller / forwardingrulesmanager / 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.forwardingrulesmanager.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.configuration.IConfigurationContainerAware;
19 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
20 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManagerAware;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.controller.sal.core.IContainer;
23 import org.opendaylight.controller.sal.core.IContainerListener;
24 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
25 import org.opendaylight.controller.sal.utils.GlobalConstants;
26 import org.opendaylight.controller.switchmanager.IInventoryListener;
27 import org.opendaylight.controller.switchmanager.ISwitchManager;
28 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
33 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
34 import org.opendaylight.controller.hosttracker.IfIptoHost;
35
36 public class Activator extends ComponentActivatorAbstractBase {
37     protected static final Logger logger = LoggerFactory
38             .getLogger(Activator.class);
39
40     /**
41      * Function called when the activator starts just after some
42      * initializations are done by the
43      * ComponentActivatorAbstractBase.
44      *
45      */
46     public void init() {
47
48     }
49
50     /**
51      * Function called when the activator stops just before the
52      * cleanup done by ComponentActivatorAbstractBase
53      *
54      */
55     public void destroy() {
56
57     }
58
59     /**
60      * Function that is used to communicate to dependency manager the
61      * list of known implementations for services inside a container
62      *
63      *
64      * @return An array containing all the CLASS objects that will be
65      * instantiated in order to get an fully working implementation
66      * Object
67      */
68     public Object[] getImplementations() {
69         Object[] res = { ForwardingRulesManagerImpl.class };
70         return res;
71     }
72
73     /**
74      * Function that is called when configuration of the dependencies
75      * is required.
76      *
77      * @param c dependency manager Component object, used for
78      * configuring the dependencies exported and imported
79      * @param imp Implementation class that is being configured,
80      * needed as long as the same routine can configure multiple
81      * implementations
82      * @param containerName The containerName being configured, this allow
83      * also optional per-container different behavior if needed, usually
84      * should not be the case though.
85      */
86     public void configureInstance(Component c, Object imp, String containerName) {
87         if (imp.equals(ForwardingRulesManagerImpl.class)) {
88             String interfaces[] = null;
89             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
90             Set<String> propSet = new HashSet<String>();
91             propSet.add("staticFlows");
92             props.put("cachenames", propSet);
93
94             // export the service
95             if (containerName.equals(GlobalConstants.DEFAULT.toString())) {
96                 interfaces = new String[] { IContainerListener.class.getName(),
97                         ISwitchManagerAware.class.getName(),
98                         IForwardingRulesManager.class.getName(),
99                         IInventoryListener.class.getName(),
100                         ICacheUpdateAware.class.getName(),
101                         IConfigurationContainerAware.class.getName() };
102             } else {
103                 interfaces = new String[] {
104                         ISwitchManagerAware.class.getName(),
105                         IForwardingRulesManager.class.getName(),
106                         IInventoryListener.class.getName(),
107                         ICacheUpdateAware.class.getName(),
108                         IConfigurationContainerAware.class.getName() };
109             }
110
111             c.setInterface(interfaces, props);
112
113             c.add(createContainerServiceDependency(containerName).setService(
114                     IFlowProgrammerService.class).setCallbacks(
115                     "setFlowProgrammerService", "unsetFlowProgrammerService")
116                     .setRequired(true));
117
118             c.add(createContainerServiceDependency(containerName).setService(
119                     IClusterContainerServices.class).setCallbacks(
120                     "setClusterContainerService",
121                     "unsetClusterContainerService").setRequired(true));
122             c.add(createContainerServiceDependency(containerName).setService(
123                     ISwitchManager.class).setCallbacks("setSwitchManager",
124                     "unsetSwitchManager").setRequired(true));
125             c.add(createContainerServiceDependency(containerName).setService(
126                     IForwardingRulesManagerAware.class).setCallbacks(
127                     "setFrmAware", "unsetFrmAware").setRequired(false));
128             c.add(createContainerServiceDependency(containerName).setService(
129                     IfIptoHost.class).setCallbacks("setHostFinder",
130                     "unsetHostFinder").setRequired(true));
131             c.add(createContainerServiceDependency(containerName).setService(
132                     IContainer.class).setCallbacks("setIContainer",
133                     "unsetIContainer").setRequired(true));
134         }
135     }
136 }