diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-ws-runtime-axis2')
4 files changed, 70 insertions, 36 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF index 3d336b6fbb..7e15de7cc5 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF @@ -68,8 +68,7 @@ Bundle-ManifestVersion: 2 Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Axis2-based WS Binding Extension
Eclipse-RegisterBuddy: org.apache.axis2.kernel
-Import-Package: com.ctc.wstx.stax,
- javax.activation;resolution:=optional,
+Import-Package: javax.activation;resolution:=optional,
javax.security.auth.callback;resolution:=optional,
javax.servlet,
javax.servlet.http,
@@ -102,8 +101,8 @@ Import-Package: com.ctc.wstx.stax, org.apache.axis2.transport,
org.apache.axis2.transport.http,
org.apache.axis2.transport.http.server,
- org.apache.axis2.transport.local,
org.apache.axis2.transport.jms,
+ org.apache.axis2.transport.local,
org.apache.axis2.util,
org.apache.axis2.util.threadpool,
org.apache.commons.httpclient,
@@ -111,7 +110,7 @@ Import-Package: com.ctc.wstx.stax, org.apache.commons.logging;resolution:=optional,
org.apache.neethi,
org.apache.tuscany.sca.assembly;version="2.0.0",
- org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
org.apache.tuscany.sca.binding.ws;version="2.0.0",
org.apache.tuscany.sca.common.xml;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
@@ -128,8 +127,8 @@ Import-Package: com.ctc.wstx.stax, org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
org.apache.tuscany.sca.invocation;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
- org.apache.tuscany.sca.policy.security;version="2.0.0",
org.apache.tuscany.sca.policy.authentication.basic;version="2.0.0",
+ org.apache.tuscany.sca.policy.security;version="2.0.0",
org.apache.tuscany.sca.policy.security.http.ssl;version="2.0.0",
org.apache.tuscany.sca.policy.util;version="2.0.0",
org.apache.tuscany.sca.provider;version="2.0.0",
@@ -140,7 +139,6 @@ Import-Package: com.ctc.wstx.stax, org.apache.ws.commons.schema.resolver,
org.apache.ws.security,
org.apache.ws.security.handler,
- org.apache.xerces.jaxp,
org.oasisopen.sca;version="2.0.0",
org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
org.w3c.dom,
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java index 73fc18a4a6..aa3e04a836 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java @@ -39,6 +39,8 @@ 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.axis2.AxisFault; import org.apache.axis2.Constants; @@ -59,11 +61,11 @@ import org.apache.axis2.description.WSDLToAxisServiceBuilder; import org.apache.axis2.engine.MessageReceiver; import org.apache.axis2.transport.local.LocalResponder; import org.apache.tuscany.sca.assembly.AbstractContract; - import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.common.xml.XMLDocumentHelper; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.extensibility.ClassLoaderContext; +import org.apache.tuscany.sca.extensibility.ServiceDiscovery; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; @@ -73,15 +75,12 @@ import org.apache.tuscany.sca.xsd.XSDefinition; import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaExternal; import org.apache.ws.commons.schema.resolver.URIResolver; -import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; import org.oasisopen.sca.ServiceRuntimeException; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import com.ctc.wstx.stax.WstxInputFactory; - public class Axis2EngineIntegration { @@ -119,32 +118,70 @@ public class Axis2EngineIntegration { /* * Create the whole configuration context for the Axis engine */ - public static ConfigurationContext getAxisConfigurationContext(){ - ConfigurationContext configContext = null; + private static class Axis2Config { + private ClassLoaderContext classLoaderContext; + private URL axis2xmlURL; + private URL repositoryURL; + } + + // Cache the discovered axis2 configuration but we need to create a new instance of ConfigurationContext every time + private static Axis2Config axis2Config; + + public synchronized static ConfigurationContext getAxisConfigurationContext(final ServiceDiscovery serviceDiscovery) { + // get the axis configuration context from the Tuscany axis2.xml file // Allow privileged access to read properties. Requires PropertyPermission read in // security policy. - try { - configContext = AccessController.doPrivileged(new PrivilegedExceptionAction<ConfigurationContext>() { - public ConfigurationContext run() throws AxisFault, MalformedURLException { - // collect together the classloaders that Axis2 requireds in order to load - // pluggable items such as the Tuscany MessageReceivers and the xerces - // document builder. - ClassLoader wsBindingCL = getClass().getClassLoader(); - ClassLoader axis2CL = URLBasedAxisConfigurator.class.getClassLoader(); - ClassLoader xercesCL = DocumentBuilderFactoryImpl.class.getClassLoader(); - ClassLoader wstxCL = WstxInputFactory.class.getClassLoader(); - ClassLoader localtransportCL = LocalResponder.class.getClassLoader(); - ClassLoader oldTCCL = ClassLoaderContext.setContextClassLoader(wsBindingCL, axis2CL, xercesCL, wstxCL, localtransportCL); - - try { - URL axis2xmlURL = wsBindingCL.getResource("org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml"); - if (axis2xmlURL != null){ - URL repositoryURL = new URL(axis2xmlURL.toExternalForm().replaceFirst("conf/tuscany-axis2.xml", "repository/")); - return ConfigurationContextFactory.createConfigurationContextFromURIs(axis2xmlURL, repositoryURL); + if (axis2Config == null) { + try { + axis2Config = AccessController.doPrivileged(new PrivilegedExceptionAction<Axis2Config>() { + public Axis2Config run() throws AxisFault, MalformedURLException { + // collect together the classloaders that Axis2 requireds in order to load + // pluggable items such as the Tuscany MessageReceivers and the xerces + // document builder. + ClassLoader wsBindingCL = getClass().getClassLoader(); + ClassLoader axis2CL = URLBasedAxisConfigurator.class.getClassLoader(); + ClassLoader localtransportCL = LocalResponder.class.getClassLoader(); + ClassLoaderContext classLoaderContext = + new ClassLoaderContext(wsBindingCL, axis2CL, localtransportCL); + + classLoaderContext = + new ClassLoaderContext(classLoaderContext.getClassLoader(), serviceDiscovery, + XMLInputFactory.class, DocumentBuilderFactory.class); + + URL axis2xmlURL = + wsBindingCL + .getResource("org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml"); + if (axis2xmlURL != null) { + URL repositoryURL = new URL(axis2xmlURL, "../repository/"); + Axis2Config config = new Axis2Config(); + config.classLoaderContext = classLoaderContext; + config.axis2xmlURL = axis2xmlURL; + config.repositoryURL = repositoryURL; + return config; } else { return null; } + } + }); + } catch (PrivilegedActionException e) { + throw new ServiceRuntimeException(e.getException()); + } + } + + if (axis2Config == null) { + return null; + } + + try { + return AccessController.doPrivileged(new PrivilegedExceptionAction<ConfigurationContext>() { + public ConfigurationContext run() throws AxisFault { + ClassLoader oldTCCL = axis2Config.classLoaderContext.setContextClassLoader(); + try { + ConfigurationContext configurationContext = + ConfigurationContextFactory.createConfigurationContextFromURIs(axis2Config.axis2xmlURL, + axis2Config.repositoryURL); + return configurationContext; } finally { if (oldTCCL != null) { Thread.currentThread().setContextClassLoader(oldTCCL); @@ -154,9 +191,8 @@ public class Axis2EngineIntegration { }); } catch (PrivilegedActionException e) { throw new ServiceRuntimeException(e.getException()); - } - - return configContext; + } + } //========================================================= diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java index 4369953f78..f427154c92 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java @@ -54,8 +54,8 @@ import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; import org.apache.commons.httpclient.params.HttpConnectionManagerParams; import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.binding.ws.axis2.transport.TransportReferenceInterceptor; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.axis2.transport.TransportReferenceInterceptor; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; @@ -125,7 +125,7 @@ public class Axis2ReferenceBindingProvider extends Axis2BaseBindingProvider impl } public void start() { - configContext = Axis2EngineIntegration.getAxisConfigurationContext(); + configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery()); try { Definition definition = wsBinding.getWSDLDocument(); diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java index 5772360575..589d3881c0 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java @@ -96,7 +96,7 @@ public class Axis2ServiceBindingProvider extends Axis2BaseBindingProvider implem contract = wsBinding.getBindingInterfaceContract(); contract.getInterface().resetDataBinding(OMElement.class.getName()); - configContext = Axis2EngineIntegration.getAxisConfigurationContext(); + configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery()); // set the root context for this instance of Axis configContext.setContextRoot(servletHost.getContextPath()); |