Fix null value put in FRM incativeFlows hash map
[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.ICacheUpdateAware;
32 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
33
34 public class Activator extends ComponentActivatorAbstractBase {
35     protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
36
37     /**
38      * Function called when the activator starts just after some initializations
39      * are done by the ComponentActivatorAbstractBase.
40      *
41      */
42     @Override
43     public void init() {
44
45     }
46
47     /**
48      * Function called when the activator stops just before the cleanup done by
49      * ComponentActivatorAbstractBase
50      *
51      */
52     @Override
53     public void destroy() {
54
55     }
56
57     /**
58      * Function that is used to communicate to dependency manager the list of
59      * known implementations for services inside a container
60      *
61      *
62      * @return An array containing all the CLASS objects that will be
63      *         instantiated in order to get an fully working implementation
64      *         Object
65      */
66     @Override
67     public Object[] getImplementations() {
68         Object[] res = { ForwardingRulesManager.class };
69         return res;
70     }
71
72     /**
73      * Function that is called when configuration of the dependencies is
74      * required.
75      *
76      * @param c
77      *            dependency manager Component object, used for configuring the
78      *            dependencies exported and imported
79      * @param imp
80      *            Implementation class that is being configured, needed as long
81      *            as the same routine can configure multiple implementations
82      * @param containerName
83      *            The containerName being configured, this allow also optional
84      *            per-container different behavior if needed, usually should not
85      *            be the case though.
86      */
87     @Override
88     public void configureInstance(Component c, Object imp, String containerName) {
89         if (imp.equals(ForwardingRulesManager.class)) {
90             String interfaces[] = null;
91             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
92             Set<String> propSet = new HashSet<String>();
93             propSet.add("frm.flowsSaveEvent");
94             props.put("cachenames", propSet);
95
96             // export the service
97             interfaces = new String[] { IContainerListener.class.getName(), ISwitchManagerAware.class.getName(),
98                     IForwardingRulesManager.class.getName(), IInventoryListener.class.getName(),
99                     ICacheUpdateAware.class.getName(), IConfigurationContainerAware.class.getName(),
100                     IFlowProgrammerListener.class.getName() };
101
102             c.setInterface(interfaces, props);
103
104             c.add(createContainerServiceDependency(containerName).setService(IFlowProgrammerService.class)
105                     .setCallbacks("setFlowProgrammerService", "unsetFlowProgrammerService").setRequired(true));
106             c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
107                     .setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
108             c.add(createContainerServiceDependency(containerName).setService(ISwitchManager.class)
109                     .setCallbacks("setSwitchManager", "unsetSwitchManager").setRequired(true));
110             c.add(createContainerServiceDependency(containerName).setService(IForwardingRulesManagerAware.class)
111                     .setCallbacks("setFrmAware", "unsetFrmAware").setRequired(false));
112             c.add(createContainerServiceDependency(containerName).setService(IContainer.class)
113                     .setCallbacks("setIContainer", "unsetIContainer").setRequired(true));
114         }
115     }
116 }