Introduced Activator in the Library module to make it OSGi friendly. 59/8359/4
authorMadhu Venugopal <mavenugo@gmail.com>
Thu, 26 Jun 2014 17:40:25 +0000 (10:40 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Thu, 26 Jun 2014 18:25:45 +0000 (11:25 -0700)
PAX-exam is not included due to the current merge resolution happening in parallel.

Change-Id: Ic25ae261905d2ea081d2bd936300cb92e7df4542
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
library/pom.xml
library/src/main/java/org/opendaylight/ovsdb/lib/Activator.java [new file with mode: 0644]

index 31f5c3c9c39a13f03429acc2b56beaf3847a82ec..f69ca33ff97ee8dde7c67b7b97cb9d404d632f41 100755 (executable)
       <groupId>ch.qos.logback</groupId>
       <artifactId>logback-core</artifactId>
     </dependency>
+      <dependency>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.dependencymanager</artifactId>
+      </dependency>
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-annotations</artifactId>
                 org.osgi.framework,
                 javax.net.ssl,
                 *</Import-Package>
+            <Bundle-Activator>org.opendaylight.ovsdb.lib.Activator</Bundle-Activator>
             <Embed-Transitive>true</Embed-Transitive>
             <Export-Package>org.opendaylight.ovsdb.lib,
                 org.opendaylight.ovsdb.lib.table,
diff --git a/library/src/main/java/org/opendaylight/ovsdb/lib/Activator.java b/library/src/main/java/org/opendaylight/ovsdb/lib/Activator.java
new file mode 100644 (file)
index 0000000..1f775d7
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Madhu Venugopal, Brent Salisbury
+ */
+package org.opendaylight.ovsdb.lib;
+
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * OVSDB Library OSGi Activator
+ */
+public class Activator extends DependencyActivatorBase {
+    protected static final Logger logger = LoggerFactory
+            .getLogger(Activator.class);
+
+    @Override
+    public void init(BundleContext context, DependencyManager manager) throws Exception {
+        manager.add(createComponent()
+            .setInterface(OvsdbConnection.class.getName(), null)
+            .setImplementation(OvsdbConnectionService.class)
+        );
+        manager.createServiceDependency()
+               .setService(OvsdbConnectionListener.class)
+               .setCallbacks("registerForPassiveConnection", "unregisterFromPassiveConnection")
+               .setRequired(false);
+    }
+
+    @Override
+    public void destroy(BundleContext context, DependencyManager manager) throws Exception {}
+}