diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-04 19:21:25 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-04 19:21:25 +0000 |
commit | 5dd6ff4c0350b94f873eac1bcb0eb40866b361fa (patch) | |
tree | a7e174bba6235b9777e62374cdbc9f50f1a6bf23 /java/sca/modules/node-launcher-equinox/src/main | |
parent | 9cbac5c80f21f18158ffbf3f38babcec94110e3b (diff) |
Add the capability for equinox node launcher to support customized MANIFEST.MF for 3rd party jars
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@800929 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-launcher-equinox/src/main')
5 files changed, 365 insertions, 6 deletions
diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java index b8b6c39354..345a06880e 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java @@ -53,6 +53,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.UUID; +import java.util.jar.Manifest; import java.util.logging.Level; import java.util.logging.Logger; @@ -98,7 +99,7 @@ public class EquinoxHost { private Bundle launcherBundle; private List<URL> bundleFiles = new ArrayList<URL>(); private List<String> bundleNames = new ArrayList<String>(); - private Collection<URL> jarFiles = new HashSet<URL>(); + private Map<URL, Manifest> jarFiles = new HashMap<URL, Manifest>(); private Map<String, Bundle> allBundles = new HashMap<String, Bundle>(); private List<Bundle> installedBundles = new ArrayList<Bundle>(); @@ -148,6 +149,34 @@ public class EquinoxHost { } } + + /** + * Search for org/apache/tuscany/sca/node/equinox/launcher for customized MANIFEST.MF + * for a given artifact. For example, a-1.0.MF for a-1.0.jar. + * + * @param fileName + * @return + * @throws IOException + */ + private Manifest getCustomizedMF(String fileName) throws IOException { + int index = fileName.lastIndexOf('.'); + if (index == -1) { + return null; + } + String mf = fileName.substring(0, index) + ".MF"; + InputStream is = getClass().getResourceAsStream(mf); + if (is == null) { + return null; + } else { + try { + Manifest manifest = new Manifest(is); + return manifest; + } finally { + is.close(); + } + } + } + /** * Start the Equinox host. * @@ -238,13 +267,21 @@ public class EquinoxHost { // regular JARs for (URL url : urls) { File file = file(url); - String bundleName = bundleName(file); + Manifest manifest = getCustomizedMF(file.getName()); + String bundleName = null; + if (manifest == null) { + bundleName = bundleName(file); + } else { + if (manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME) == null) { + manifest = null; + } + } if (bundleName != null) { bundleFiles.add(url); bundleNames.add(bundleName); } else { if (file.isFile()) { - jarFiles.add(url); + jarFiles.put(url, manifest); } } } @@ -287,12 +324,19 @@ public class EquinoxHost { Set<String> serviceProviders = new HashSet<String>(); if (!aggregateThirdPartyJars) { - for (URL jarFile : jarFiles) { - Bundle bundle = installAsBundle(jarFile, null); + for (Map.Entry<URL, Manifest> entry : jarFiles.entrySet()) { + URL jarFile = entry.getKey(); + Manifest manifest = entry.getValue(); + Bundle bundle = null; + if (manifest == null) { + bundle = installAsBundle(jarFile, null); + } else { + bundle = installAsBundle(Collections.singleton(jarFile), manifest); + } isServiceProvider(bundle, serviceProviders); } } else { - Bundle bundle = installAsBundle(jarFiles, LAUNCHER_EQUINOX_LIBRARIES); + Bundle bundle = installAsBundle(jarFiles.keySet(), LAUNCHER_EQUINOX_LIBRARIES); isServiceProvider(bundle, serviceProviders); } @@ -422,6 +466,24 @@ public class EquinoxHost { } return libraryBundle; } + + public Bundle installAsBundle(Collection<URL> jarFiles, Manifest manifest) throws IOException, BundleException { + String bundleName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME); + + // Install a single 'library' bundle for the third-party JAR files + Bundle libraryBundle = allBundles.get(bundleName); + if (libraryBundle == null) { + InputStream library = thirdPartyLibraryBundle(jarFiles, manifest); + libraryBundle = bundleContext.installBundle(bundleName, library); + allBundles.put(bundleName, libraryBundle); + installedBundles.add(libraryBundle); + } else { + if (logger.isLoggable(Level.FINE)) { + logger.fine("Third-party library bundle is already installed: " + string(libraryBundle, false)); + } + } + return libraryBundle; + } public Bundle installBundle(URL bundleFile, String bundleName) throws MalformedURLException, BundleException { if (bundleName == null) { diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java index 832427b380..05e96fe7f0 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java @@ -537,6 +537,24 @@ final class NodeLauncherUtil { jos.close(); return new ByteArrayInputStream(bos.toByteArray()); } + + static InputStream thirdPartyLibraryBundle(Collection<URL> jarFiles, Manifest manifest) throws IOException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + StringBuffer classpath = new StringBuffer(); + for (URL jarFile : jarFiles) { + classpath.append("\"external:"); + classpath.append(file(jarFile).getPath().replace(File.separatorChar, '/')); + classpath.append("\","); + } + + if (classpath.length() > 0) { + manifest.getMainAttributes().putValue(BUNDLE_CLASSPATH, classpath.substring(0, classpath.length() - 1)); + } + + JarOutputStream jos = new JarOutputStream(bos, manifest); + jos.close(); + return new ByteArrayInputStream(bos.toByteArray()); + } /** * Returns the location of this bundle. diff --git a/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF b/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF new file mode 100644 index 0000000000..400fdc58e8 --- /dev/null +++ b/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF @@ -0,0 +1,48 @@ +Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Axiom API
+Bundle-SymbolicName: org.apache.ws.commons.axiom.axiom-api
+Bundle-Version: 1.2.7
+Bundle-ClassPath: axiom-api-1.2.7.jar
+Bundle-Vendor: Apache Software Foundation
+Export-Package: org.apache.axiom.attachments,
+ org.apache.axiom.attachments.impl,
+ org.apache.axiom.attachments.lifecycle,
+ org.apache.axiom.attachments.lifecycle.impl,
+ org.apache.axiom.attachments.utils,
+ org.apache.axiom.om,
+ org.apache.axiom.om.ds,
+ org.apache.axiom.om.ds.custombuilder,
+ org.apache.axiom.om.impl,
+ org.apache.axiom.om.impl.builder,
+ org.apache.axiom.om.impl.exception,
+ org.apache.axiom.om.impl.serialize,
+ org.apache.axiom.om.impl.traverse,
+ org.apache.axiom.om.impl.util,
+ org.apache.axiom.om.util,
+ org.apache.axiom.om.xpath,
+ org.apache.axiom.soap,
+ org.apache.axiom.soap.impl.builder
+Archiver-Version: Plexus Archiver
+Build-Jdk: 1.5.0_15
+Created-By: Apache Maven
+Bundle-DocURL: http://www.apache.org/
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Built-By: dims
+Import-Package: javax.activation,
+ javax.mail,
+ javax.mail.internet,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.om.impl.llom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap11;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap12;resolution:=optional,
+ org.apache.commons.logging,
+ org.jaxen;resolution:=optional,
+ org.jaxen.saxpath;resolution:=optional,
+ org.jaxen.util;resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.helpers
diff --git a/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF b/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF new file mode 100644 index 0000000000..58630c02ef --- /dev/null +++ b/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0
+
diff --git a/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF b/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF new file mode 100644 index 0000000000..b3e9d79d28 --- /dev/null +++ b/java/sca/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF @@ -0,0 +1,229 @@ +Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Created-By: 1.4.2_17 (Sun Microsystems Inc.)
+Built-By: dims
+Build-Jdk: 1.4.2_17
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Import-Package: com.ibm.wsdl.util,
+ com.ibm.wsdl.util.xml,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ org.apache.woden;version="1.0",
+ org.apache.woden.internal;version="1.0.0",
+ org.apache.woden.internal.resolver;version="1.0.0",
+ org.apache.woden.internal.schema;version="1.0.0",
+ org.apache.woden.internal.util;version="1.0.0",
+ org.apache.woden.internal.util.dom;version="1.0.0",
+ org.apache.woden.internal.wsdl20;version="1.0.0",
+ org.apache.woden.internal.wsdl20.assertions;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.http;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.rpc;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.soap;version="1.0.0",
+ org.apache.woden.internal.wsdl20.validation;version="1.0.0",
+ org.apache.woden.internal.xml;version="1.0.0",
+ org.apache.woden.internal.xpointer;version="1.0.0",
+ org.apache.woden.resolver;version="1.0",
+ org.apache.woden.schema;version="1.0",
+ org.apache.woden.tool.converter;version="1.0.0",
+ org.apache.woden.types;version="1.0",
+ org.apache.woden.wsdl20;version="1.0",
+ org.apache.woden.wsdl20.enumeration;version="1.0",
+ org.apache.woden.wsdl20.extensions;version="1.0",
+ org.apache.woden.wsdl20.extensions.http;version="1.0",
+ org.apache.woden.wsdl20.extensions.rpc;version="1.0",
+ org.apache.woden.wsdl20.extensions.soap;version="1.0",
+ org.apache.woden.wsdl20.fragids;version="1.0",
+ org.apache.woden.wsdl20.validation;version="1.0",
+ org.apache.woden.wsdl20.xml;version="1.0",
+ org.apache.woden.xml;version="1.0",
+ org.apache.woden.xpointer;version="1.0",
+ org.apache.ws.commons.schema,
+ org.apache.ws.commons.schema.resolver,
+ org.apache.ws.commons.schema.utils,
+ org.apache.xerces.parsers,
+ org.apache.xml.serialize,
+ org.w3c.dom,
+ org.xml.sax
+Bnd-LastModified: 1208980539265
+Export-Package: javax.xml.namespace,
+ org.apache.woden.internal;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.schema,
+ org.apache.xerces.parsers,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.resolver,
+ org.apache.woden.internal.schema,
+ javax.xml.parsers,
+ org.apache.woden.wsdl20.xml,
+ org.xml.sax,
+ org.apache.ws.commons.schema,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden.internal.xpointer,
+ org.apache.woden.internal.util.dom,
+ org.apache.ws.commons.schema.resolver,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.xpointer,
+ org.apache.woden.internal.wsdl20.validation,
+ org.apache.woden.wsdl20.enumeration,
+ org.apache.woden.types,
+ org.apache.woden.internal.resolver,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.resolver;version="1.0.0";
+ uses:="org.apache.ws.commons.schema.resolver,
+ org.xml.sax,
+ org.apache.xml.serialize,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.resolver,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.schema;version="1.0.0";
+ uses:="org.apache.woden.schema,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden",
+ org.apache.woden.internal.util;version="1.0.0",
+ org.apache.woden.internal.util.dom;version="1.0.0";
+ uses:="javax.xml.namespace,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.wsdl20;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.schema,
+ org.apache.woden.wsdl20.extensions.rpc,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.wsdl20.fragids,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.ws.commons.schema.utils,
+ org.apache.woden.internal.schema,
+ org.apache.woden.wsdl20.enumeration,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.types",
+ org.apache.woden.internal.wsdl20.assertions;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.validation,
+ javax.xml.namespace,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden,
+ org.apache.woden.resolver,
+ org.apache.woden.internal",
+ org.apache.woden.internal.wsdl20.extensions;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.woden.internal.wsdl20.extensions.soap,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal.wsdl20.extensions.rpc,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.wsdl20.extensions.soap,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.wsdl20.extensions.http;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.wsdl20.xml",
+ org.apache.woden.internal.wsdl20.extensions.rpc;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions",
+ org.apache.woden.internal.wsdl20.extensions.soap;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.wsdl20.extensions.soap",
+ org.apache.woden.internal.wsdl20.validation;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.validation,
+ org.apache.woden.schema,
+ org.apache.woden.internal.wsdl20.assertions,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.resolver,
+ org.apache.woden.internal,
+ org.apache.woden.types,
+ org.apache.woden.wsdl20.xml",
+ org.apache.woden.internal.xml;version="1.0.0";
+ uses:="org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.internal.util,
+ org.apache.woden.internal",
+ org.apache.woden.internal.xpointer;version="1.0.0";
+ uses:="org.apache.woden.xpointer,
+ org.apache.woden.types,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal",
+ org.apache.woden.tool.converter;version="1.0.0";
+ uses:="javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.xml,
+ javax.wsdl.factory,
+ javax.xml.namespace,
+ com.ibm.wsdl.util,
+ com.ibm.wsdl.util.xml"
+Bundle-Version: 1.0.0
+Bundle-Description: The Woden project is a subproject of the Apache We
+ b Services Project to develop a Java class library for reading, ma
+ nipulating, creating and writing WSDL documents, initially to supp
+ ort WSDL 2.0 but with the longer term aim of supporting past, present
+ and future versions of WSDL. There are two main deliverables:
+ an API and an implementation. The Woden API consists of a set of J
+ ava interfaces. The WSDL 2.0-specific portion of the Woden API confor
+ ms to the W3C WSDL 2.0 specification. The implementation will be a
+ high performance implementation directly usable in other Apache p
+ rojects such as Axis2.
+Bundle-Name: Woden - DOM
+Bundle-DocURL: http://www.apache.org/
+Bundle-ManifestVersion: 2
+Bundle-Vendor: Apache Software Foundation
+Bundle-SymbolicName: org.apache.woden.woden-impl-dom
+Tool: Bnd-0.0.238
+
+
|