From 56e572665cba4b30f4b954e19c1ebabee5cc90d4 Mon Sep 17 00:00:00 2001 From: rsivaram Date: Sat, 26 Jul 2008 21:15:13 +0000 Subject: Version Tuscany modules and 3rd party libraries in itest/osgi-tuscany git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@680048 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/osgi/runtime/impl/OSGiTestRuntime.java | 4 + java/sca/itest/osgi-tuscany/pom.xml | 1 + .../sca/installer/InstallerBundleActivator.java | 186 +++++- .../itest/osgi-tuscany/tuscany-versioned/pom.xml | 644 +++++++++++++++++++++ 4 files changed, 832 insertions(+), 3 deletions(-) create mode 100644 java/sca/itest/osgi-tuscany/tuscany-versioned/pom.xml (limited to 'java/sca/itest/osgi-tuscany') diff --git a/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/osgi/runtime/impl/OSGiTestRuntime.java b/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/osgi/runtime/impl/OSGiTestRuntime.java index 6362385a13..6356718fe5 100644 --- a/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/osgi/runtime/impl/OSGiTestRuntime.java +++ b/java/sca/itest/osgi-tuscany/osgi-tuscany-test/src/main/java/org/apache/tuscany/sca/test/osgi/runtime/impl/OSGiTestRuntime.java @@ -134,12 +134,15 @@ public abstract class OSGiTestRuntime { "javax.xml.xpath, " + "javax.sql," + "org.w3c.dom, " + + "org.w3c.dom.bootstrap, " + + "org.w3c.dom.ls, " + "org.xml.sax, " + "org.xml.sax.ext, " + "org.xml.sax.helpers, " + "javax.security.auth, " + "javax.security.auth.login, " + "javax.security.auth.callback, " + + "javax.security.cert, " + "javax.naming, " + "javax.naming.spi, " + "javax.naming.directory, " + @@ -147,6 +150,7 @@ public abstract class OSGiTestRuntime { "javax.imageio, " + "sun.misc, " + "javax.net, " + + "javax.net.ssl, " + "javax.crypto, " + "javax.rmi, " + "javax.transaction, " + diff --git a/java/sca/itest/osgi-tuscany/pom.xml b/java/sca/itest/osgi-tuscany/pom.xml index 4b432782a9..0da4f09d61 100644 --- a/java/sca/itest/osgi-tuscany/pom.xml +++ b/java/sca/itest/osgi-tuscany/pom.xml @@ -31,6 +31,7 @@ test-bundles + tuscany-versioned tuscany-osgi-installer osgi-tuscany-test diff --git a/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java b/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java index 2366acd094..059200302c 100644 --- a/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java +++ b/java/sca/itest/osgi-tuscany/tuscany-osgi-installer/src/main/java/org/apache/tuscany/sca/installer/InstallerBundleActivator.java @@ -77,9 +77,28 @@ public class InstallerBundleActivator implements BundleActivator { }; + private static final String[] rebundleJars = { + "org.apache.tuscany.sdo", // Recreate export statements + }; + public void start(BundleContext bundleContext) throws Exception { + + String tuscanyHome = System.getProperty("TUSCANY_HOME"); + if (tuscanyHome == null) { + File homeDir = new File("../tuscany-versioned/target/classes"); + if (homeDir.exists()) { + tuscanyHome = homeDir.getCanonicalPath(); + } + } - installTuscanyIntoOSGi(bundleContext); + if (tuscanyHome == null) { + System.out.println("Installing Tuscany bundles and virtual 3rd party bundles."); + installTuscanyIntoOSGi(bundleContext); + } + else { + System.out.println("Installing Tuscany from TUSCANY_HOME=" + tuscanyHome); + installVersionedTuscanyIntoOSGi(bundleContext, tuscanyHome); + } } public void stop(BundleContext bundleContext) throws Exception { @@ -92,6 +111,75 @@ public class InstallerBundleActivator implements BundleActivator { } } } + + private void installVersionedTuscanyIntoOSGi(BundleContext bundleContext, String tuscanyHome) { + + try { + Bundle[] installedBundles = bundleContext.getBundles(); + HashSet installedBundleSet = new HashSet(); + for (Bundle bundle : installedBundles) { + if (bundle.getSymbolicName() != null) + installedBundleSet.add(bundle.getSymbolicName()); + } + + // FIXME: SDO bundles dont have the correct dependencies + System.setProperty("commonj.sdo.impl.HelperProvider", "org.apache.tuscany.sdo.helper.HelperProviderImpl"); + + HashSet tuscanyJars = new HashSet(); + HashSet thirdPartyJars = new HashSet(); + + + File tuscanyInstallDir = new File(tuscanyHome).getCanonicalFile(); + findBundles(bundleContext, tuscanyInstallDir, tuscanyJars, thirdPartyJars); + + + for (File bundleFile : thirdPartyJars) { + + String bundleName = bundleFile.getName(); + if (bundleName.startsWith("org.apache.felix")) + continue; + + boolean installed = false; + for (String name : rebundleJars) { + if (bundleName.startsWith(name)) { + rebundleAndInstall(bundleContext, tuscanyInstallDir, bundleFile); + installed = true; + } + } + if (installed) + continue; + + bundleContext.installBundle(bundleFile.toURI().toURL().toString()); + + } + + Bundle osgiRuntimeBundle = null; + for (File bundleFile : tuscanyJars) { + Bundle bundle = bundleContext.installBundle(bundleFile.toURI().toURL().toString()); + if ("org.apache.tuscany.sca.osgi.runtime".equals(bundle.getSymbolicName())) + osgiRuntimeBundle = bundle; + } + if (osgiRuntimeBundle != null) + osgiRuntimeBundle.start(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void rebundleAndInstall(BundleContext bundleContext, File tuscanyInstallDir, File bundleFile) throws Exception { + String bundleSymbolicName = "org.apache.tuscany.sca.3rdparty." + bundleFile.getName(); + if (bundleSymbolicName.endsWith(".jar")) bundleSymbolicName = bundleSymbolicName.substring(0, bundleSymbolicName.length()-4); + + String bundleLocation = bundleFile.toURI().toURL().toString(); + InputStream bundleManifestStream = updateBundleManifest(bundleFile, bundleSymbolicName); + HashSet jarSet = new HashSet(); + jarSet.add(bundleFile); + + File newBundleFile = new File(tuscanyInstallDir, "org.apache.tuscany.sca." + bundleFile.getName()); + createAndInstallBundle(bundleContext, bundleLocation, newBundleFile, bundleManifestStream, jarSet); + bundleManifestStream.close(); + } private void installTuscanyIntoOSGi(BundleContext bundleContext) { @@ -167,6 +255,98 @@ public class InstallerBundleActivator implements BundleActivator { e.printStackTrace(); } } + + private void findBundles(BundleContext bundleContext, + File tuscanyInstallDir, + HashSet tuscanyJars, + HashSet thirdPartyJars) + throws IOException + { + + File[] jars = tuscanyInstallDir.listFiles(); + for (File jar : jars) { + String jarName = jar.getName(); + if (!jarName.endsWith(".jar")) + continue; + + if (!jarName.startsWith("org.apache.tuscany.sca")) { + if (jarName.endsWith(".jar")) + { + thirdPartyJars.add(jar); + } + } else { + boolean installTuscanyJar = true; + for (String name : tuscanyModulesToIgnore) { + name = name.replaceAll("-", "."); + if (jarName.startsWith("org.apache.tuscany.sca." + name)) { + installTuscanyJar = false; + break; + } + } + if (installTuscanyJar) + tuscanyJars.add(jar); + } + } + } + + + private InputStream updateBundleManifest(File jarFile, String bundleSymbolicName) throws Exception { + + if (!jarFile.exists()) + return null; + JarInputStream jar = new JarInputStream(new FileInputStream(jarFile)); + Manifest manifest = jar.getManifest(); + if (manifest == null) { + ZipEntry ze; + while ((ze = jar.getNextEntry()) != null) { + if (ze.getName().equals("META-INF/MANIFEST.MF")) + break; + } + if (ze != null) { + byte[] bytes = new byte[(int)ze.getSize()]; + jar.read(bytes); + manifest = new Manifest(new ByteArrayInputStream(bytes)); + } + } + if (manifest == null) { + manifest = new Manifest(); + } + + String bundleName = jarFile.getName(); + boolean isImmutableJar = false; + for (String immutableJar : immutableJars) { + if (bundleName.startsWith(immutableJar)) { + isImmutableJar = true; + break; + } + } + Attributes attributes = manifest.getMainAttributes(); + if (isImmutableJar) + attributes.putValue("Bundle-ClassPath", bundleName); + + + attributes.remove(new Attributes.Name("Require-Bundle")); + attributes.putValue("DynamicImport-Package", "*"); + + // Existing export statements in bundles may contain versions, so they should be used as is + // SDO exports are not sufficient, and should be changed + if (attributes.getValue("Export-Package") == null || bundleName.startsWith("org.apache.tuscany.sdo.tuscany-sdo-impl")) { + + HashSet packages = getPackagesInJar(bundleName, jar); + String version = getJarVersion(bundleName); + + attributes.putValue("Export-Package", packagesToString(packages, version)); + attributes.putValue("Import-Package", packagesToString(packages, null)); + } + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + manifest.write(out); + ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); + out.close(); + + return in; + + } private void findJars(BundleContext bundleContext, HashSet tuscanyJars, @@ -222,10 +402,10 @@ public class InstallerBundleActivator implements BundleActivator { tuscanyJars.add(jar); } } - - } + + private File findTuscanyInstallDir(Bundle installerBundle) throws IOException { diff --git a/java/sca/itest/osgi-tuscany/tuscany-versioned/pom.xml b/java/sca/itest/osgi-tuscany/tuscany-versioned/pom.xml new file mode 100644 index 0000000000..2a0ff0dcc8 --- /dev/null +++ b/java/sca/itest/osgi-tuscany/tuscany-versioned/pom.xml @@ -0,0 +1,644 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.4-SNAPSHOT + ../../pom.xml + + itest-osgi-tuscany-versioned + Apache Tuscany OSGi - Versioned Tuscany Bundles + + + true + ${pom.version} + + + + + ${pom.groupId} + tuscany-monitor-logging + ${pom.version} + + + ${pom.groupId} + tuscany-assembly + ${pom.version} + + + ${pom.groupId} + tuscany-assembly-xml + ${pom.version} + + + ${pom.groupId} + tuscany-assembly-xsd + ${pom.version} + + + ${pom.groupId} + tuscany-binding-dwr + ${pom.version} + + + ${pom.groupId} + tuscany-binding-ejb-runtime + ${pom.version} + + + ${pom.groupId} + tuscany-binding-atom + ${pom.version} + + + + ${pom.groupId} + tuscany-binding-feed + ${pom.version} + + + ${pom.groupId} + tuscany-binding-rss + ${pom.version} + + + ${pom.groupId} + tuscany-binding-rss-rome + ${pom.version} + + + ${pom.groupId} + tuscany-binding-http-runtime + ${pom.version} + + + ${pom.groupId} + tuscany-binding-jms-runtime + ${pom.version} + + + org.apache.activemq + apache-activemq + 4.1.1 + + + commons-httpclient + commons-httpclient + + + commons-fileupload + commons-fileupload + + + commons-beanutils + commons-beanutils + + + org.apache.activemq + activemq-console + + + org.apache.activemq + activemq-core + + + org.apache.activemq + activemq-optional + + + org.apache.activemq + activemq-web + + + org.apache.activemq + activemq-web-demo + + + org.apache.activemq + activemq-jaas + + + org.apache.geronimo.specs + geronimo-j2ee-connector_1.5_spec + + + org.apache.geronimo.specs + geronimo-j2ee-jacc_1.0_spec + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + org.apache.geronimo.specs + geronimo-jsp_2.0_spec + + + org.apache.geronimo.specs + geronimo-j2ee-management_1.0_spec + + + org.mortbay.jetty + servlet-api-2.5 + + + org.mortbay.jetty + jetty + + + org.mortbay.jetty + jetty-util + + + xerces + xercesImpl + + + backport-util-concurrent + backport-util-concurrent + + + activesoap + jaxp-api + + + activemq + jmdns + + + jrms + jrms + + + xerces + xmlParserAPIs + + + xstream + xstream + + + xmlpull + xmlpull + + + mx4j + mx4j + + + mx4j + mx4j-remote + + + + + ${pom.groupId} + tuscany-binding-jsonrpc-runtime + ${pom.version} + + + ${pom.groupId} + tuscany-binding-notification + ${pom.version} + + + ${pom.groupId} + tuscany-binding-rmi + ${pom.version} + + + ${pom.groupId} + tuscany-binding-sca + ${pom.version} + + + ${pom.groupId} + tuscany-binding-sca-axis2 + ${pom.version} + + + ${pom.groupId} + tuscany-binding-sca-xml + ${pom.version} + + + ${pom.groupId} + tuscany-binding-ws + ${pom.version} + + + ${pom.groupId} + tuscany-binding-ws-axis2 + ${pom.version} + + + ${pom.groupId} + tuscany-binding-ws-xml + ${pom.version} + + + ${pom.groupId} + tuscany-contribution + ${pom.version} + + + ${pom.groupId} + tuscany-contribution-groovy + ${pom.version} + + + ${pom.groupId} + tuscany-contribution-impl + ${pom.version} + + + ${pom.groupId} + tuscany-contribution-java + ${pom.version} + + + ${pom.groupId} + tuscany-contribution-namespace + ${pom.version} + + + ${pom.groupId} + tuscany-core + ${pom.version} + + + ${pom.groupId} + tuscany-core-databinding + ${pom.version} + + + ${pom.groupId} + tuscany-core-spi + ${pom.version} + + + ${pom.groupId} + tuscany-databinding + ${pom.version} + + + ${pom.groupId} + tuscany-databinding-axiom + ${pom.version} + + + ${pom.groupId} + tuscany-databinding-fastinfoset + ${pom.version} + + + ${pom.groupId} + tuscany-databinding-jaxb + ${pom.version} + + + ${pom.groupId} + tuscany-databinding-sdo + ${pom.version} + + + ${pom.groupId} + tuscany-databinding-sdo-axiom + ${pom.version} + + + ${pom.groupId} + tuscany-databinding-xmlbeans + ${pom.version} + + + ${pom.groupId} + tuscany-databinding-xstream + ${pom.version} + + + ${pom.groupId} + tuscany-host-embedded + ${pom.version} + + + ${pom.groupId} + tuscany-host-http + ${pom.version} + + + ${pom.groupId} + tuscany-host-rmi + ${pom.version} + + + ${pom.groupId} + tuscany-host-webapp + ${pom.version} + + + ${pom.groupId} + tuscany-host-jetty + ${pom.version} + + + ${pom.groupId} + tuscany-interface + ${pom.version} + + + ${pom.groupId} + tuscany-interface-java + ${pom.version} + + + ${pom.groupId} + tuscany-interface-java-xml + ${pom.version} + + + ${pom.groupId} + tuscany-interface-wsdl + ${pom.version} + + + ${pom.groupId} + tuscany-interface-wsdl-xml + ${pom.version} + + + + ${pom.groupId} + tuscany-implementation-das + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-ejb + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-ejb + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-java + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-java-xml + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-java-runtime + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-node + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-node-runtime + ${pom.version} + + + ${pom.groupId} + tuscany-host-tomcat + + + + + ${pom.groupId} + tuscany-implementation-osgi + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-resource-runtime + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-script + ${pom.version} + + + groovy + groovy-all-minimal + + + + + ${pom.groupId} + tuscany-implementation-spring + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-xquery + ${pom.version} + + + ${pom.groupId} + tuscany-implementation-widget-runtime + ${pom.version} + + + ${pom.groupId} + tuscany-node2-api + ${pom.version} + + + ${pom.groupId} + tuscany-node2-impl + ${pom.version} + + + ${pom.groupId} + tuscany-node2-launcher + ${pom.version} + + + ${pom.groupId} + tuscany-policy + ${pom.version} + + + ${pom.groupId} + tuscany-policy-logging + ${pom.version} + + + ${pom.groupId} + tuscany-policy-security + ${pom.version} + + + ${pom.groupId} + tuscany-policy-xml + ${pom.version} + + + ${pom.groupId} + tuscany-definitions + ${pom.version} + + + ${pom.groupId} + tuscany-workspace + ${pom.version} + + + ${pom.groupId} + tuscany-domain-manager + ${pom.version} + + + ${pom.groupId} + tuscany-host-tomcat + + + + + ${pom.groupId} + tuscany-workspace-impl + ${pom.version} + + + ${pom.groupId} + tuscany-workspace-xml + ${pom.version} + + + + ${pom.groupId} + tuscany-sca-api + ${pom.version} + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1-incubating + + + org.codehaus.woodstox + wstx-asl + + + + + org.apache.tuscany.sdo + tuscany-sdo-tools + 1.1-incubating + + + + com.sun.xml.bind + jaxb-impl + 2.1.6 + + + javax.xml.stream + stax-api + + + + + commons-lang + commons-lang + 2.1 + + + commons-cli + commons-cli + 1.0 + + + junit + junit + + + + + org.easymock + easymock + 2.2 + + + + + + + + org.apache.tuscany.sca + tuscany-maven-bundle-plugin + 1.4-SNAPSHOT + true + + + + execute + + + + + + + + + + -- cgit v1.2.3