Migrating caches to TRANSACTIONAL Caches and enabled use1PcForAutoCommitTransactions.
[controller.git] / opendaylight / forwardingrulesmanager / implementation / src / main / java / org / opendaylight / controller / forwardingrulesmanager / internal / Activator.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.forwardingrulesmanager.internal;
10
11 import java.util.Dictionary;
12 import java.util.HashSet;
13 import java.util.Hashtable;
14 import java.util.Set;
15
16 import org.apache.felix.dm.Component;
17 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
18 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
19 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManagerAware;
20 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
21 import org.opendaylight.controller.sal.core.IContainer;
22 import org.opendaylight.controller.sal.core.IContainerListener;
23 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
24 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
25 import org.opendaylight.controller.switchmanager.IInventoryListener;
26 import org.opendaylight.controller.switchmanager.ISwitchManager;
27 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
32
33 public class Activator extends ComponentActivatorAbstractBase {
34     protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
35
36     /**
37      * Function called when the activator starts just after some initializations
38      * are done by the ComponentActivatorAbstractBase.
39      *
40      */
41     @Override
42     public void init() {
43
44     }
45
46     /**
47      * Function called when the activator stops just before the cleanup done by
48      * ComponentActivatorAbstractBase
49      *
50      */
51     @Override
52     public void destroy() {
53
54     }
55
56     /**
57      * Function that is used to communicate to dependency manager the list of
58      * 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 = { ForwardingRulesManager.class };
68         return res;
69     }
70
71     /**
72      * Function that is called when configuration of the dependencies is
73      * required.
74      *
75      * @param c
76      *            dependency manager Component object, used for configuring the
77      *            dependencies exported and imported
78      * @param imp
79      *            Implementation class that is being configured, needed as long
80      *            as the same routine can configure multiple implementations
81      * @param containerName
82      *            The containerName being configured, this allow also optional
83      *            per-container different behavior if needed, usually should not
84      *            be the case though.
85      */
86     @Override
87     public void configureInstance(Component c, Object imp, String containerName) {
88         if (imp.equals(ForwardingRulesManager.class)) {
89             String interfaces[] = null;
90
91             // export the service
92             interfaces = new String[] { IContainerListener.class.getName(), ISwitchManagerAware.class.getName(),
93                     IForwardingRulesManager.class.getName(), IInventoryListener.class.getName(),
94                     IConfigurationContainerAware.class.getName(),
95                     IFlowProgrammerListener.class.getName() };
96
97             c.setInterface(interfaces, null);
98
99             c.add(createContainerServiceDependency(containerName).setService(IFlowProgrammerService.class)
100                     .setCallbacks("setFlowProgrammerService", "unsetFlowProgrammerService").setRequired(true));
101             c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
102                     .setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
103             c.add(createContainerServiceDependency(containerName).setService(ISwitchManager.class)
104                     .setCallbacks("setSwitchManager", "unsetSwitchManager").setRequired(true));
105             c.add(createContainerServiceDependency(containerName).setService(IForwardingRulesManagerAware.class)
106                     .setCallbacks("setFrmAware", "unsetFrmAware").setRequired(false));
107             c.add(createContainerServiceDependency(containerName).setService(IContainer.class)
108                     .setCallbacks("setIContainer", "unsetIContainer").setRequired(true));
109         }
110     }
111 }