diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-13 19:25:51 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-13 19:25:51 +0000 |
commit | 3fee48a0cb04ca9bf57fabe3846a15d7ce0f3232 (patch) | |
tree | 835fdaa819a0accbf140ee007ca4a623cc555eaa /java/sca/modules | |
parent | 9ef6d7751c4c1e219a01376a842935a50aa05c18 (diff) |
Add exclusion of axis2-adb to avoid split packages
Add TCCL to work around XMLInputFactory.newInstance call made by Axis2 which is not OSGi-friendly
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@764571 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
3 files changed, 28 insertions, 11 deletions
diff --git a/java/sca/modules/binding-ws-axis2/pom.xml b/java/sca/modules/binding-ws-axis2/pom.xml index 41d17ce0cf..8ab98ba2d7 100644 --- a/java/sca/modules/binding-ws-axis2/pom.xml +++ b/java/sca/modules/binding-ws-axis2/pom.xml @@ -178,6 +178,10 @@ <scope>runtime</scope> <exclusions> <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-adb</artifactId> + </exclusion> + <exclusion> <groupId>stax</groupId> <artifactId>stax-api</artifactId> </exclusion> diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java index 8aa2181c22..a3277a39e3 100644 --- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java +++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.binding.ws.axis2; +import javax.xml.stream.XMLInputFactory; + import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.core.FactoryExtensionPoint; @@ -58,7 +60,9 @@ public class Axis2ServiceBindingProvider implements ServiceBindingProvider { InterfaceContract contract = wsBinding.getBindingInterfaceContract(); contract.getInterface().resetDataBinding(OMElement.class.getName()); - axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory); + // Pass in the XMLInputFactory to work around the Axis2 way of loading XMLInputFactory + XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); + axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory, inputFactory); } public void start() { 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 dd58b39a1c..e1ba92c3d4 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 @@ -43,6 +43,7 @@ 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.stream.XMLInputFactory; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; @@ -161,7 +162,8 @@ public class Axis2ServiceProvider { AbstractContract contract, WebServiceBinding wsBinding, ServletHost servletHost, - MessageFactory messageFactory) { + MessageFactory messageFactory, + final XMLInputFactory xmlInputFactory) { this.component = component; this.contract = contract; @@ -174,20 +176,27 @@ public class Axis2ServiceProvider { // TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(); // Allow privileged access to read properties. Requires PropertyPermission read in // security policy. - TuscanyAxisConfigurator tuscanyAxisConfigurator = - AccessController.doPrivileged(new PrivilegedExceptionAction<TuscanyAxisConfigurator>() { - public TuscanyAxisConfigurator run() throws AxisFault { - return new TuscanyAxisConfigurator(isRampartRequired); + configContext = AccessController.doPrivileged(new PrivilegedExceptionAction<ConfigurationContext>() { + public ConfigurationContext run() throws AxisFault { + ClassLoader newTccl = xmlInputFactory.getClass().getClassLoader(); + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + if (newTccl != null && newTccl != tccl) { + Thread.currentThread().setContextClassLoader(newTccl); } - }); - configContext = tuscanyAxisConfigurator.getConfigurationContext(); + try { + return new TuscanyAxisConfigurator(isRampartRequired).getConfigurationContext(); + } finally { + if (newTccl != null && newTccl != tccl) { + Thread.currentThread().setContextClassLoader(tccl); + } + } + } + }); // deployRampartModule(); // configureSecurity(); } catch (PrivilegedActionException e) { throw new ServiceRuntimeException(e.getException()); - } catch (AxisFault e) { - throw new ServiceRuntimeException(e); // TODO: better exception - } + } configContext.setContextRoot(servletHost.getContextPath()); |