protocol.openflow_netty cleanup
[controller.git] / opendaylight / protocol_plugins / openflow_netty / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / internal / EnhancedActivator.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.protocol_plugin.openflow.internal;
10
11 import java.util.Arrays;
12 import java.util.List;
13 import java.util.ArrayList;
14
15 import org.apache.felix.dm.Component;
16 import org.opendaylight.controller.protocol_plugin.openflow.core.internal.EnhancedController;
17 import org.opendaylight.controller.protocol_plugin.openflow.core.internal.Controller;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * Openflow protocol plugin Activator
23  *
24  *
25  */
26 public class EnhancedActivator extends Activator {
27     protected static final Logger logger = LoggerFactory
28             .getLogger(EnhancedActivator.class);
29
30     // Default Constructor for the activator
31     public EnhancedActivator() {
32         super();
33         logger.debug("Enhanced activator called!");
34     }
35
36     /**
37      * Function that is used to communicate to dependency manager the list of
38      * known implementations for services that are container independent.
39      *
40      *
41      * @return An array containing all the CLASS objects that will be
42      *         instantiated in order to get an fully working implementation
43      *         Object
44      */
45     @Override
46     public Object[] getGlobalImplementations() {
47         Object[] res = super.getGlobalImplementations();
48         // Now remove the Controller.class and return the
49         // EnhancedController
50         List resList = new ArrayList(Arrays.asList(res));
51         resList.remove(Controller.class);
52         resList.add(EnhancedController.class);
53         return resList.toArray();
54     }
55
56     /**
57      * Function that is called when configuration of the dependencies is
58      * required.
59      *
60      * @param c
61      *            dependency manager Component object, used for configuring the
62      *            dependencies exported and imported
63      * @param imp
64      *            Implementation class that is being configured, needed as long
65      *            as the same routine can configure multiple implementations
66      */
67     @Override
68     public void configureGlobalInstance(Component c, Object imp) {
69         if (imp.equals(EnhancedController.class)) {
70             // Configure it like if was the Controller.class
71             super.configureGlobalInstance(c, Controller.class);
72         } else {
73             super.configureGlobalInstance(c, imp);
74         }
75     }
76 }