Refactored yang-model-parser-impl to improve readability. SchemaContextImpl moved...
[controller.git] / opendaylight / arphandler / src / main / java / org / opendaylight / controller / arphandler / 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.arphandler.internal;
11
12 import java.util.Hashtable;
13 import java.util.Dictionary;
14 import org.apache.felix.dm.Component;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 import org.opendaylight.controller.hosttracker.IfHostListener;
19 import org.opendaylight.controller.hosttracker.IfIptoHost;
20 import org.opendaylight.controller.hosttracker.hostAware.IHostFinder;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.controller.sal.packet.IListenDataPacket;
23 import org.opendaylight.controller.sal.packet.IDataPacketService;
24 import org.opendaylight.controller.switchmanager.ISwitchManager;
25
26 public class Activator extends ComponentActivatorAbstractBase {
27     protected static final Logger logger = LoggerFactory
28             .getLogger(Activator.class);
29
30     /**
31      * Function called when the activator starts just after some
32      * initializations are done by the
33      * ComponentActivatorAbstractBase.
34      *
35      */
36     public void init() {
37
38     }
39
40     /**
41      * Function called when the activator stops just before the
42      * cleanup done by ComponentActivatorAbstractBase
43      *
44      */
45     public void destroy() {
46
47     }
48
49     /**
50      * Function that is used to communicate to dependency manager the
51      * list of known implementations for services inside a container
52      *
53      *
54      * @return An array containing all the CLASS objects that will be
55      * instantiated in order to get an fully working implementation
56      * Object
57      */
58     public Object[] getImplementations() {
59         Object[] res = { ArpHandler.class };
60         return res;
61     }
62
63     /**
64      * Function that is called when configuration of the dependencies
65      * is required.
66      *
67      * @param c dependency manager Component object, used for
68      * configuring the dependencies exported and imported
69      * @param imp Implementation class that is being configured,
70      * needed as long as the same routine can configure multiple
71      * implementations
72      * @param containerName The containerName being configured, this allow
73      * also optional per-container different behavior if needed, usually
74      * should not be the case though.
75      */
76     public void configureInstance(Component c, Object imp, String containerName) {
77         if (imp.equals(ArpHandler.class)) {
78             // export the service
79             Dictionary<String, String> props = new Hashtable<String, String>();
80             props.put("salListenerName", "arphandler");
81             c.setInterface(new String[] { IHostFinder.class.getName(),
82                     IListenDataPacket.class.getName() }, props);
83
84             c.add(createContainerServiceDependency(containerName).setService(
85                     ISwitchManager.class).setCallbacks("setSwitchManager",
86                     "unsetSwitchManager").setRequired(true));
87
88             c.add(createContainerServiceDependency(containerName).setService(
89                     IDataPacketService.class).setCallbacks(
90                     "setDataPacketService", "unsetDataPacketService")
91                     .setRequired(true));
92
93             // the Host Listener is optional
94             c.add(createContainerServiceDependency(containerName).setService(
95                     IfHostListener.class).setCallbacks("setHostListener",
96                     "unsetHostListener").setRequired(false));
97
98             // the IfIptoHost is a required dependency
99             c.add(createContainerServiceDependency(containerName).setService(
100                     IfIptoHost.class).setCallbacks("setHostTracker",
101                     "unsetHostTracker").setRequired(true));
102         }
103     }
104 }