You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ro...@apache.org on 2008/05/02 00:25:54 UTC

svn commit: r652694 - in /webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws: catalog/impl/OASISCatalogManager.java description/impl/ServiceDescriptionImpl.java

Author: rott
Date: Thu May  1 15:25:54 2008
New Revision: 652694

URL: http://svn.apache.org/viewvc?rev=652694&view=rev
Log:
top-level WSDL document URLs may be overridden by XMLCatalog.  We now check for, and resolve, the catalog mapping before instantiating the WSDL reader.  Also allow callers to OASISCatalogManager to specify a classloader for loading catalog resource files.

Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java?rev=652694&r1=652693&r2=652694&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java Thu May  1 15:25:54 2008
@@ -43,6 +43,8 @@
     public static final String DEFAULT_CATALOG_WEB = "WEB-INF/jax-ws-catalog.xml";
     public static final String DEFAULT_CATALOG_EJB = "META-INF/jax-ws-catalog.xml";
     public static final String CATALOG_DEBUG_KEY = "OASISCatalogManager.catalog.debug.level";
+    
+    private ClassLoader classloader = null;
 
     private static final Logger LOG =
     	Logger.getLogger(OASISCatalogManager.class.getName());
@@ -66,6 +68,27 @@
     private Catalog staticCatalog = null;
 
     /**
+     * Default constructor with ClassLoader argument.
+     * This constructor will use the defaults specified for Axis2 in the
+     * acceptDefaults method.
+     * @param classLoader
+     */
+    public OASISCatalogManager(ClassLoader classLoader) {
+        this();
+        this.classloader = classLoader;
+    }
+    
+    /**
+     * Constructor that specifies an explicit property file and ClassLoader.
+     * @param classLoader
+     * @param propertyFileName
+     */
+    public OASISCatalogManager(ClassLoader classLoader, String propertyFileName) {
+        this(propertyFileName);
+        this.classloader = classLoader;
+    }
+    
+    /**
      * Default constructor with no arguments.
      * This constructor will use the defaults specified for Axis2 in the
      * acceptDefaults method.
@@ -119,7 +142,7 @@
 
     private String determineFileName() {
 
-        ClassLoader classLoader = findClassLoader();
+        ClassLoader classLoader = (classloader != null) ? classloader : findClassLoader();
         // try web app WEB-INF first
         URL url = classLoader.getResource(DEFAULT_CATALOG_WEB);
         if (url != null) {

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=652694&r1=652693&r2=652694&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Thu May  1 15:25:54 2008
@@ -47,6 +47,7 @@
 import org.apache.axis2.jaxws.util.WSDLWrapper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.xml.resolver.Catalog;
 
 import javax.jws.HandlerChain;
 import javax.wsdl.Definition;
@@ -159,10 +160,12 @@
             log.debug("ServiceDescriptionImpl(URL,QName,Class,DescriptionBuilderComposite,Object)");
         }
     	
-    	if (sparseComposite != null)
+    	if (sparseComposite != null) {
     	    catalogManager = sparseComposite.getCatalogManager();
-    	else
+        }
+    	if (catalogManager == null) {
     		catalogManager = new OASISCatalogManager();
+        }
     	
         if (serviceQName == null) {
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("serviceDescErr0"));
@@ -853,6 +856,8 @@
     /**
      * This method will handle obtaining a URL for the given WSDL location.  The WSDL will be
      * looked for in the following places in this order:
+     * 
+     * PreResolution) check for xmlcatalog resolver
      * 1) As a resource on the classpath
      * 2) As a fully specified URL
      * 3) As a file on the filesystem.  This is analagous to what the generated
@@ -864,6 +869,10 @@
      */
     private URL getWSDLURL(String wsdlLocation) {
         // Look for the WSDL file as follows:
+        // PreResolution) check for xmlcatalog resolver
+        wsdlLocation = resolveWSDLLocationByCatalog(wsdlLocation);
+        
+        
         // 1) As a resource on the classpath
 
         ClassLoader loader = composite.getClassLoader();
@@ -2145,5 +2154,37 @@
     public ResolvedHandlersDescription getResolvedHandlersDescription(PortInfo portInfo) {
         return resolvedHandlersDescription.get(portInfo);
     }
+    
+    private String resolveWSDLLocationByCatalog(String wsdlLocation) {
+        if (catalogManager != null) {
+            Catalog catalog = catalogManager.getCatalog();
+            if (catalog != null) {
+                String resolvedLocation = null;
+                try {
+                    resolvedLocation = catalog.resolveSystem(wsdlLocation);
+                    if (resolvedLocation == null) {
+                        resolvedLocation = catalog.resolveURI(wsdlLocation);
+                    }
+                    // normally, one might also do the following, but in this case we're looking at a top-level WSDL, so no parent
+                    // resolvedLocation = catalog.resolvePublic(wsdlLocation, parent);
+                    if (resolvedLocation != null) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("XMLCatalog transformed original wsdl location \""
+                                    + wsdlLocation
+                                    + "\" to \""
+                                    + resolvedLocation + "\"");
+                        }
+                        return resolvedLocation;
+                    }
+                } catch (Exception e) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Catalog resolution attempt caused exception: "
+                                + e);
+                    }
+                }
+            }
+        }
+        return wsdlLocation;
+    }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org