Remove ComponentActivatorAbstractBase from plugin 34/15034/3
authorSam Hague <shague@redhat.com>
Sun, 8 Feb 2015 04:28:48 +0000 (23:28 -0500)
committerSam Hague <shague@redhat.com>
Mon, 9 Feb 2015 01:13:25 +0000 (20:13 -0500)
Patch Set 3: remove some unused imports.

Change-Id: Ib656201f3a2d5598b96e13774620e283c6547114
Signed-off-by: Sam Hague <shague@redhat.com>
plugin/pom.xml
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/ConfigurationServiceImpl.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/internal/Activator.java

index 0ccdf2f91d498507529ac6bbaefb4816a881873b..86b15e713956704b2ae64102c0c54d16c1aeeb94 100755 (executable)
         <extensions>true</extensions>
         <configuration>
           <instructions>
-            <Import-Package>
-              org.opendaylight.controller.sal.packet,
-              org.opendaylight.controller.sal.action,
-              org.opendaylight.controller.sal.discovery,
-              org.opendaylight.controller.sal.topology,
-              org.opendaylight.controller.sal.core,
-              org.opendaylight.controller.sal.flowprogrammer,
-              org.opendaylight.controller.sal.reader,
-              org.opendaylight.controller.sal.inventory,
-              org.opendaylight.controller.sal.match,
-              org.opendaylight.controller.sal.utils,
-              org.opendaylight.ovsdb.lib.error,
-              org.opendaylight.ovsdb.lib.notation,
-              org.opendaylight.ovsdb.lib.operations,
-              org.opendaylight.ovsdb.lib.message,
-              org.opendaylight.ovsdb.schema.openvswitch,
-              org.apache.commons.lang3.builder,
-              org.apache.commons.lang3.tuple,
-              org.apache.felix.dm,
-              org.slf4j,
-              org.eclipse.osgi.framework.console,
-              org.osgi.framework,
-              javax.net.ssl,
-              *
-            </Import-Package>
             <Embed-Dependency>commons-codec,javax.servlet-api,portlet-api,commons-collections,utils.config;type=!pom;inline=false</Embed-Dependency>
             <Embed-Transitive>true</Embed-Transitive>
             <Bundle-Activator>org.opendaylight.ovsdb.plugin.internal.Activator</Bundle-Activator>
index 8562eb5fbf94b11cd2430f4121b65ebf82bd076b..d284eb6854d399df51378095d17966b21ca17ae0 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 
-import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
@@ -57,8 +56,6 @@ import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
 import org.opendaylight.ovsdb.schema.openvswitch.Port;
 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
 
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -94,14 +91,6 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
      *
      */
     void start() {
-        registerWithOSGIConsole();
-    }
-
-    private void registerWithOSGIConsole() {
-        BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass())
-                .getBundleContext();
-        bundleContext.registerService(CommandProvider.class.getName(), this,
-                null);
     }
 
     /**
index ab85910ae2fd07c25f2d74851b81244f585a3800..c0ac4ca5363c29f1acf269cba4e86884eba1fd78 100644 (file)
@@ -12,8 +12,8 @@ package org.opendaylight.ovsdb.plugin.internal;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
@@ -33,6 +33,7 @@ import org.opendaylight.ovsdb.plugin.impl.InventoryServiceImpl;
 import org.opendaylight.ovsdb.plugin.impl.NodeConnectorFactory;
 import org.opendaylight.ovsdb.plugin.impl.NodeFactory;
 
+import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,111 +42,83 @@ import org.slf4j.LoggerFactory;
  *
  *
  */
