Move init and destroy empty impl from Activator classes. Have only one
[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 that is used to communicate to dependency manager the list of
26      * known Global implementations
27      *
28      *
29      * @return An array containing all the CLASS objects that will be
30      *         instantiated in order to get an fully working implementation
31      *         Object
32      */
33     public Object[] getGlobalImplementations() {
34         Object[] res = { ConnectionService.class};
35         return res;
36     }
37
38     /**
39      * Function that is called when configuration of the dependencies is required.
40      *
41      * @param c
42      *            dependency manager Component object, used for configuring the
43      *            dependencies exported and imported
44      * @param imp
45      *            Implementation class that is being configured, needed as long
46      *            as the same routine can configure multiple implementations
47      */
48     public void configureGlobalInstance(Component c, Object imp) {
49         if (imp.equals(ConnectionService.class)) {
50             c.setInterface(
51                     new String[] { IConnectionService.class.getName(),
52                                    IPluginOutConnectionService.class.getName() },
53                                    null);
54
55             c.add(createServiceDependency()
56                     .setService(IPluginInConnectionService.class)
57                     .setCallbacks("setPluginService", "unsetPluginService")
58                     .setRequired(false));
59             c.add(createServiceDependency()
60                     .setService(IConnectionListener.class)
61                     .setCallbacks("setListener", "unsetListener")
62                     .setRequired(false));
63         }
64     }
65 }