Small fix for 3037-5 build failure
[openflowplugin.git] / 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.openflowplugin.openflow.core.internal.Controller;
18 import org.opendaylight.openflowplugin.openflow.internal.Activator;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 /**
23  * Openflow protocol plugin Activator
24  *
25  *
26  */
27 public class EnhancedActivator extends Activator {
28     protected static final Logger logger = LoggerFactory
29             .getLogger(EnhancedActivator.class);
30
31     // Default Constructor for the activator
32     public EnhancedActivator() {
33         super();
34         logger.debug("Enhanced activator called!");
35     }
36
37     /**
38      * Function that is used to communicate to dependency manager the list of
39      * known implementations for services that are container independent.
40      *
41      *
42      * @return An array containing all the CLASS objects that will be
43      *         instantiated in order to get an fully working implementation
44      *         Object
45      */
46     @Override
47     public Object[] getGlobalImplementations() {
48         Object[] res = super.getGlobalImplementations();
49         // Now remove the Controller.class and return the
50         // EnhancedController
51         List resList = new ArrayList(Arrays.asList(res));
52         resList.remove(Controller.class);
53         resList.add(EnhancedController.class);
54         return resList.toArray();
55     }
56
57     /**
58      * Function that is called when configuration of the dependencies is
59      * 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     @Override
69     public void configureGlobalInstance(Component c, Object imp) {
70         if (imp.equals(EnhancedController.class)) {
71             // Configure it like if was the Controller.class
72             super.configureGlobalInstance(c, Controller.class);
73         } else {
74             super.configureGlobalInstance(c, imp);
75         }
76     }
77 }