You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2010/03/04 01:41:03 UTC

svn commit: r918795 - in /tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2: META-INF/ src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/

Author: rfeng
Date: Thu Mar  4 00:41:02 2010
New Revision: 918795

URL: http://svn.apache.org/viewvc?rev=918795&view=rev
Log:
Clean up the hard-dependency on impl class of XMLInputFactory and DocumentBuilderFactory
Cache the discovered axis2 xml (TODO: we need to see how we can improve the performance for the axis2 configuration loading)

Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java
    tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
    tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF?rev=918795&r1=918794&r2=918795&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF Thu Mar  4 00:41:02 2010
@@ -68,8 +68,7 @@
 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 @@
  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 @@
  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 @@
  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 @@
  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,

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java?rev=918795&r1=918794&r2=918795&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java Thu Mar  4 00:41:02 2010
@@ -39,6 +39,8 @@
 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.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.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 @@
     /*
      * 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 @@
             });
         } catch (PrivilegedActionException e) {
             throw new ServiceRuntimeException(e.getException());
-        } 
-        
-        return configContext;
+        }
+
     }
     
     //=========================================================  

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java?rev=918795&r1=918794&r2=918795&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java Thu Mar  4 00:41:02 2010
@@ -54,8 +54,8 @@
 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 void start() {
-        configContext = Axis2EngineIntegration.getAxisConfigurationContext();
+        configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery());
         
         try {
             Definition definition = wsBinding.getWSDLDocument();

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java?rev=918795&r1=918794&r2=918795&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java Thu Mar  4 00:41:02 2010
@@ -96,7 +96,7 @@
         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());



Re: svn commit: r918795 - in /tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2: META-INF/ src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/

Posted by ant elder <an...@gmail.com>.
Ok guess i'll just go try and do it and see what happens.

   ...ant

On Thu, Dec 9, 2010 at 10:31 AM, ant elder <an...@gmail.com> wrote:
> Bit of an old one, do you remember if there were any issues with the
> rampart part of this? Presently theres now a message output about
> rampart being loaded for every WS request which can mess up the
> console log so it would be good to get the only using rampart when
> needed going again. Do you think i'm likely to hit any blockers if i
> try to do that?
>
>   ...ant
>
> On Thu, Mar 4, 2010 at 8:55 AM, Simon Laws <si...@googlemail.com> wrote:
>> Right, I backed out the previous "optimizations" of, for example, only
>> loading rampart on demand as they were mired in TODOs realated to old
>> Axis versions. It maybe that we'll have to put some of that back in.
>>
>> Simon
>>
>

Re: svn commit: r918795 - in /tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2: META-INF/ src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/

Posted by ant elder <an...@gmail.com>.
Bit of an old one, do you remember if there were any issues with the
rampart part of this? Presently theres now a message output about
rampart being loaded for every WS request which can mess up the
console log so it would be good to get the only using rampart when
needed going again. Do you think i'm likely to hit any blockers if i
try to do that?

   ...ant

On Thu, Mar 4, 2010 at 8:55 AM, Simon Laws <si...@googlemail.com> wrote:
> Right, I backed out the previous "optimizations" of, for example, only
> loading rampart on demand as they were mired in TODOs realated to old
> Axis versions. It maybe that we'll have to put some of that back in.
>
> Simon
>

Re: svn commit: r918795 - in /tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2: META-INF/ src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/

Posted by Simon Laws <si...@googlemail.com>.
Right, I backed out the previous "optimizations" of, for example, only
loading rampart on demand as they were mired in TODOs realated to old
Axis versions. It maybe that we'll have to put some of that back in.

Simon