Expand implementation of Neutron Service APIs in Lisp
[lispflowmapping.git] / mappingservice / neutron / src / main / java / org / opendaylight / lispflowmapping / neutron / Activator.java
1 /*
2  * Copyright (c) 2014 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.lispflowmapping.neutron;
10
11
12 import java.util.Dictionary;
13 import java.util.Hashtable;
14
15 import org.apache.felix.dm.Component;
16 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
17 import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
18 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
19 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
20 import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * Main application activator class for registering the dependencies and
26  * Initializing the Mapping Service application.
27  *
28  */
29
30 public class Activator extends ComponentActivatorAbstractBase {
31
32     /*
33      * Logger instance
34      */
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         logger.debug("LISP Neutron Service is initialized!");
45
46     }
47
48     /**
49      * Function called when the activator stops just before the cleanup done by
50      * ComponentActivatorAbstractBase
51      *
52      */
53     @Override
54     public void destroy() {
55         logger.debug("LISP Neutron Service is destroyed!");
56     }
57
58     /**
59      * Function that is used to communicate to dependency manager the list of
60      * known implementations for services inside a container
61      *
62      *
63      * @return An array containing all the CLASS objects that will be
64      *         instantiated in order to get an fully working implementation
65      *         Object
66      */
67     @Override
68     public Object[] getImplementations() {
69         Object[] res = { LispNeutronService.class,
70                                          LispNeutronSubnetHandler.class,
71                                          LispNeutronPortHandler.class,
72                                          LispNeutronNetworkHandler.class};
73         return res;
74     }
75
76     /**
77      * Function that is called when configuration of the dependencies is
78      * required.
79      *
80      * @param c
81      *            dependency manager Component object, used for configuring the
82      *            dependencies exported and imported
83      * @param imp
84      *            Implementation class that is being configured, needed as long
85      *            as the same routine can configure multiple implementations
86      * @param containerName
87      *            The containerName being configured, this allow also optional
88      *            per-container different behavior if needed, usually should not
89      *            be the case though.
90      */
91     @Override
92     public void configureInstance(Component c, Object imp, String containerName) {
93         Dictionary<String, String> props = new Hashtable<String, String>();
94         props.put("name", "mappingservice");
95
96         if (imp.equals(LispNeutronService.class)) {
97             c.setInterface(ILispNeutronService.class.getName(), props);
98         }
99
100         if (imp.equals(LispNeutronNetworkHandler.class)) {
101             c.setInterface(new String[] { ILispNeutronService.class.getName(), INeutronNetworkAware.class.getName()}, props);
102         }
103
104         if (imp.equals(LispNeutronSubnetHandler.class)) {
105                 c.setInterface(new String[] { ILispNeutronService.class.getName(), INeutronSubnetAware.class.getName()}, props);
106         }
107
108         if (imp.equals(LispNeutronPortHandler.class)) {
109             c.setInterface(new String[] { ILispNeutronService.class.getName(), INeutronPortAware.class.getName()}, props);
110         }
111
112         c.add(createContainerServiceDependency(containerName)
113                         .setService(IFlowMapping.class)
114                         .setCallbacks("setMappingService", "unsetMappingService")
115                 .setRequired(true));
116
117
118     }
119
120 }