-public class Activator extends ComponentActivatorAbstractBase {
+public class Activator extends DependencyActivatorBase {
     protected static final Logger logger = LoggerFactory
             .getLogger(Activator.class);
 
-    /**
-     * Function called when the activator starts just after some initializations
-     * are done by the ComponentActivatorAbstractBase.
-     * Here it registers the node Type
-     *
-     */
     @Override
-    public void init() {
+    public void init(BundleContext context, DependencyManager manager) throws Exception {
         Node.NodeIDType.registerIDType("OVS", String.class);
         NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
-    }
-
-    /**
-     * Function called when the activator stops just before the cleanup done by
-     * ComponentActivatorAbstractBase
-     *
-     */
-    @Override
-    public void destroy() {
-        Node.NodeIDType.unRegisterIDType("OVS");
-        NodeConnector.NodeConnectorIDType.unRegisterIDType("OVS");
-    }
-    @Override
-    public Object[] getGlobalImplementations() {
-        Object[] res = { ConnectionServiceImpl.class, ConfigurationServiceImpl.class, NodeFactory.class, NodeConnectorFactory.class, InventoryServiceImpl.class };
-        return res;
-    }
 
-    @Override
-    public void configureGlobalInstance(Component c, Object imp){
-        if (imp.equals(ConfigurationServiceImpl.class)) {
-            // export the service to be used by SAL
-            Dictionary<String, Object> props = new Hashtable<String, Object>();
-            // Set the protocolPluginType property which will be used
-            // by SAL
-            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-            c.setInterface(new String[] { OvsdbConfigurationService.class.getName()}, props);
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
 
-            c.add(createServiceDependency()
-                    .setService(OvsdbConnectionService.class)
-                    .setRequired(true));
-            c.add(createServiceDependency()
-                    .setService(OvsdbInventoryService.class)
-                    .setRequired(true));
-        }
+        manager.add(createComponent()
+                        .setInterface(OvsdbConfigurationService.class.getName(), props)
+                        .setImplementation(ConfigurationServiceImpl.class)
+                        .add(createServiceDependency()
+                                        .setService(OvsdbConnectionService.class)
+                                        .setRequired(true))
+                        .add(createServiceDependency()
+                                .setService(OvsdbInventoryService.class)
+                                .setRequired(true)));
 
-        if (imp.equals(ConnectionServiceImpl.class)) {
-            // export the service to be used by SAL
-            Dictionary<String, Object> props = new Hashtable<String, Object>();
-            // Set the protocolPluginType property which will be used
-            // by SAL
-            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-            c.setInterface(
-                    new String[] {OvsdbConnectionService.class.getName(),
-                                  OvsdbConnectionListener.class.getName()}, props);
-            c.add(createServiceDependency()
-                    .setService(OvsdbInventoryService.class)
-                    .setRequired(true));
-            c.add(createServiceDependency()
-                    .setService(OvsdbConnection.class)
-                    .setRequired(true));
-        }
+        Dictionary<String, Object> props2 = new Hashtable<String, Object>();
+        props2.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
+        manager.add(createComponent()
+                        .setInterface(
+                                new String[] {OvsdbConnectionService.class.getName(),
+                                        OvsdbConnectionListener.class.getName()}, props2)
+                        .setImplementation(ConnectionServiceImpl.class)
+                        .add(createServiceDependency()
+                                .setService(OvsdbInventoryService.class)
+                                .setRequired(true))
+                        .add(createServiceDependency()
+                                .setService(OvsdbConnection.class)
+                                .setRequired(true))
+        );
 
-        if (imp.equals(InventoryServiceImpl.class)) {
-            Dictionary<String, Object> props = new Hashtable<>();
-            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-            props.put("scope", "Global");
-            c.setInterface(
-                    new String[]{IPluginInInventoryService.class.getName(),
-                                 OvsdbInventoryService.class.getName()}, props);
-            c.add(createServiceDependency()
-                          .setService(IPluginOutInventoryService.class, "(scope=Global)")
-                          .setCallbacks("setPluginOutInventoryServices",
+        Dictionary<String, Object> props3 = new Hashtable<>();
+        props3.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
+        props3.put("scope", "Global");
+        manager.add(createComponent()
+                        .setInterface(
+                                new String[]{IPluginInInventoryService.class.getName(),
+                                        OvsdbInventoryService.class.getName()}, props3)
+                        .setImplementation(InventoryServiceImpl.class)
+                        .add(createServiceDependency()
+                                .setService(IPluginOutInventoryService.class, "(scope=Global)")
+                                .setCallbacks("setPluginOutInventoryServices",
                                         "unsetPluginOutInventoryServices")
-                          .setRequired(true));
-            c.add(createServiceDependency()
-                    .setService(OvsdbInventoryListener.class)
-                    .setCallbacks("listenerAdded", "listenerRemoved"));
-            c.add(createServiceDependency()
-                    .setService(OvsdbConfigurationService.class)
-                    .setRequired(false));
-        }
+                                .setRequired(true))
+                        .add(createServiceDependency()
+                                .setService(OvsdbInventoryListener.class)
+                                .setCallbacks("listenerAdded", "listenerRemoved"))
+                        .add(createServiceDependency()
+                                .setService(OvsdbConfigurationService.class)
+                                .setRequired(false)));
+
+        Dictionary<String, Object> props4 = new Hashtable<String, Object>();
+        props4.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
+        props4.put("protocolName", "OVS");
+
+        manager.add(createComponent()
+                .setInterface(INodeFactory.class.getName(), props4)
+                .setImplementation(NodeFactory.class));
+
+        Dictionary<String, Object> props5 = new Hashtable<String, Object>();
+        props5.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
+        props5.put("protocolName", "OVS");
 
-        if (imp.equals(NodeFactory.class)) {
-            // export the service to be used by SAL
-            Dictionary<String, Object> props = new Hashtable<String, Object>();
-            // Set the protocolPluginType property which will be used
-            // by SAL
-            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-            props.put("protocolName", "OVS");
-            c.setInterface(INodeFactory.class.getName(), props);
-        }
-        if (imp.equals(NodeConnectorFactory.class)) {
-            // export the service to be used by SAL
-            Dictionary<String, Object> props = new Hashtable<String, Object>();
-            // Set the protocolPluginType property which will be used
-            // by SAL
-            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-            props.put("protocolName", "OVS");
-            c.setInterface(INodeConnectorFactory.class.getName(), props);
-        }
+        manager.add(createComponent()
+                .setInterface(INodeConnectorFactory.class.getName(), props5)
+                .setImplementation(NodeConnectorFactory.class));
+    }
 
+    @Override
+    public void destroy(BundleContext context, DependencyManager manager) throws Exception {
+        Node.NodeIDType.unRegisterIDType("OVS");
+        NodeConnector.NodeConnectorIDType.unRegisterIDType("OVS");
     }
 }