concierge: Add OSGi R3 implementation and service tracker
authorStefan Schmidt <stefan@buglabs.net>
Thu, 2 Dec 2010 14:37:18 +0000 (15:37 +0100)
committerStefan Schmidt <stefan@buglabs.net>
Mon, 31 Jan 2011 11:03:52 +0000 (12:03 +0100)
recipes/concierge/concierge_1.0.bb [new file with mode: 0644]
recipes/concierge/files/fix-EE-string.patch [new file with mode: 0644]
recipes/concierge/files/run-in-place.patch [new file with mode: 0644]
recipes/concierge/files/service-tracker-MANIFEST.MF [new file with mode: 0644]
recipes/concierge/service-tracker_1.0-rc3.bb [new file with mode: 0644]

diff --git a/recipes/concierge/concierge_1.0.bb b/recipes/concierge/concierge_1.0.bb
new file mode 100644 (file)
index 0000000..e4a99e0
--- /dev/null
@@ -0,0 +1,27 @@
+DESCRIPTION = "A fast, lightweight OSGi R3 framework implementation"
+LICENSE = "BSD"
+DEPENDS = "fastjar-native"
+
+SRCREV = "246"
+PV = "1.0+svnr${SRCREV}"
+PR = "r0"
+
+SRC_URI = "svn://concierge.svn.sourceforge.net/svnroot/concierge/tags/Concierge/1.0.0/trunk;module=framework;proto=http;localdir=framework \
+                   file://fix-EE-string.patch \
+                   file://run-in-place.patch;striplevel=1 \
+                  "
+S = "${WORKDIR}/framework"
+
+inherit bug-java-library
+
+do_compile() {
+  mkdir -p build
+  javac -sourcepath src/main/java -d build `find src/main/java -name \*.java`
+  fastjar -0 -C build -c -f ${JARFILENAME} .
+}
+
+PACKAGE_ARCH = "all"
+# override java-library's naming conventions
+PACKAGES = "${PN}"
+
+FILES_${PN} += "${datadir_java}/${PN}.jar"
diff --git a/recipes/concierge/files/fix-EE-string.patch b/recipes/concierge/files/fix-EE-string.patch
new file mode 100644 (file)
index 0000000..9c04eb5
--- /dev/null
@@ -0,0 +1,13 @@
+Index: framework/src/main/java/ch/ethz/iks/concierge/framework/Framework.java
+===================================================================
+--- framework.orig/src/main/java/ch/ethz/iks/concierge/framework/Framework.java
++++ framework/src/main/java/ch/ethz/iks/concierge/framework/Framework.java
+@@ -624,7 +624,7 @@ public final class Framework {\r
+                       case 7:\r
+                               myEEs.append("J2SE-1.7,");\r
+                       case 6:\r
+-                              myEEs.append("J2SE-1.6,");\r
++                              myEEs.append("JavaSE-1.6,");\r
+                       case 5:\r
+                               myEEs.append("J2SE-1.5,");\r
+                       case 4:\r
diff --git a/recipes/concierge/files/run-in-place.patch b/recipes/concierge/files/run-in-place.patch
new file mode 100644 (file)
index 0000000..04bb86c
--- /dev/null
@@ -0,0 +1,97 @@
+---
+ src/main/java/ch/ethz/iks/concierge/framework/BundleClassLoader.java |   11 +++++-
+ src/main/java/ch/ethz/iks/concierge/framework/Framework.java         |   17 ++++++++--
+ 2 files changed, 24 insertions(+), 4 deletions(-)
+
+--- framework.orig/src/main/java/ch/ethz/iks/concierge/framework/BundleClassLoader.java
++++ framework/src/main/java/ch/ethz/iks/concierge/framework/BundleClassLoader.java
+@@ -172,13 +172,20 @@ final class BundleClassLoader extends Cl
+               this.bundle = bundle;\r
+               this.storageLocation = Framework.STORAGE_LOCATION + bundle.bundleID\r
+                               + File.separatorChar + File.separatorChar;\r
\r
+               try {\r
+-                      // write the JAR file to the storage\r
+                       File file = new File(storageLocation, BUNDLE_FILE_NAME);\r
+-                      storeFile(file, stream);\r
++\r
++                      if (Framework.RUN_IN_PLACE) {\r
++                              file.getParentFile().mkdirs();\r
++                              String fileLoc = bundle.location.indexOf(':') > -1 ? bundle.location.substring(bundle.location.indexOf(':') + 1) : bundle.location;\r
++                              file = new File(fileLoc);\r
++                      } else {\r
++                              // write the JAR file to the storage\r
++                              storeFile(file, stream);\r
++                      }\r
\r
+                       // and open a JarFile\r
+                       final JarFile jar = new JarFile(file);\r
\r
+                       // process the manifest\r
+--- framework.orig/src/main/java/ch/ethz/iks/concierge/framework/Framework.java
++++ framework/src/main/java/ch/ethz/iks/concierge/framework/Framework.java
+@@ -164,10 +164,15 @@ public final class Framework {
\r
+       /**\r
+        * debug outputs from services ?\r
+        */\r
+       static boolean DEBUG_SERVICES;\r
++      \r
++      /**\r
++       * run without copying classes to storage ?\r
++       */\r
++      static boolean RUN_IN_PLACE;\r
\r
+       /**\r
+        * the profile.\r
+        */\r
+       private static String PROFILE;\r
+@@ -382,27 +387,34 @@ public final class Framework {
+                               PROFILE = properties.getProperty("osgi.profile", "default");\r
+                               launch();\r
\r
+                               // if profile set, try to restart the profile\r
+                               target = -1;\r
++                              restart = false;\r
+                               boolean init = getProperty("osgi.init", false);\r
+-                              if (!init) {\r
++                              if (RUN_IN_PLACE) {\r
++                                      System.out.println("Executing jars in place.");\r
++                              }\r
++                              \r
++                              if (!init && !RUN_IN_PLACE) {\r
+                                       time = System.currentTimeMillis();\r
+                                       target = restoreProfile();\r
+                                       restart = true;\r
+                               }\r
\r
+                               if (target == -1) {\r
+-                                      restart = false;\r
+                                       File storage = new File(STORAGE_LOCATION);\r
+                                       if (init) {\r
+                                               if (storage.exists()) {\r
+                                                       System.out.println("purging storage ...");\r
+                                                       deleteDirectory(storage);\r
+                                               }\r
++                                      } else if (RUN_IN_PLACE && storage.exists()) {\r
++                                              restart = true;\r
+                                       }\r
\r
++\r
+                                       storage.mkdirs();\r
\r
+                                       // TO THE ACTUAL WORK\r
+                                       time = System.currentTimeMillis();\r
+                                       properties.setProperty("osgi.auto.install.1", properties\r
+@@ -592,10 +604,11 @@ public final class Framework {
+                               false);\r
+               DECOMPRESS_EMBEDDED = getProperty(\r
+                               "ch.ethz.iks.concierge.decompressEmbedded", true);\r
+               SECURITY_ENABLED = getProperty(\r
+                               "ch.ethz.iks.concierge.security.enabled", false);\r
++              RUN_IN_PLACE = getProperty("ch.ethz.iks.concierge.runInPlace", false);\r
\r
+               final String ADDITIONAL_PACKAGES = properties\r
+                               .getProperty("org.osgi.framework.system.packages");\r
\r
+               if (ADDITIONAL_PACKAGES != null) {\r
diff --git a/recipes/concierge/files/service-tracker-MANIFEST.MF b/recipes/concierge/files/service-tracker-MANIFEST.MF
new file mode 100644 (file)
index 0000000..89d9891
--- /dev/null
@@ -0,0 +1,5 @@
+Bundle-Name: Service Tracker
+Bundle-Description: Concierge Service Tracker
+Bundle-Vendor: Jan S. Rellermeyer, ETH Zurich
+Import-Package: org.osgi.framework;specification-version=1.2
+Export-Package: org.osgi.util.tracker;specification-version=1.2
diff --git a/recipes/concierge/service-tracker_1.0-rc3.bb b/recipes/concierge/service-tracker_1.0-rc3.bb
new file mode 100644 (file)
index 0000000..6899232
--- /dev/null
@@ -0,0 +1,34 @@
+DESCRIPTION = "OSGi R3 ServiceTracker classes"
+HOMEPAGE = "http://concierge.sourceforge.net"
+LICENSE = "BSD"
+DEPENDS = "fastjar-native concierge"
+
+SRCREV = "220"
+PV = "1.0+svnr${SRCREV}"
+PR = "r0"
+
+SRC_URI = "svn://concierge.svn.sourceforge.net/svnroot/concierge/tags/Concierge/1.0.0.RC3/;module=bundles/service_tracker;proto=http;localdir=${PN} \
+        file://files/service-tracker-MANIFEST.MF \
+"
+
+S = "${WORKDIR}/bundles/service_tracker"
+
+inherit bug-java-library
+
+do_compile() {
+  mkdir -p build
+  oe_makeclasspath cp -s ${DEPENDS} ${EXTRA_CP}
+  echo "JAVAC CLASSPATH ---------------"
+  echo $cp | awk 'BEGIN {FS=":"} {split($0,a,":"); for (i=1; i<=NF; i++) print a[i]; }'
+  echo "-------------------------"
+  javac -sourcepath src/main/java -cp $cp -d build `find src/main/java -name \*.java`
+  fastjar -m ${WORKDIR}/files/service-tracker-MANIFEST.MF -C build -c -f ${JARFILENAME} .
+  fastjar -C src/main/java -u -f ${JARFILENAME} .
+}
+
+PACKAGE_ARCH = "all"
+# override java-library's naming conventions
+PACKAGES = "${PN}"
+
+FILES_${PN} += "${datadir_java}/${PN}.jar"
+FILES_${PN} += "${datadir_java}/${P}.jar"