d0d9bfaa5ea144256dceeaae179e9ebef43e6221
[controller.git] / opendaylight / topologymanager / src / main / java / org / opendaylight / controller / topologymanager / 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.topologymanager.internal;
11
12 import org.apache.felix.dm.Component;
13
14 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
15 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
16 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
17 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
18 import org.opendaylight.controller.sal.topology.ITopologyService;
19 import org.opendaylight.controller.topologymanager.ITopologyManager;
20 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 public class Activator extends ComponentActivatorAbstractBase {
25     protected static final Logger logger = LoggerFactory
26             .getLogger(Activator.class);
27
28     /**
29      * Function called when the activator starts just after some
30      * initializations are done by the
31      * ComponentActivatorAbstractBase.
32      *
33      */
34     public void init() {
35
36     }
37
38     /**
39      * Function called when the activator stops just before the
40      * cleanup done by ComponentActivatorAbstractBase
41      *
42      */
43     public void destroy() {
44
45     }
46
47     /**
48      * Function that is used to communicate to dependency manager the
49      * list of known implementations for services inside a container
50      *
51      *
52      * @return An array containing all the CLASS objects that will be
53      * instantiated in order to get an fully working implementation
54      * Object
55      */
56     public Object[] getImplementations() {
57         Object[] res = { TopologyManagerImpl.class };
58         return res;
59     }
60
61     /**
62      * Function that is called when configuration of the dependencies
63      * is required.
64      *
65      * @param c dependency manager Component object, used for
66      * configuring the dependencies exported and imported
67      * @param imp Implementation class that is being configured,
68      * needed as long as the same routine can configure multiple
69      * implementations
70      * @param containerName The containerName being configured, this allow
71      * also optional per-container different behavior if needed, usually
72      * should not be the case though.
73      */
74     public void configureInstance(Component c, Object imp, String containerName) {
75         if (imp.equals(TopologyManagerImpl.class)) {
76             // export the service needed to listen to topology updates
77             c.setInterface(new String[] { IListenTopoUpdates.class.getName(),
78                     ITopologyManager.class.getName(),
79                     IConfigurationContainerAware.class.getName() }, null);
80
81             c.add(createContainerServiceDependency(containerName).setService(
82                     ITopologyService.class).setCallbacks("setTopoService",
83                     "unsetTopoService").setRequired(true));
84
85             // These are all the listeners for a topology manager
86             // updates, there could be many or none
87             c.add(createContainerServiceDependency(containerName).setService(
88                     ITopologyManagerAware.class).setCallbacks(
89                     "setTopologyManagerAware", "unsetTopologyManagerAware")
90                     .setRequired(false));
91
92             c.add(createContainerServiceDependency(containerName).setService(
93                     IClusterContainerServices.class).setCallbacks(
94                     "setClusterContainerService",
95                     "unsetClusterContainerService").setRequired(true));
96         }
97     }
98 }