68cd10d3595e25750d0f61f714627e7e3d378635
[controller.git] / opendaylight / sal / connection / implementation / src / main / java / org / opendaylight / controller / sal / connection / implementation / 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.sal.connection.implementation.internal;
10
11 import org.apache.felix.dm.Component;
12 import org.opendaylight.controller.sal.connection.IConnectionListener;
13 import org.opendaylight.controller.sal.connection.IConnectionService;
14 import org.opendaylight.controller.sal.connection.IPluginInConnectionService;
15 import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
16 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 public class Activator extends ComponentActivatorAbstractBase {
21     protected static final Logger logger = LoggerFactory
22             .getLogger(Activator.class);
23
24     /**
25      * Function called when the activator starts just after some initializations
26      * are done by the ComponentActivatorAbstractBase.
27      *
28      */
29     @Override
30     public void init() {
31
32     }
33
34     /**
35      * Function called when the activator stops just before the cleanup done by
36      * ComponentActivatorAbstractBase
37      *
38      */
39     @Override
40     public void destroy() {
41
42     }
43
44     /**
45      * Function that is used to communicate to dependency manager the list of
46      * known Global implementations
47      *
48      *
49      * @return An array containing all the CLASS objects that will be
50      *         instantiated in order to get an fully working implementation
51      *         Object
52      */
53     public Object[] getGlobalImplementations() {
54         Object[] res = { ConnectionService.class};
55         return res;
56     }
57
58     /**
59      * Function that is called when configuration of the dependencies is required.
60      *
61      * @param c
62      *            dependency manager Component object, used for configuring the
63      *            dependencies exported and imported
64      * @param imp
65      *            Implementation class that is being configured, needed as long
66      *            as the same routine can configure multiple implementations
67      */
68     public void configureGlobalInstance(Component c, Object imp) {
69         if (imp.equals(ConnectionService.class)) {
70             c.setInterface(
71                     new String[] { IConnectionService.class.getName(),
72                                    IPluginOutConnectionService.class.getName() },
73                                    null);
74
75             c.add(createServiceDependency()
76                     .setService(IPluginInConnectionService.class)
77                     .setCallbacks("setPluginService", "unsetPluginService")
78                     .setRequired(false));
79             c.add(createServiceDependency()
80                     .setService(IConnectionListener.class)
81                     .setCallbacks("setListener", "unsetListener")
82                     .setRequired(false));
83         }
84     }
85 }