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