summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-07-31 03:42:17 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-07-31 03:42:17 +0000
commit6e481c109faf970288bae780bea01c236571e277 (patch)
treef73fae7d20d1f15b4ec4ed6ece36b975455d97a5 /java/sca
parentdb0695c47f85c0d8a57966110bfb5b70fbb9f5e0 (diff)
Generate a gateway bundle that aggregate split META-INF/services resources
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@799510 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java21
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java3
-rw-r--r--java/sca/modules/extensibility-equinox/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/extensibility/META-INF/MANIFEST.MF10
-rw-r--r--java/sca/modules/host-http-osgi/META-INF/MANIFEST.MF2
-rw-r--r--java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF2
-rwxr-xr-xjava/sca/modules/implementation-osgi/META-INF/MANIFEST.MF2
-rw-r--r--java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF2
-rw-r--r--java/sca/modules/node-launcher-equinox/META-INF/MANIFEST.MF4
-rw-r--r--java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java62
-rw-r--r--java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java93
11 files changed, 166 insertions, 36 deletions
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
index e6b18f8068..e314046793 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
@@ -29,6 +29,7 @@ import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -49,8 +50,6 @@ import javax.wsdl.extensions.UnknownExtensibilityElement;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.stream.XMLInputFactory;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
@@ -62,6 +61,7 @@ import org.apache.axis2.Constants.Configuration;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.deployment.URLBasedAxisConfigurator;
import org.apache.axis2.deployment.util.Utils;
import org.apache.axis2.description.AxisEndpoint;
import org.apache.axis2.description.AxisOperation;
@@ -91,6 +91,7 @@ import org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigP
import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingHeaderConfigurator;
import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy;
import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
import org.apache.tuscany.sca.host.http.ServletHost;
@@ -170,7 +171,7 @@ public class Axis2ServiceProvider {
* This classloader is used in OSGi to work around XXXFactory.newInstance()
*/
private static class MultiParentClassLoader extends ClassLoader {
- private final Set<ClassLoader> classLoaders = new HashSet<ClassLoader>();
+ private final Collection<ClassLoader> classLoaders = new ArrayList<ClassLoader>();
/**
* @param parent The parent classloaders
@@ -180,7 +181,7 @@ public class Axis2ServiceProvider {
super(parent);
if (loaders != null) {
for (ClassLoader cl : loaders) {
- if (cl != null && cl != parent) {
+ if (cl != null && cl != parent && !classLoaders.contains(cl)) {
this.classLoaders.add(cl);
}
}
@@ -247,13 +248,15 @@ public class Axis2ServiceProvider {
// security policy.
configContext = AccessController.doPrivileged(new PrivilegedExceptionAction<ConfigurationContext>() {
public ConfigurationContext run() throws AxisFault {
- ClassLoader cl1 = modelFactories.getFactory(XMLInputFactory.class).getClass().getClassLoader();
- ClassLoader cl2 =
- modelFactories.getFactory(DocumentBuilderFactory.class).getClass().getClassLoader();
+ ClassLoader cl0 = getClass().getClassLoader();
+ ClassLoader cl1 = URLBasedAxisConfigurator.class.getClassLoader();
+ ClassLoader cl2 = ExtensionPointRegistry.class.getClassLoader();
+// ClassLoader cl3 =
+// modelFactories.getFactory(DocumentBuilderFactory.class).getClass().getClassLoader();
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
ClassLoader newTccl = tccl;
- if (cl1 != tccl || cl2 != tccl) {
- newTccl = new MultiParentClassLoader(null, new ClassLoader[] {cl1, cl2});
+ if (cl0 != tccl || cl1 != tccl || cl2 != tccl) {
+ newTccl = new MultiParentClassLoader(null, new ClassLoader[] {cl0, cl1, cl2, tccl});
}
if (newTccl != null && newTccl != tccl) {
Thread.currentThread().setContextClassLoader(newTccl);
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
index d54eac2228..fc1f4bd6c6 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
@@ -60,7 +60,8 @@ public class ClassLoaderModelResolver extends URLClassLoader implements ModelRes
}
}
if (parentClassLoader == null) {
- parentClassLoader = ServiceDiscovery.getInstance().getServiceDiscoverer().getClass().getClassLoader();
+ // The extensibility bundle has DynamicImport-Package = *
+ parentClassLoader = ServiceDiscovery.class.getClassLoader();
}
return parentClassLoader;
diff --git a/java/sca/modules/extensibility-equinox/META-INF/MANIFEST.MF b/java/sca/modules/extensibility-equinox/META-INF/MANIFEST.MF
index a613976264..9436ea4f94 100644
--- a/java/sca/modules/extensibility-equinox/META-INF/MANIFEST.MF
+++ b/java/sca/modules/extensibility-equinox/META-INF/MANIFEST.MF
@@ -6,7 +6,6 @@ Tool: Bnd-0.0.255
Bundle-Name: Apache Tuscany SCA Extensibility for Eclipse Equinox
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
Bundle-Vendor: The Apache Software Foundation
-DynamicImport-Package: *
Eclipse-LazyStart: true
Bundle-Version: 2.0.0
Bnd-LastModified: 1225397425625
diff --git a/java/sca/modules/extensibility/META-INF/MANIFEST.MF b/java/sca/modules/extensibility/META-INF/MANIFEST.MF
index 94a091df0c..7cc2ff22c9 100644
--- a/java/sca/modules/extensibility/META-INF/MANIFEST.MF
+++ b/java/sca/modules/extensibility/META-INF/MANIFEST.MF
@@ -1,11 +1,17 @@
Manifest-Version: 1.0
+Tuscany-Comment: Expoprt the META-INF.services under an "internal" attribute
+ so that it can be seen only by the bundle itself without following the
+ DynamicImport-Package *
Export-Package: org.apache.tuscany.sca.core;uses:="org.apache.tuscany.
sca.extensibility";version="2.0.0",org.apache.tuscany.sca.extensibility
- ;version="2.0.0"
+ ;version="2.0.0",META-INF.services;internal=true;mandatory:=internal
Tool: Bnd-0.0.255
Bundle-Name: Apache Tuscany SCA Extensibility
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
-DynamicImport-Package: org.apache.tuscany.sca.extensibility.equinox
+DynamicImport-Package: org.apache.tuscany.sca.extensibility.equinox,
+ javax.transaction;version="1.1",
+ javax.transaction.xa;version="1.1",
+ *
Bundle-Vendor: The Apache Software Foundation
Bundle-Version: 2.0.0
Bnd-LastModified: 1225397079296
diff --git a/java/sca/modules/host-http-osgi/META-INF/MANIFEST.MF b/java/sca/modules/host-http-osgi/META-INF/MANIFEST.MF
index e0e0a70663..efe05b13da 100644
--- a/java/sca/modules/host-http-osgi/META-INF/MANIFEST.MF
+++ b/java/sca/modules/host-http-osgi/META-INF/MANIFEST.MF
@@ -17,7 +17,7 @@ Import-Package: javax.net.ssl;resolution:=optional,
org.apache.tuscany.sca.work;version="2.0.0",
org.osgi.framework;version="1.4.0",
org.osgi.service.http;version="1.2",
- org.osgi.util.tracker;version="1.3.3"
+ org.osgi.util.tracker;version="1.3.0"
Bundle-SymbolicName: org.apache.tuscany.sca.host.http.osgi
Bundle-DocURL: http://www.apache.org/
Bundle-ActivationPolicy: lazy
diff --git a/java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF b/java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF
index f1bac6e4eb..986e931927 100644
--- a/java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF
+++ b/java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF
@@ -25,6 +25,6 @@ Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
org.oasisopen.sca;version="2.0.0",
org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
org.osgi.framework;version="1.4.0",
- org.osgi.util.tracker;version="1.3.3"
+ org.osgi.util.tracker;version="1.3.0"
Bundle-DocURL: http://www.apache.org/
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/java/sca/modules/implementation-osgi/META-INF/MANIFEST.MF b/java/sca/modules/implementation-osgi/META-INF/MANIFEST.MF
index f417c651b2..265ecaef6a 100755
--- a/java/sca/modules/implementation-osgi/META-INF/MANIFEST.MF
+++ b/java/sca/modules/implementation-osgi/META-INF/MANIFEST.MF
@@ -29,7 +29,7 @@ Import-Package: javax.xml.namespace,
org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
org.osgi.framework;version="1.4.0",
org.osgi.service.packageadmin;version="1.2.0",
- org.osgi.util.tracker;version="1.3.3"
+ org.osgi.util.tracker;version="1.3.0"
Bundle-DocURL: http://www.apache.org/
Export-Package: org.apache.tuscany.sca.implementation.osgi;version="2.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF b/java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF
index 71a5f1ae46..cef4fb1ff0 100644
--- a/java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF
+++ b/java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF
@@ -39,7 +39,7 @@ Import-Package: javax.xml.namespace,
org.osgi.framework;version="1.4.0",
org.osgi.framework.hooks.service;version="1.0.0";resolution:=optional,
org.osgi.service.packageadmin;version="1.2.0";resolution:=optional,
- org.osgi.util.tracker;version="1.3.3";resolution:=optional
+ org.osgi.util.tracker;version="1.3.0";resolution:=optional
Bundle-SymbolicName: org.apache.tuscany.sca.node.osgi.impl
Bundle-DocURL: http://www.apache.org/
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/java/sca/modules/node-launcher-equinox/META-INF/MANIFEST.MF b/java/sca/modules/node-launcher-equinox/META-INF/MANIFEST.MF
index 5bcd76a610..359daed2cc 100644
--- a/java/sca/modules/node-launcher-equinox/META-INF/MANIFEST.MF
+++ b/java/sca/modules/node-launcher-equinox/META-INF/MANIFEST.MF
@@ -15,8 +15,8 @@ Import-Package: org.apache.commons.cli;resolution:=optional,
org.apache.tuscany.sca.node.equinox.launcher;version="2.0.0",
org.eclipse.core.runtime.adaptor;resolution:=optional,
org.eclipse.osgi.framework.console;resolution:=optional,
- org.osgi.framework;version="1.4",
- org.osgi.framework.launch;version="1.0.0"
+ org.osgi.framework;version="[1.4, 2.0)",
+ org.osgi.framework.launch;version="[1.0.0, 2.0.0)"
Bundle-Activator: org.apache.tuscany.sca.node.equinox.launcher.FrameworkLauncher
Bundle-SymbolicName: org.apache.tuscany.sca.node.launcher.equinox
Bundle-DocURL: http://www.apache.org/
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 e730333cd2..24a8b368dc 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
@@ -21,6 +21,7 @@ package org.apache.tuscany.sca.node.equinox.launcher;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.setProperty;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.GATEWAY_BUNDLE;
import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.LAUNCHER_EQUINOX_LIBRARIES;
import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.artifactId;
import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.bundleName;
@@ -33,6 +34,7 @@ import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.thir
import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.thisBundleLocation;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -57,6 +59,7 @@ import java.util.logging.Logger;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.launch.Framework;
/**
@@ -155,6 +158,11 @@ public class EquinoxHost {
if (injectedBundleContext == null) {
String version = getSystemProperty("java.specification.version");
+
+ /**
+ * [rfeng] I have to remove javax.transaction.* packages from the system bundle
+ * See: http://www.mail-archive.com/dev@geronimo.apache.org/msg70761.html
+ */
String profile = "J2SE-1.5.profile";
if (version.startsWith("1.6")) {
profile = "JavaSE-1.6.profile";
@@ -197,6 +205,23 @@ public class EquinoxHost {
put(props, PROP_CONFIG_AREA_DEFAULT, new File(root, "config").toURI().toString());
put(props, PROP_USER_AREA_DEFAULT, new File(root, "user").toURI().toString());
+ // Test if the configuration/config.ini or osgi.bundles has been set
+ // If yes, try to avoid discovery of bundles
+ if (bundleLocations == null) {
+ if (props.getProperty("osgi.bundles") != null) {
+ bundleLocations = Collections.emptySet();
+ } else {
+ String config = props.getProperty(PROP_CONFIG_AREA);
+ File ini = new File(config, "config.ini");
+ if (ini.isFile()) {
+ Properties iniProps = new Properties();
+ iniProps.load(new FileInputStream(ini));
+ if (iniProps.getProperty("osgi.bundles") != null) {
+ bundleLocations = Collections.emptySet();
+ }
+ }
+ }
+ }
startFramework(props);
} else {
@@ -259,13 +284,20 @@ public class EquinoxHost {
logger.fine("Generating third-party library bundle.");
}
long libraryStart = currentTimeMillis();
+
+ Set<String> serviceProviders = new HashSet<String>();
if (!aggregateThirdPartyJars) {
for (URL jarFile : jarFiles) {
- installAsBundle(jarFile, null);
+ Bundle bundle = installAsBundle(jarFile, null);
+ isServiceProvider(bundle, serviceProviders);
}
} else {
- installAsBundle(jarFiles, LAUNCHER_EQUINOX_LIBRARIES);
+ Bundle bundle = installAsBundle(jarFiles, LAUNCHER_EQUINOX_LIBRARIES);
+ isServiceProvider(bundle, serviceProviders);
}
+
+ installGatewayBundle(serviceProviders);
+
if (logger.isLoggable(Level.FINE)) {
logger
.fine("Third-party library bundle installed in " + (currentTimeMillis() - libraryStart) + " ms: ");
@@ -320,6 +352,32 @@ public class EquinoxHost {
}
}
+ private boolean isServiceProvider(Bundle bundle, Set<String> serviceProviders) {
+ if (bundle != null) {
+ String export = (String)bundle.getHeaders().get(Constants.EXPORT_PACKAGE);
+ if (export != null && export.contains("META-INF.services")) {
+ serviceProviders.add(bundle.getSymbolicName());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void installGatewayBundle(Set<String> bundles) throws IOException, BundleException {
+ if (allBundles.containsKey(GATEWAY_BUNDLE)) {
+ return;
+ }
+ if (bundles == null) {
+ bundles = allBundles.keySet();
+ }
+ InputStream gateway = NodeLauncherUtil.generateGatewayBundle(bundles, null, false);
+ if (gateway != null) {
+ Bundle gatewayBundle = bundleContext.installBundle(GATEWAY_BUNDLE, gateway);
+ allBundles.put(NodeLauncherUtil.GATEWAY_BUNDLE, gatewayBundle);
+ installedBundles.add(gatewayBundle);
+ }
+ }
+
/**
* Start all the bundles as a check for class loading issues
* @param bundleContext - the bundle context
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 d958cda0cf..47480635f0 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
@@ -19,12 +19,22 @@
package org.apache.tuscany.sca.node.equinox.launcher;
+import static org.osgi.framework.Constants.ACTIVATION_LAZY;
+import static org.osgi.framework.Constants.BUNDLE_ACTIVATIONPOLICY;
import static org.osgi.framework.Constants.BUNDLE_CLASSPATH;
import static org.osgi.framework.Constants.BUNDLE_MANIFESTVERSION;
+import static org.osgi.framework.Constants.BUNDLE_NAME;
import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME;
+import static org.osgi.framework.Constants.BUNDLE_VENDOR;
+import static org.osgi.framework.Constants.BUNDLE_VERSION;
import static org.osgi.framework.Constants.DYNAMICIMPORT_PACKAGE;
import static org.osgi.framework.Constants.EXPORT_PACKAGE;
import static org.osgi.framework.Constants.IMPORT_PACKAGE;
+import static org.osgi.framework.Constants.REQUIRE_BUNDLE;
+import static org.osgi.framework.Constants.RESOLUTION_DIRECTIVE;
+import static org.osgi.framework.Constants.RESOLUTION_OPTIONAL;
+import static org.osgi.framework.Constants.VISIBILITY_DIRECTIVE;
+import static org.osgi.framework.Constants.VISIBILITY_REEXPORT;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -81,7 +91,8 @@ final class NodeLauncherUtil {
private static final Logger logger = Logger.getLogger(NodeLauncherUtil.class.getName());
static final String LAUNCHER_EQUINOX_LIBRARIES = "org.apache.tuscany.sca.node.launcher.equinox.libraries";
-
+ static final String GATEWAY_BUNDLE = "org.apache.tuscany.sca.gateway";
+
private static final String NODE_FACTORY = "org.apache.tuscany.sca.node.NodeFactory";
private static final String DOMAIN_MANAGER_LAUNCHER_BOOTSTRAP =
@@ -335,13 +346,22 @@ final class NodeLauncherUtil {
}
String pkg = cls.substring(0, index);
pkg = pkg.replace('/', '.') + version;
- packages.add(pkg);
+ // Export META-INF.services
+ if ("META-INF.services".equals(pkg)) {
+ packages.add("META-INF.services" + ";partial=true;mandatory:=partial");
+ } else {
+ packages.add(pkg);
+ }
}
} else if (file.isFile()) {
ZipInputStream is = new ZipInputStream(new FileInputStream(file));
ZipEntry entry;
while ((entry = is.getNextEntry()) != null) {
String entryName = entry.getName();
+ // Export split packages for META-INF/services
+ if(entryName.startsWith("META-INF/services/")) {
+ packages.add("META-INF.services" + ";partial=true;mandatory:=partial");
+ }
if (!entry.isDirectory() && entryName != null
&& entryName.length() > 0
&& !entryName.startsWith(".")
@@ -358,6 +378,10 @@ final class NodeLauncherUtil {
private static List<String> listClassFiles(File directory) {
List<String> artifacts = new ArrayList<String>();
traverse(artifacts, directory, directory);
+ // Add META-INF/services to be exported
+ if (new File(directory, "META-INF/services").isDirectory()) {
+ artifacts.add("META-INF/services/");
+ }
return artifacts;
}
@@ -426,16 +450,6 @@ final class NodeLauncherUtil {
String bundleSymbolicName,
String bundleVersion) throws IllegalStateException {
try {
- // Added by Mike Edwards, 12/04/2009 - to handle the third party JAR files in the distribution that
- // have separate OSGi manifest files provided alongside them
- // In some cases a single JAR file is already accompanied by a MANIFEST.MF file, sitting in
- // a META-INF directory alongside the JAR
- //if( jarFiles.size() == 1 ){
- // URL theJar = jarFiles.iterator().next();
- // Manifest theManifest = findOSGiManifest( theJar );
- // if( theManifest != null ) return theManifest;
- //} // end if
- // End of addition
// List exported packages and bundle classpath entries
StringBuffer classpath = new StringBuffer();
@@ -459,8 +473,11 @@ final class NodeLauncherUtil {
importPackage = pkg.substring(0, index);
}
if (!importPackages.contains(importPackage)) {
- imports.append(pkg);
- imports.append(',');
+ // Exclude META-INF.services
+ if (!"META-INF.services".equals(importPackage)) {
+ imports.append(pkg);
+ imports.append(',');
+ }
importPackages.add(importPackage);
exports.append(pkg);
exports.append(',');
@@ -492,7 +509,8 @@ final class NodeLauncherUtil {
if (classpath.length() > 0) {
attributes.putValue(BUNDLE_CLASSPATH, classpath.substring(0, classpath.length() - 1));
}
- attributes.putValue(DYNAMICIMPORT_PACKAGE, "*");
+ // The system bundle has incomplete javax.transaction* packages exported
+ attributes.putValue(DYNAMICIMPORT_PACKAGE, "javax.transaction;version=\"1.1\",javax.transaction.xa;version=\"1.1\",*");
return manifest;
} catch (IOException e) {
@@ -1259,4 +1277,49 @@ final class NodeLauncherUtil {
} // end if
} // end collectDevelopmentLibraryEntries
+ /**
+ * Generate a gateway bundle that aggregate other bundles to handle split packages
+ * @param bundleSymbolicNames
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ static InputStream generateGatewayBundle(Collection<String> bundleSymbolicNames, String bundleVersion, boolean reexport)
+ throws IOException {
+ Manifest manifest = new Manifest();
+ Attributes attrs = manifest.getMainAttributes();
+ StringBuffer requireBundle = new StringBuffer();
+ for (String name : new HashSet<String>(bundleSymbolicNames)) {
+ requireBundle.append(name).append(";").append(RESOLUTION_DIRECTIVE).append(":=")
+ .append(RESOLUTION_OPTIONAL);
+ if (reexport) {
+ requireBundle.append(";").append(VISIBILITY_DIRECTIVE).append(":=").append(VISIBILITY_REEXPORT);
+ }
+ requireBundle.append(",");
+ }
+ int len = requireBundle.length();
+ if (len > 0 && requireBundle.charAt(len - 1) == ',') {
+ requireBundle.deleteCharAt(len - 1);
+ attrs.putValue(REQUIRE_BUNDLE, requireBundle.toString());
+ attrs.putValue("Manifest-Version", "1.0");
+ attrs.putValue("Implementation-Vendor", "The Apache Software Foundation");
+ attrs.putValue("Implementation-Vendor-Id", "org.apache");
+ if (bundleVersion != null) {
+ attrs.putValue(BUNDLE_VERSION, bundleVersion);
+ }
+ attrs.putValue(BUNDLE_MANIFESTVERSION, "2");
+ attrs.putValue(BUNDLE_SYMBOLICNAME, GATEWAY_BUNDLE);
+ attrs.putValue(BUNDLE_NAME, "Apache Tuscany SCA Gateway Bundle");
+ attrs.putValue(BUNDLE_VENDOR, "The Apache Software Foundation");
+ attrs.putValue(EXPORT_PACKAGE, "META-INF.services");
+ attrs.putValue(DYNAMICIMPORT_PACKAGE, "*");
+ attrs.putValue(BUNDLE_ACTIVATIONPOLICY, ACTIVATION_LAZY);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ JarOutputStream jos = new JarOutputStream(bos, manifest);
+ jos.close();
+ return new ByteArrayInputStream(bos.toByteArray());
+ } else {
+ return null;
+ }
+ }
+
}