From 1fd00705939747143753aeae8c8aa084e3d9f800 Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 29 Jun 2009 22:10:28 +0000 Subject: Merge changes from trunk to bring up the distributed osgi samples with Tuscany distribution git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@789466 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding-ws-axis2-policy/META-INF/MANIFEST.MF | 1 - .../modules/binding-ws-axis2/META-INF/MANIFEST.MF | 19 +++++++------- .../modules/binding-ws-axis2/pom.xml | 7 ++++++ .../sca/binding/ws/axis2/Axis2ServiceProvider.java | 3 +-- .../osgi/impl/OSGiBundleContributionScanner.java | 16 ++++++++++-- .../modules/contribution/META-INF/MANIFEST.MF | 1 + .../core/assembly/impl/EndpointSerializerImpl.java | 8 +++--- .../modules/databinding-axiom/META-INF/MANIFEST.MF | 4 --- .../tuscany/sca/node/osgi/impl/NodeManager.java | 21 +++++++++++++--- .../sca/node/equinox/launcher/NodeLauncher.java | 29 +++++++++++++++++++--- 10 files changed, 80 insertions(+), 29 deletions(-) (limited to 'branches/sca-java-2.0-M3/modules') diff --git a/branches/sca-java-2.0-M3/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M3/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF index 0f0213707a..992af5dd44 100644 --- a/branches/sca-java-2.0-M3/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF +++ b/branches/sca-java-2.0-M3/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF @@ -44,7 +44,6 @@ Import-Package: javax.xml.namespace, org.apache.tuscany.sca.contribution.processor;version="2.0.0", org.apache.tuscany.sca.contribution.resolver;version="2.0.0", org.apache.tuscany.sca.core;version="2.0.0", - org.apache.tuscany.sca.databinding.axiom;version="2.0.0", org.apache.tuscany.sca.interfacedef;version="2.0.0", org.apache.tuscany.sca.invocation;version="2.0.0", org.apache.tuscany.sca.monitor;version="2.0.0", diff --git a/branches/sca-java-2.0-M3/modules/binding-ws-axis2/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M3/modules/binding-ws-axis2/META-INF/MANIFEST.MF index adef101ef7..74869d3c4a 100644 --- a/branches/sca-java-2.0-M3/modules/binding-ws-axis2/META-INF/MANIFEST.MF +++ b/branches/sca-java-2.0-M3/modules/binding-ws-axis2/META-INF/MANIFEST.MF @@ -76,7 +76,14 @@ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Bundle-Description: Apache Tuscany SCA Axis2-based WS Binding Extensio n Eclipse-RegisterBuddy: org.apache.axis2.kernel -Import-Package: javax.security.auth.callback;resolution:=optional, +Import-Package: javax.xml.stream, + javax.xml.transform, + javax.xml.transform.dom, + javax.xml.parsers, + org.w3c.dom, + javax.activation;resolution:=optional, + org.xml.sax, + javax.security.auth.callback;resolution:=optional, javax.servlet, javax.servlet.http, javax.wsdl, @@ -86,9 +93,6 @@ Import-Package: javax.security.auth.callback;resolution:=optional, javax.wsdl.factory;resolution:=optional, javax.wsdl.xml;resolution:=optional, javax.xml.namespace, - javax.xml.stream, - javax.xml.transform, - javax.xml.transform.dom, org.apache.axiom.om, org.apache.axiom.om.impl.builder, org.apache.axiom.om.util, @@ -112,6 +116,7 @@ Import-Package: javax.security.auth.callback;resolution:=optional, org.apache.axis2.util.threadpool, org.apache.commons.httpclient, org.apache.commons.httpclient.params, + org.apache.commons.logging;resolution:=optional, org.apache.neethi, org.apache.tuscany.sca.assembly;version="2.0.0", org.apache.tuscany.sca.binding.ws;version="2.0.0", @@ -144,12 +149,8 @@ Import-Package: javax.security.auth.callback;resolution:=optional, org.apache.ws.security, org.apache.ws.security.handler, org.oasisopen.sca;version="2.0.0", - org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional, - org.w3c.dom, - javax.activation;resolution:=optional, - org.xml.sax + org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional Bundle-SymbolicName: org.apache.tuscany.sca.binding.ws.axis2 -Fragment-Host: org.apache.axis2.kernel Bundle-DocURL: http://www.apache.org/ Bundle-RequiredExecutionEnvironment: J2SE-1.5, JavaSE-1.6 diff --git a/branches/sca-java-2.0-M3/modules/binding-ws-axis2/pom.xml b/branches/sca-java-2.0-M3/modules/binding-ws-axis2/pom.xml index dcc97d3400..116c34e357 100644 --- a/branches/sca-java-2.0-M3/modules/binding-ws-axis2/pom.xml +++ b/branches/sca-java-2.0-M3/modules/binding-ws-axis2/pom.xml @@ -84,10 +84,17 @@ runtime + + org.apache.tuscany.sca + tuscany-databinding + 2.0-M3-SNAPSHOT + + org.apache.tuscany.sca tuscany-databinding-axiom 2.0-M3-SNAPSHOT + runtime diff --git a/branches/sca-java-2.0-M3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/branches/sca-java-2.0-M3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java index cd3a6b38b8..1db1d94dee 100644 --- a/branches/sca-java-2.0-M3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java +++ b/branches/sca-java-2.0-M3/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.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; @@ -118,8 +119,6 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import edu.emory.mathcs.backport.java.util.Collections; - public class Axis2ServiceProvider { public static final String IMPORT_TAG = "import"; public static final String INCLUDE_TAG = "include"; diff --git a/branches/sca-java-2.0-M3/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java b/branches/sca-java-2.0-M3/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java index 3d20d968a3..a8bec24dab 100644 --- a/branches/sca-java-2.0-M3/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java +++ b/branches/sca-java-2.0-M3/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java @@ -37,6 +37,7 @@ import org.apache.tuscany.sca.contribution.processor.ContributionException; import org.apache.tuscany.sca.contribution.processor.ContributionReadException; import org.apache.tuscany.sca.contribution.scanner.ContributionScanner; import org.osgi.framework.Bundle; +import org.osgi.framework.Constants; /** * Bundle Contribution package processor. @@ -123,19 +124,30 @@ public class OSGiBundleContributionScanner implements ContributionScanner { } List artifacts = new ArrayList(); + Set bundleClassPath = new HashSet(); + String cp = (String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH); + if (cp != null) { + String[] paths = cp.split(","); + for (String path : paths) { + bundleClassPath.add(path.trim()); + } + } try { Enumeration entries = bundle.findEntries("/", "*", true); while (entries.hasMoreElements()) { URL entry = (URL)entries.nextElement(); String entryName = entry.getPath(); + if (entryName.contains("/.svn/")) { + // Ignore .svn files + continue; + } if (entryName.startsWith("/")) { entryName = entryName.substring(1); } artifacts.add(entryName); - // FIXME: We probably should honor Bundle-ClassPath headers to deal with inner jars - if (entryName.endsWith(".jar")) { + if (entryName.endsWith(".jar") && bundleClassPath.contains(entryName)) { artifacts.addAll(getJarArtifacts(entry, entry.openStream())); } diff --git a/branches/sca-java-2.0-M3/modules/contribution/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M3/modules/contribution/META-INF/MANIFEST.MF index aeda1d66a6..6d2c1e8380 100644 --- a/branches/sca-java-2.0-M3/modules/contribution/META-INF/MANIFEST.MF +++ b/branches/sca-java-2.0-M3/modules/contribution/META-INF/MANIFEST.MF @@ -49,6 +49,7 @@ Import-Package: javax.xml.namespace, org.apache.tuscany.sca.monitor;version="2.0.0", org.apache.tuscany.sca.policy;version="2.0.0", org.w3c.dom, + org.w3c.dom.ls, org.xml.sax, org.xml.sax.helpers Bundle-SymbolicName: org.apache.tuscany.sca.contribution diff --git a/branches/sca-java-2.0-M3/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java b/branches/sca-java-2.0-M3/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java index cd86fd21aa..b9eb6c117b 100644 --- a/branches/sca-java-2.0-M3/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java +++ b/branches/sca-java-2.0-M3/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java @@ -61,7 +61,7 @@ public class EndpointSerializerImpl implements EndpointSerializer { endpoint.setBinding(result.getBinding()); endpoint.setInterfaceContract(result.getService().getInterfaceContract()); } catch (Exception e) { - throw new IOException(e); + throw new IOException(e.getMessage()); } } @@ -75,7 +75,7 @@ public class EndpointSerializerImpl implements EndpointSerializer { writer.close(); return sw.toString(); } catch (Exception e) { - throw new IOException(e); + throw new IOException(e.getMessage()); } } @@ -89,7 +89,7 @@ public class EndpointSerializerImpl implements EndpointSerializer { endpointReference.setBinding(result.getBinding()); endpointReference.setInterfaceContract(result.getReference().getInterfaceContract()); } catch (Exception e) { - throw new IOException(e); + throw new IOException(e.getMessage()); } } @@ -102,7 +102,7 @@ public class EndpointSerializerImpl implements EndpointSerializer { writer.close(); return sw.toString(); } catch (Exception e) { - throw new IOException(e); + throw new IOException(e.getMessage()); } } } \ No newline at end of file diff --git a/branches/sca-java-2.0-M3/modules/databinding-axiom/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M3/modules/databinding-axiom/META-INF/MANIFEST.MF index d1b38bea6c..bc9ebc0bc8 100644 --- a/branches/sca-java-2.0-M3/modules/databinding-axiom/META-INF/MANIFEST.MF +++ b/branches/sca-java-2.0-M3/modules/databinding-axiom/META-INF/MANIFEST.MF @@ -18,9 +18,6 @@ Import-Package: javax.xml.namespace, javax.xml.stream, org.apache.axiom.om, org.apache.axiom.om.impl.builder, - org.apache.axiom.om.impl.llom.factory;resolution:=optional, - org.apache.axiom.soap.impl.llom.soap11;resolution:=optional, - org.apache.axiom.soap.impl.llom.soap12;resolution:=optional, org.apache.tuscany.sca.databinding;version="2.0.0", org.apache.tuscany.sca.databinding.axiom;version="2.0.0", org.apache.tuscany.sca.databinding.impl;version="2.0.0", @@ -30,6 +27,5 @@ Import-Package: javax.xml.namespace, org.apache.tuscany.sca.interfacedef.util;version="1.4", org.apache.tuscany.sca.policy;version="2.0.0" Bundle-SymbolicName: org.apache.tuscany.sca.databinding.axiom -Fragment-Host: org.apache.ws.commons.axiom.axiom-api Bundle-DocURL: http://www.apache.org/ Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/branches/sca-java-2.0-M3/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java b/branches/sca-java-2.0-M3/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java index fb2e8a8305..3f71117c1a 100644 --- a/branches/sca-java-2.0-M3/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java +++ b/branches/sca-java-2.0-M3/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java @@ -19,8 +19,8 @@ package org.apache.tuscany.sca.node.osgi.impl; +import java.net.URL; import java.util.Dictionary; -import java.util.Enumeration; import java.util.logging.Level; import java.util.logging.Logger; @@ -68,12 +68,27 @@ public class NodeManager implements SynchronousBundleListener, ServiceListener { if (headers.get("SCA-Composite") != null) { return true; } - Enumeration entries = bundle.findEntries("OSGI-INF/sca", "*", false); - if (entries != null && entries.hasMoreElements()) { + + URL bundleComposite = bundle.getResource("OSGI-INF/sca/bundle.composite"); + if (bundleComposite != null) { return true; } + /* FIXME: What if there is a META-INF/sca-contribution.xml? There are two cases: + * 1. The file contains deployable elements + * 2. The file doesn't contain deployable elements + */ + + /* + * FIXME: Do we want to use all of the .composite files under OSGI-INF/sca? + */ + /* + Enumeration entries = bundle.findEntries("OSGI-INF/sca", "bundle.composite", false); + if (entries != null && entries.hasMoreElements()) { + return true; + } + // OSGi Declarative Services if (headers.get("Service-Component") != null) { return true; diff --git a/branches/sca-java-2.0-M3/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java b/branches/sca-java-2.0-M3/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java index 08f962fb0a..79aedc81c4 100644 --- a/branches/sca-java-2.0-M3/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java +++ b/branches/sca-java-2.0-M3/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java @@ -35,15 +35,14 @@ import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; -import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; /** * A launcher for SCA nodes. * * Agruments: * [-config ]: The configuration folder for Equinox + * [-bundles ]: A list of bundles to be installed * [-c ]: The composite URI * [-t ]: Time to live in milliseconds before the node is started * contribution1 ... contributionN: A list of contribution files or URLs @@ -128,6 +127,7 @@ public class NodeLauncher { if (cli.hasOption("config")) { System.setProperty("osgi.configuration.area", cli.getOptionValue("config")); } + while (true) { if (cli.hasOption("node")) { // Create a node from a configuration URI @@ -139,10 +139,28 @@ public class NodeLauncher { equinox = launcher.equinoxHost; node = launcher.createNode(configurationURI); - } else if (cli.hasOption("bundles")) { + } + else if (cli.hasOption("bundles")) { + /** + * osgi.bundles + * The comma-separated list of bundles which are automatically installed and optionally started once the system is up + * and running. Each entry is of the form: + * [@ [] [":start"]] + * If the start-level (>0 integer) is omitted then the framework will use the default start level for the bundle. + * If the "start" tag is added then the bundle will be marked as started after being installed. Simple bundle locations are + * interepreted as relative to the framework's parent directory. The start-level indicates the OSGi start level at which the + * bundle should run. If this value is not set, the system computes an appropriate default. + */ + String bundles = cli.getOptionValue("bundles"); + if (bundles != null) { + System.setProperty("osgi.bundles", cli.getOptionValue("bundles")); + } + // Create a node launcher NodeLauncher launcher = newInstance(); equinox = launcher.equinoxHost; + + /* List bundleFiles = cli.getArgList(); for (String bf : bundleFiles) { File f = new File(bf); @@ -159,8 +177,10 @@ public class NodeLauncher { // logger.log(Level.SEVERE, e.getMessage(), e); } } + */ - } else { + } + else { // Create a node from a composite URI and a contribution location String compositeURI = cli.getOptionValue("composite"); List contribs = cli.getArgList(); @@ -185,6 +205,7 @@ public class NodeLauncher { formatter.printHelp("java " + NodeLauncher.class.getName() + " [-config ]" + " [-c ]" + + " [-b ]" + " [-t ]" + " contribution1 ... contributionN", options); return; -- cgit v1.2.3