add bundle support for library 95/1495/1
authorMichal Rehak <mirehak@cisco.com>
Thu, 26 Sep 2013 15:10:17 +0000 (17:10 +0200)
committerMichal Rehak <mirehak@cisco.com>
Mon, 30 Sep 2013 07:26:41 +0000 (09:26 +0200)
fixing slf4j dependency, property added

Change-Id: I6f4366eb4933494cdb4e049810b782e2916418ab
Signed-off-by: Michal Rehak <mirehak@cisco.com>
openflow-protocol-api/pom.xml
openflow-protocol-impl/pom.xml
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/Activator.java [new file with mode: 0644]
openflow-protocol-spi/pom.xml
pom.xml

index 2b8a65c1cff6875270a8cdee5502ff5d0432e061..fa09ec52881be333e48d201d149f862d61797f68 100644 (file)
@@ -7,6 +7,7 @@
                <version>0.1-SNAPSHOT</version>\r
        </parent>\r
        <artifactId>openflow-protocol-api</artifactId>\r
+    <packaging>bundle</packaging>\r
        <name>Openflow Protocol Library - API</name>\r
     \r
     <properties>\r
index 34b57ad4e5766668877d879a26f43d70255affc0..dd3632018dccccb998461108a686111dff2045e0 100644 (file)
@@ -7,7 +7,24 @@
         <version>0.1-SNAPSHOT</version>
     </parent>
     <artifactId>openflow-protocol-impl</artifactId>
-    <packaging>jar</packaging>
+    <packaging>bundle</packaging>
+    <name>Openflow Protocol Library - IMPL</name>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>
+                          org.opendaylight.openflowjava.protocol.impl.connection.Activator
+                        </Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
     
     <dependencies>
         <dependency>
         </dependency>
         <dependency>
             <groupId>io.netty</groupId>
-            <artifactId>netty-all</artifactId>
+            <artifactId>netty-handler</artifactId>
             <version>4.0.8.Final</version>
         </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>5.0.0</version>
+        </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
-            <version>1.7.5</version>
+            <version>${slf4j.version}</version>
         </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/Activator.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/Activator.java
new file mode 100644 (file)
index 0000000..1406735
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.opendaylight.openflowjava.protocol.impl.connection;
+
+import java.util.Hashtable;
+
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Activate library bundle, expose provided implementations:
+ * <ul>
+ *  <li>{@link SwitchConnectionProviderImpl}</li>
+ * </ul>
+ * 
+ * @author mirehak
+ */
+public class Activator implements BundleActivator {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        LOG.debug("starting OF Library");
+        Hashtable<String, String> props = new Hashtable<String, String>();
+        props.put("type", "default");
+        context.registerService(
+                SwitchConnectionProvider.class.getName(), 
+                new SwitchConnectionProviderImpl(), props);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        LOG.debug("stopping OF Library");
+        //TODO:: add teardown activities (check, if servers are running, stop if necessary..)
+    }
+}
index 78996e7c6a4af33948c3fac77b0d1b56b81cddd2..e6cf8e4ec951f1f2b59579eb8c20d5e4a6da8c96 100644 (file)
@@ -7,8 +7,10 @@
         <version>0.1-SNAPSHOT</version>
     </parent>
     <artifactId>openflow-protocol-spi</artifactId>
-       <name>Openflow Protocol Library SPI</name>
-       
+    <packaging>bundle</packaging>
+    
+    <name>Openflow Protocol Library - SPI</name>
+    
     <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
diff --git a/pom.xml b/pom.xml
index ff99572be59223e705f358ba9d7c5dfff4d783f7..eb5c77f55399755c5376de3f310ac332cff5c570 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -28,8 +28,9 @@
         <sonar.branch>${user.name}-private-view</sonar.branch>
         <sonar.skippedModules>org.openflow.openflowj,net.sf.jung2</sonar.skippedModules>
         <logback.version>1.0.9</logback.version>
-        <slf4j.version>1.7.2</slf4j.version>
+        <slf4j.version>1.7.5</slf4j.version>
        <yang.prototype.version>1.0-SNAPSHOT</yang.prototype.version>
+       <maven.bundle.version>2.4.0</maven.bundle.version>
     </properties>
 
     <pluginRepositories>
             <dependency>
                 <groupId>org.slf4j</groupId>
                 <artifactId>slf4j-api</artifactId>
-                <version>1.7.2</version>
+                <version>${slf4j.version}</version>
             </dependency>
         </dependencies>
     </dependencyManagement>
                     </execution> 
                 </executions> 
             </plugin> 
+            <plugin>
+              <groupId>org.apache.felix</groupId>
+              <artifactId>maven-bundle-plugin</artifactId>
+              <version>${maven.bundle.version}</version>
+              <extensions>true</extensions>
+              <configuration>
+                <instructions>
+                  <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                </instructions>
+                <manifestLocation>${project.build.directory}/META-INF</manifestLocation>
+              </configuration>
+            </plugin>
         </plugins>
         <pluginManagement>
             <plugins>