2cf1c1d6fe6763e497ab30d2cb574432c9c11d0f
[controller.git] / opendaylight / hosttracker_new / implementation / src / main / java / org / opendaylight / controller / hosttracker / 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.hosttracker.internal;
10
11 import java.util.Dictionary;
12 import java.util.Hashtable;
13
14 import org.apache.felix.dm.Component;
15 import org.opendaylight.controller.hosttracker.IDeviceService;
16 import org.opendaylight.controller.hosttracker.IfIptoHost;
17 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
18 import org.opendaylight.controller.sal.packet.IDataPacketService;
19 import org.opendaylight.controller.sal.packet.IListenDataPacket;
20 import org.opendaylight.controller.switchmanager.ISwitchManager;
21 import org.opendaylight.controller.topologymanager.ITopologyManager;
22 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 public class Activator extends ComponentActivatorAbstractBase {
27     protected static final Logger logger = LoggerFactory
28             .getLogger(Activator.class);
29
30     @Override
31     protected void init() {
32
33     }
34
35     @Override
36     protected void destroy() {
37
38     }
39
40     /**
41      * Function that is used to communicate to dependency manager the list of
42      * known implementations for services inside a container
43      *
44      *
45      * @return An array containing all the CLASS objects that will be
46      *         instantiated in order to get an fully working implementation
47      *         Object
48      */
49     @Override
50     public Object[] getImplementations() {
51         Object[] res = { DeviceManagerImpl.class };
52         return res;
53     }
54
55     /**
56      * Function that is called when configuration of the dependencies is
57      * required.
58      *
59      * @param c
60      *            dependency manager Component object, used for configuring the
61      *            dependencies exported and imported
62      * @param imp
63      *            Implementation class that is being configured, needed as long
64      *            as the same routine can configure multiple implementations
65      * @param containerName
66      *            The containerName being configured, this allow also optional
67      *            per-container different behavior if needed, usually should not
68      *            be the case though.
69      */
70     @Override
71     public void configureInstance(Component c, Object imp, String containerName) {
72         if (imp.equals(DeviceManagerImpl.class)) {
73             // export the service
74             // XXX - TODO merge with existing APIs
75             Dictionary<String, String> props = new Hashtable<String, String>();
76             props.put("salListenerName", "devicemanager");
77
78             c.setInterface(
79                     new String[] { IDeviceService.class.getName(),
80                             IfIptoHost.class.getName(),
81                             IListenDataPacket.class.getName(),
82                             ITopologyManagerAware.class.getName() }, props);
83
84             c.add(createContainerServiceDependency(containerName)
85                     .setService(ISwitchManager.class)
86                     .setCallbacks("setSwitchManager", "unsetSwitchManager")
87                     .setRequired(false));
88
89             c.add(createContainerServiceDependency(containerName)
90                     .setService(IDataPacketService.class)
91                     .setCallbacks("setDataPacketService",
92                             "unsetDataPacketService").setRequired(true));
93
94             // c.add(createContainerServiceDependency(containerName).setService(
95             // IClusterContainerServices.class).setCallbacks(
96             // "setClusterContainerService",
97             // "unsetClusterContainerService").setRequired(true));
98             c.add(createContainerServiceDependency(containerName)
99                     .setService(ITopologyManager.class)
100                     .setCallbacks("setTopologyManager", "unsetTopologyManager")
101                     .setRequired(false));
102
103             c.add(createContainerServiceDependency(containerName)
104                     .setService(IDataPacketService.class)
105                     .setCallbacks("setDataPacketService",
106                             "unsetDataPacketService").setRequired(true));
107         }
108     }
109
110     /**
111      * Method which tells how many Global implementations are supported by the
112      * bundle. This way we can tune the number of components created. This
113      * components will be created ONLY at the time of bundle startup and will be
114      * destroyed only at time of bundle destruction, this is the major
115      * difference with the implementation retrieved via getImplementations where
116      * all of them are assumed to be in a container !
117      *
118      *
119      * @return The list of implementations the bundle will support, in Global
120      *         version
121      */
122     @Override
123     protected Object[] getGlobalImplementations() {
124         return null;
125     }
126
127     /**
128      * Configure the dependency for a given instance Global
129      *
130      * @param c
131      *            Component assigned for this instance, this will be what will
132      *            be used for configuration
133      * @param imp
134      *            implementation to be configured
135      * @param containerName
136      *            container on which the configuration happens
137      */
138     @Override
139     protected void configureGlobalInstance(Component c, Object imp) {
140
141     }
142
143 }