Author: scheu
Date: Mon Jul 19 21:22:58 2010
New Revision: 965641

URL: http://svn.apache.org/viewvc?rev=965641&view=rev
Log:
AXIS2-4782
Contributor:Rich Scheuerle
Small change to the algorithm to determine if a reloadable WSDL implementation 
should be used.

Modified:
    
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLDefinitionWrapper.java
    
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLWrapperReloadImpl.java

Modified: 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLDefinitionWrapper.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLDefinitionWrapper.java?rev=965641&r1=965640&r2=965641&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLDefinitionWrapper.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLDefinitionWrapper.java
 Mon Jul 19 21:22:58 2010
@@ -267,11 +267,22 @@ public class WSDLDefinitionWrapper imple
             // otherwise, default to the serialization technique
 
             if (reduceWSDLMemoryType == 2) {
-                // a wrapper implementation that uses release & reload on the 
-                // underlying WSDL4J object
-                // this would be desirable for those environments where 
-                // many of the WSDL definitions are not serializable 
-                wrapperImpl = new WSDLWrapperReloadImpl(def, wURL);
+                
+                // See if the definition is reloadable
+                if (WSDLWrapperReloadImpl.isReloadable(def, wURL)) {
+                    // a wrapper implementation that uses release & reload on 
the 
+                    // underlying WSDL4J object
+                    // this would be desirable for those environments where 
+                    // many of the WSDL definitions are not serializable 
+                    wrapperImpl = new WSDLWrapperReloadImpl(def, wURL);
+                } else {
+                    // a wrapper implementation that is just a passthrough to 
the 
+                    // underlying WSDL4J object
+                    if (log.isDebugEnabled() ) {
+                        log.debug("WSDLDefinitionWrapper could not create a 
reloadable WSDL wrapper object.");
+                    }
+                    wrapperImpl = new WSDLWrapperBasicImpl(def, wURL);
+                }
             }
             else {
                 // a wrapper implementation that uses serialization to save 
the  

Modified: 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLWrapperReloadImpl.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLWrapperReloadImpl.java?rev=965641&r1=965640&r2=965641&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLWrapperReloadImpl.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/wsdl/util/WSDLWrapperReloadImpl.java
 Mon Jul 19 21:22:58 2010
@@ -133,6 +133,49 @@ public class WSDLWrapperReloadImpl imple
         }
         prepare(def, wURL);
     }
+    
+    public static boolean isReloadable(Definition def, URL wURL) {
+        if (isDebugEnabled) {
+            log.debug("Enter " + myClassName + ".isReloadable(): " + wURL);
+        }
+        String explicitURI = null;
+        if (def != null) {
+            try {
+                String documentBaseURI = def.getDocumentBaseURI();
+
+                // build up the wURL if possible
+                if ((wURL == null) && (documentBaseURI != null)) {
+                    wURL = new URL(documentBaseURI);
+                }
+
+                // get the explicit location of the wsdl if possible
+                if (wURL != null) {
+                    explicitURI = getExplicitURI(wURL);
+                }
+
+                
+            } catch (Exception e) {
+                if (isDebugEnabled) {
+                    log.debug(myClassName + ".isReloaded(): ["
+                            + e.getClass().getName() + "]  error [" + 
e.getMessage() + "]", e);
+                    log.debug("Processing continues.");
+                }
+            }
+        }
+        
+        // Return true if explicitURI is available
+        if (isDebugEnabled) {
+            log.debug(" explicitURI=" + explicitURI);
+        }
+        boolean rc = explicitURI != null && explicitURI.length() > 0;
+        
+        if (isDebugEnabled) {
+            log.debug("Exit " + myClassName + ".isReloadable(): " + rc);
+        }
+        
+        return rc;
+        
+    }
 
 
     /**
@@ -1222,7 +1265,7 @@ public class WSDLWrapperReloadImpl imple
     //-------------------------------------------------------------------------
 
 
-    private String getExplicitURI(URL wsdlURL) throws WSDLException {
+    private static String getExplicitURI(URL wsdlURL) throws WSDLException {
 
         if (isDebugEnabled) {
             log.debug(myClassName + ".getExplicitURI(" + wsdlURL + ") ");
@@ -1264,7 +1307,7 @@ public class WSDLWrapperReloadImpl imple
 
                     // Lets read the complete WSDL URL for relative path from 
class loader
                     // Use relative path of url to fetch complete URL.         
     
-                    url = getAbsoluteURL(classLoader, filePath);
+                    url = getAbsoluteURL(classLoader, filePath, wsdlURL);
 
                     if (url == null) {
                         if (isDebugEnabled) {
@@ -1308,7 +1351,7 @@ public class WSDLWrapperReloadImpl imple
 
                 if (filePath != null) {
 
-                    url = getAbsoluteURL(classLoader, filePath);
+                    url = getAbsoluteURL(classLoader, filePath, wsdlURL);
                     if (url == null) {
                         if (log.isDebugEnabled()) {
                             log.debug("Could not locate URL for wsdl. 
Reporting error");
@@ -1343,7 +1386,7 @@ public class WSDLWrapperReloadImpl imple
     }
 
 
-    private URL getAbsoluteURL(final ClassLoader classLoader, final String 
filePath) throws WSDLException {
+    private static URL getAbsoluteURL(final ClassLoader classLoader, final 
String filePath, URL wURL) throws WSDLException {
         URL url = (URL) AccessController.doPrivileged(
                 new PrivilegedAction() {
                     public Object run() {
@@ -1357,7 +1400,7 @@ public class WSDLWrapperReloadImpl imple
             }
             if (classLoader instanceof URLClassLoader) {
                 URLClassLoader urlLoader = (URLClassLoader) classLoader;
-                url = getURLFromJAR(urlLoader, wsdlURL);
+                url = getURLFromJAR(urlLoader, wURL);
             }
         }
         return url;
@@ -1402,7 +1445,7 @@ public class WSDLWrapperReloadImpl imple
         return def;
     }
 
-    private URL getURLFromJAR(URLClassLoader urlLoader, URL relativeURL) 
throws WSDLException {
+    private static URL getURLFromJAR(URLClassLoader urlLoader, URL 
relativeURL) throws WSDLException {
 
         URL[] urlList = urlLoader.getURLs();
 
@@ -1493,7 +1536,7 @@ public class WSDLWrapperReloadImpl imple
      * may be an instance of a FileURLConnection object which would require 
access 
      * permissions if Java2 Security was enabled.
      */
-    private InputStream getInputStream(URLConnection urlCon) throws Exception {
+    private static InputStream getInputStream(URLConnection urlCon) throws 
Exception {
        final URLConnection finalURLCon = urlCon;
        InputStream is = null;
        try {


Reply via email to