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