geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r735186 - in /geronimo/server/trunk/plugins: axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/ axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/po...
Date Sat, 17 Jan 2009 00:20:59 GMT
Author: gawor
Date: Fri Jan 16 16:20:58 2009
New Revision: 735186

URL: http://svn.apache.org/viewvc?rev=735186&view=rev
Log:
Support OASIS catalogs with Axis2 (GERONIMO-4501)

Added:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/util/CatalogWSDLLocator.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
    geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBWebServiceGBean.java
    geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFCatalogUtils.java
    geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java?rev=735186&r1=735185&r2=735186&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
Fri Jan 16 16:20:58 2009
@@ -30,6 +30,7 @@
 import org.apache.geronimo.axis2.AxisServiceGenerator;
 import org.apache.geronimo.axis2.GeronimoFactoryRegistry;
 import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
+import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.JNDIResolver;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.openejb.DeploymentInfo;
@@ -86,6 +87,7 @@
     @Override
     protected AxisServiceGenerator createServiceGenerator() {
         AxisServiceGenerator serviceGenerator = super.createServiceGenerator();
+        serviceGenerator.setCatalogName(JAXWSUtils.DEFAULT_CATALOG_EJB);
         EJBMessageReceiver messageReceiver = 
             new EJBMessageReceiver(this, this.endpointClass, this.deploymnetInfo);
         serviceGenerator.setMessageReceiver(messageReceiver);

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java?rev=735186&r1=735185&r2=735186&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
Fri Jan 16 16:20:58 2009
@@ -17,8 +17,6 @@
 
 package org.apache.geronimo.axis2;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashMap;
@@ -29,12 +27,9 @@
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
-import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.http.HTTPBinding;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap12.SOAP12Binding;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebServiceException;
 
@@ -45,6 +40,7 @@
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
 import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.jaxws.catalog.impl.OASISCatalogManager;
 import org.apache.axis2.jaxws.description.DescriptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
@@ -56,8 +52,8 @@
 import org.apache.axis2.jaxws.description.builder.WsdlGenerator;
 import org.apache.axis2.jaxws.description.builder.converter.JavaClassToDBCConverter;
 import org.apache.axis2.jaxws.server.JAXWSMessageReceiver;
+import org.apache.axis2.jaxws.util.WSDL4JWrapper;
 import org.apache.axis2.wsdl.WSDLUtil;
-import org.apache.geronimo.axis2.util.SimpleWSDLLocator;
 import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
@@ -73,6 +69,7 @@
 
     private MessageReceiver messageReceiver;
     private ConfigurationContext configurationContext;
+    private String catalogName;
     
     public AxisServiceGenerator(){
         this.messageReceiver = new JAXWSMessageReceiver();
@@ -86,6 +83,10 @@
         this.configurationContext = configurationContext;
     }
     
+    public void setCatalogName(String catalogName) {
+        this.catalogName = catalogName;
+    }
+    
     public AxisService getServiceFromClass(Class endpointClass) throws Exception {
         ServiceDescription serviceDescription = 
             DescriptionFactory.createServiceDescription(endpointClass);        
@@ -138,7 +139,14 @@
             portQName = JAXWSUtils.getPortQName(endpointClass);
         }
                 
-        Definition wsdlDefinition = readWSDL(wsdlFile, configurationBaseUrl, classLoader);
+        OASISCatalogManager catalogManager = new OASISCatalogManager();
+        URL catalogURL = JAXWSUtils.getOASISCatalogURL(configurationBaseUrl, classLoader,
this.catalogName);
+        if (catalogURL != null) {
+            catalogManager.setCatalogFiles(catalogURL.toString());
+        }
+        URL wsdlURL = getWsdlURL(wsdlFile, configurationBaseUrl, classLoader);
+        WSDL4JWrapper wsdlWrapper = new WSDL4JWrapper(wsdlURL, this.configurationContext,
catalogManager);
+        Definition wsdlDefinition = wsdlWrapper.getDefinition(); 
         
         Service wsdlService = wsdlDefinition.getService(serviceQName);
         if (wsdlService == null) {
@@ -166,6 +174,7 @@
         dbc.setWsdlDefinition(wsdlDefinition);
         dbc.setClassName(endpointClassName);
         dbc.setCustomWsdlGenerator(new WSDLGeneratorImpl(wsdlDefinition));
+        dbc.setCatalogManager(catalogManager);
         
         if (dbc.getWebServiceAnnot() != null) { //information specified in .wsdl should overwrite
annotation.
             WebServiceAnnot serviceAnnot = dbc.getWebServiceAnnot();
@@ -290,30 +299,7 @@
             return composite;
         }
     }
-    
-    protected Definition readWSDL(String wsdlLocation, 
-                                  URL configurationBaseUrl, 
-                                  ClassLoader classLoader)
-        throws IOException, WSDLException {
-        Definition wsdlDefinition = null;
-        URL wsdlURL = getWsdlURL(wsdlLocation, configurationBaseUrl, classLoader);
-        InputStream wsdlStream = null;
-        try {
-            wsdlStream = wsdlURL.openStream();
-            WSDLFactory factory = WSDLFactory.newInstance();
-            WSDLReader reader = factory.newWSDLReader();
-            reader.setFeature("javax.wsdl.importDocuments", true);
-            reader.setFeature("javax.wsdl.verbose", false);
-            SimpleWSDLLocator wsdlLocator = new SimpleWSDLLocator(wsdlURL.toString());
-            wsdlDefinition = reader.readWSDL(wsdlLocator);
-        } finally {
-            if (wsdlStream != null) {
-                wsdlStream.close();
-            }
-        }
-        return wsdlDefinition;
-    }
-    
+        
     public static URL getWsdlURL(String wsdlFile, URL configurationBaseUrl, ClassLoader classLoader)
{
         URL wsdlURL = null;
         if (wsdlFile != null) {
@@ -336,7 +322,7 @@
         }
         return wsdlURL;
     }
-    
+        
     public static EndpointDescription getEndpointDescription(AxisService service) {
         Parameter param = service.getParameter(EndpointDescription.AXIS_SERVICE_PARAMETER);
         return (param == null) ? null : (EndpointDescription) param.getValue();

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java?rev=735186&r1=735185&r2=735186&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java
Fri Jan 16 16:20:58 2009
@@ -21,16 +21,15 @@
 
 import java.io.FileNotFoundException;
 import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Import;
 import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.extensions.schema.SchemaImport;
@@ -47,74 +46,76 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.catalog.JAXWSCatalogManager;
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.geronimo.axis2.util.CatalogWSDLLocator;
 import org.apache.geronimo.jaxws.WSDLUtils;
+import org.apache.xml.resolver.Catalog;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-public class WSDLQueryHandler
-{
+public class WSDLQueryHandler {
+
     private static final Logger LOG = LoggerFactory.getLogger(WSDLQueryHandler.class);
     
-    private Map<String, Definition> mp = new ConcurrentHashMap<String, Definition>();
-    private Map<String, SchemaReference> smp = new ConcurrentHashMap<String, SchemaReference>();
+    private Map<String, Definition> wsdlMap;
+    private Map<String, SchemaReference> schemaMap;
+    private Map<String, String> keyMap;
+    private int wsdlCounter;
+    private int schemaCounter;
     private AxisService service;
+    private Catalog catalog;    
     
     public WSDLQueryHandler(AxisService service) {
         this.service = service;
+        EndpointDescription ed = AxisServiceGenerator.getEndpointDescription(this.service);
+        JAXWSCatalogManager catalogManager = ed.getServiceDescription().getCatalogManager();
+        if (catalogManager != null) {
+            this.catalog = catalogManager.getCatalog();
+        }
     }
     
     public void writeResponse(String baseUri, String wsdlUri, OutputStream os) throws Exception
{
 
         String base = null;
-        String wsdl = "";
-        String xsd = null;
+        String wsdlKey = "";
+        String xsdKey = null;
         
         int idx = baseUri.toLowerCase().indexOf("?wsdl");
         if (idx != -1) {
             base = baseUri.substring(0, idx);
-            wsdl = baseUri.substring(idx + 5);
-            if (wsdl.length() > 0) {
-                wsdl = wsdl.substring(1);
+            wsdlKey = baseUri.substring(idx + 5);
+            if (wsdlKey.length() > 0) {
+                wsdlKey = wsdlKey.substring(1);
             }
         } else {
             idx = baseUri.toLowerCase().indexOf("?xsd");
             if (idx != -1) {
                 base = baseUri.substring(0, idx);
-                xsd = baseUri.substring(idx + 4);
-                if (xsd.length() > 0) {
-                    xsd = xsd.substring(1);
+                xsdKey = baseUri.substring(idx + 4);
+                if (xsdKey.length() > 0) {
+                    xsdKey = xsdKey.substring(1);
                 }
             } else {
                 throw new Exception("Invalid request: " + baseUri);
             }
         }
 
-        if (!mp.containsKey(wsdl)) {
-            WSDLFactory factory = WSDLFactory.newInstance();
-            WSDLReader reader = factory.newWSDLReader();
-            reader.setFeature("javax.wsdl.importDocuments", true);
-            reader.setFeature("javax.wsdl.verbose", false);
-            Definition def = reader.readWSDL(wsdlUri);
-            updateDefinition(def, mp, smp, base);
-            // remove other services and ports from wsdl
-            WSDLUtils.trimDefinition(def, this.service.getName(), this.service.getEndpointName());
-            mp.put("", def);
-        }
+        init(wsdlUri, base);
 
         Element rootElement;
-
-        if (xsd == null) {
-            Definition def = mp.get(wsdl);
+        if (xsdKey == null) {
+            Definition def = wsdlMap.get(wsdlKey);
 
             if (def == null) {
-                throw new FileNotFoundException("WSDL not found: " + wsdl);
+                throw new FileNotFoundException("WSDL not found: " + wsdlKey);
             }
-            
+
             // update service port location on each request
-            if (wsdl.equals("")) {
+            if (wsdlKey.equals("")) {
                 WSDLUtils.updateLocations(def, base);
             }
             
@@ -122,117 +123,148 @@
             WSDLWriter writer = factory.newWSDLWriter();
 
             rootElement = writer.getDocument(def).getDocumentElement();
+            
+            updateWSDLImports(rootElement, base, wsdlKey);
+            updateSchemaImports(rootElement, base, wsdlKey);
         } else {
-            SchemaReference si = smp.get(xsd);
+            SchemaReference si = schemaMap.get(xsdKey);
             
             if (si == null) {
-                throw new FileNotFoundException("Schema not found: " + xsd);
+                throw new FileNotFoundException("Schema not found: " + xsdKey);
             }
             
             rootElement = si.getReferencedSchema().getElement();
+            
+            updateSchemaImports(rootElement, base, xsdKey);
         }
+                
+        writeTo(rootElement, os);
+    }
 
-        NodeList nl = rootElement.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema",
-                "import");
+    private synchronized void init(String wsdlUri, String base) throws WSDLException {
+        if (keyMap == null) {
+            wsdlMap = new HashMap<String, Definition>();
+            schemaMap = new HashMap<String, SchemaReference>();
+            keyMap = new HashMap<String, String>();
+            
+            WSDLFactory factory = WSDLFactory.newInstance();
+            WSDLReader reader = factory.newWSDLReader();
+            reader.setFeature("javax.wsdl.importDocuments", true);
+            reader.setFeature("javax.wsdl.verbose", false);            
+            Definition def = reader.readWSDL(new CatalogWSDLLocator(wsdlUri, this.catalog));
+            updateDefinition("", def, base);
+            // remove other services and ports from wsdl
+            WSDLUtils.trimDefinition(def, this.service.getName(), this.service.getEndpointName());
+            
+            wsdlMap.put("", def);
+        }
+    }
+
+    private void updateWSDLImports(Element rootElement, String base, String parentKey) {
+        NodeList nl = rootElement.getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/",
"import");        
         for (int x = 0; x < nl.getLength(); x++) {
             Element el = (Element) nl.item(x);
-            String sl = el.getAttribute("schemaLocation");
-            if (smp.containsKey(sl)) {
-                el.setAttribute("schemaLocation", base + "?xsd=" + sl);
+            String location = el.getAttribute("location");
+            String id = parentKey + "/" + location;
+            String key = keyMap.get(id);
+            if (key != null) {
+                el.setAttribute("location", base + "?wsdl=" + key);
             }
         }
-        nl = rootElement.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "include");
+    }
+
+    private void updateSchemaImports(Element rootElement, String base, String parentKey)
{
+        NodeList nl = rootElement.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema",
"import");
         for (int x = 0; x < nl.getLength(); x++) {
             Element el = (Element) nl.item(x);
-            String sl = el.getAttribute("schemaLocation");
-            if (smp.containsKey(sl)) {
-                el.setAttribute("schemaLocation", base + "?xsd=" + sl);
+            String location = el.getAttribute("schemaLocation");
+            String id = parentKey + "/" + location;
+            String key = keyMap.get(id);
+            if (key != null) {
+                el.setAttribute("schemaLocation", base + "?xsd=" + key);
             }
         }
-        nl = rootElement.getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "import");
+        
+        nl = rootElement.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "include");
         for (int x = 0; x < nl.getLength(); x++) {
             Element el = (Element) nl.item(x);
-            String sl = el.getAttribute("location");
-            if (mp.containsKey(sl)) {
-                el.setAttribute("location", base + "?wsdl=" + sl);
+            String location = el.getAttribute("schemaLocation");
+            String id = parentKey + "/" + location;
+            String key = keyMap.get(id);
+            if (key != null) {
+                el.setAttribute("schemaLocation", base + "?xsd=" + key);
             }
         }
-
-        writeTo(rootElement, os);
     }
        
-    protected void updateDefinition(Definition def,
-                                    Map<String, Definition> done,
-                                    Map<String, SchemaReference> doneSchemas,
+    protected void updateDefinition(String parentKey,
+                                    Definition def,
                                     String base) {
         Collection<List> imports = def.getImports().values();
         for (List lst : imports) {
             List<Import> impLst = lst;
             for (Import imp : impLst) {
-                String start = imp.getLocationURI();
-                try {
-                    //check to see if it's aleady in a URL format.  If so, leave it.
-                    new URL(start);
-                } catch (MalformedURLException e) {
-                    done.put(start, imp.getDefinition());
-                    updateDefinition(imp.getDefinition(), done, doneSchemas, base);
+                String location = imp.getLocationURI();                
+                String id = parentKey + "/" + location;                   
+                if (!keyMap.containsKey(id)) {
+                    String key = getUniqueWSDLId();
+                    wsdlMap.put(key, imp.getDefinition());
+                    keyMap.put(id, key);
+                    updateDefinition(key, imp.getDefinition(), base);
                 }
             }
         }      
-        
-        
-        /* This doesn't actually work.   Setting setSchemaLocationURI on the import
-        * for some reason doesn't actually result in the new URI being written
-        * */
+               
         Types types = def.getTypes();
         if (types != null) {
             for (ExtensibilityElement el : (List<ExtensibilityElement>)types.getExtensibilityElements())
{
                 if (el instanceof Schema) {
-                    Schema see = (Schema)el;
-                    updateSchemaImports(see, doneSchemas, base);
+                    Schema schema = (Schema)el;
+                    updateSchemaImports(parentKey, schema, base);
                 }
             }
         }
     }
     
-    protected void updateSchemaImports(Schema schema,
-                                       Map<String, SchemaReference> doneSchemas,
+    protected void updateSchemaImports(String parentKey, 
+                                       Schema schema,
                                        String base) {
-        Collection<List>  imports = schema.getImports().values();
-        for (List lst : imports) {
-            List<SchemaImport> impLst = lst;
-            for (SchemaImport imp : impLst) {
-                String start = imp.getSchemaLocationURI();
-                if (start != null) {
-                    try {
-                        //check to see if it's aleady in a URL format.  If so, leave it.
-                        new URL(start);
-                    } catch (MalformedURLException e) {
-                        if (!doneSchemas.containsKey(start)) {
-                            doneSchemas.put(start, imp);
-                            updateSchemaImports(imp.getReferencedSchema(), doneSchemas, base);
-                        }
-                    }
-                }
+        Collection<List> imports = schema.getImports().values();
+        for (List list : imports) {
+            List<SchemaImport> impList = list;
+            for (SchemaImport imp : impList) {
+                String location = imp.getSchemaLocationURI();                           
    
+                String id = parentKey + "/" + location;
+                if (!keyMap.containsKey(id)) {
+                    String key = getUniqueSchemaId();
+                    schemaMap.put(key, imp);
+                    keyMap.put(id, key);
+                    updateSchemaImports(key, imp.getReferencedSchema(), base);
+                }                    
             }
         }
+        
         List<SchemaReference> includes = schema.getIncludes();
         for (SchemaReference included : includes) {
-            String start = included.getSchemaLocationURI();
-            if (start != null) {
-                try {
-                    //check to see if it's aleady in a URL format.  If so, leave it.
-                    new URL(start);
-                } catch (MalformedURLException e) {
-                    if (!doneSchemas.containsKey(start)) {
-                        doneSchemas.put(start, included);
-                        updateSchemaImports(included.getReferencedSchema(), doneSchemas,
base);
-                    }
-                }
+            String location = included.getSchemaLocationURI();
+            String id = parentKey + "/" + location;
+            if (!keyMap.containsKey(id)) {
+                String key = getUniqueSchemaId();
+                schemaMap.put(key, included);
+                keyMap.put(id, key);
+                updateSchemaImports(key, included.getReferencedSchema(), base);
             }
         }
     }
     
+    private String getUniqueSchemaId() {
+        return "xsd" + ++schemaCounter;
+    }
+    
+    private String getUniqueWSDLId() {
+        return "wsdl" + ++wsdlCounter;
+    }    
+    
     public static void writeTo(Node node, OutputStream os) {
         writeTo(new DOMSource(node), os);
     }

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java?rev=735186&r1=735185&r2=735186&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
Fri Jan 16 16:20:58 2009
@@ -37,8 +37,10 @@
 import org.apache.axis2.transport.http.HTTPTransportUtils;
 import org.apache.axis2.transport.http.util.RESTUtil;
 import org.apache.geronimo.axis2.Axis2WebServiceContainer;
+import org.apache.geronimo.axis2.AxisServiceGenerator;
 import org.apache.geronimo.axis2.GeronimoFactoryRegistry;
 import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
+import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.jaxws.annotations.AnnotationHolder;
 import org.slf4j.Logger;
@@ -112,6 +114,13 @@
     }
     
     @Override
+    protected AxisServiceGenerator createServiceGenerator() {
+        AxisServiceGenerator serviceGenerator = super.createServiceGenerator();
+        serviceGenerator.setCatalogName(JAXWSUtils.DEFAULT_CATALOG_WEB);
+        return serviceGenerator;
+    }
+    
+    @Override
     protected void processXMLRequest(Request request, 
                                      Response response, 
                                      AxisService service, 

Added: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/util/CatalogWSDLLocator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/util/CatalogWSDLLocator.java?rev=735186&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/util/CatalogWSDLLocator.java
(added)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/util/CatalogWSDLLocator.java
Fri Jan 16 16:20:58 2009
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.axis2.util;
+
+import java.io.IOException;
+
+import org.apache.xml.resolver.Catalog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.InputSource;
+
+public class CatalogWSDLLocator extends SimpleWSDLLocator {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(CatalogWSDLLocator.class);
+    
+    private Catalog catalog;
+        
+    public CatalogWSDLLocator(String baseURI, Catalog catalog) {
+        super(baseURI);
+        this.catalog = catalog;
+    }
+        
+    @Override
+    protected InputSource resolve(String parentLocation, String importLocation) {       
       
+        String resolvedImportLocation = null;
+        
+        if (this.catalog != null) {
+            try {
+                resolvedImportLocation = this.catalog.resolveSystem(importLocation);
+                if (resolvedImportLocation == null) {
+                    resolvedImportLocation = catalog.resolveURI(importLocation);
+                }
+                if (resolvedImportLocation == null) {
+                    resolvedImportLocation = catalog.resolvePublic(importLocation, parentLocation);
+                }
+            } catch (IOException e) {
+                throw new RuntimeException("Catalog resolution failed", e);
+            }
+        }
+        
+        if (resolvedImportLocation == null) {
+            // not found in the catalog
+            return super.resolve(parentLocation, importLocation);
+        } else {
+            // found in the catalog
+            return super.resolve("", resolvedImportLocation);            
+        }
+    }
+        
+}

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/util/CatalogWSDLLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/util/CatalogWSDLLocator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/util/CatalogWSDLLocator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBWebServiceGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBWebServiceGBean.java?rev=735186&r1=735185&r2=735186&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBWebServiceGBean.java
(original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBWebServiceGBean.java
Fri Jan 16 16:20:58 2009
@@ -27,6 +27,7 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.JNDIResolver;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.jaxws.ServerJNDIResolver;
@@ -69,13 +70,17 @@
         bus.setExtension(portInfo, PortInfo.class);  
         bus.setExtension(ejbDeploymentContext.getDeploymentInfo(), DeploymentInfo.class);
         
-        CXFCatalogUtils.loadOASISCatalog(bus, 
-                                         configurationBaseUrl, 
-                                         "META-INF/jax-ws-catalog.xml");
+        ClassLoader classLoader = ejbDeploymentContext.getClassLoader();
+        
+        URL catalog = JAXWSUtils.getOASISCatalogURL(configurationBaseUrl, 
+                                                    classLoader, 
+                                                    JAXWSUtils.DEFAULT_CATALOG_EJB);
+        if (catalog != null) {
+            CXFCatalogUtils.loadOASISCatalog(bus, catalog);
+        }
         
         this.container = new EJBWebServiceContainer(bus, configurationBaseUrl, beanClass);
         
-        ClassLoader classLoader = ejbDeploymentContext.getClassLoader();
         if (soapHandler != null) {
             soapHandler.addWebService(this.location, 
                                       virtualHosts, 

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFCatalogUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFCatalogUtils.java?rev=735186&r1=735185&r2=735186&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFCatalogUtils.java
(original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFCatalogUtils.java
Fri Jan 16 16:20:58 2009
@@ -18,15 +18,13 @@
  */
 package org.apache.geronimo.cxf;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.net.URL;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.cxf.Bus;
 import org.apache.cxf.catalog.OASISCatalogManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class CXFCatalogUtils {
     
@@ -34,24 +32,8 @@
         
     private CXFCatalogUtils() {        
     }
-    
-    public static void loadOASISCatalog(Bus bus, URL baseURL, String catalogName) {
-        URL catalogURL = null;
-        try {
-            catalogURL = new URL(baseURL, catalogName);
-            LOG.debug("Checking for " + catalogURL + " catalog.");            
-            catalogURL.openStream().close();
-            loadOASISCatalog(bus, catalogURL);            
-        } catch (MalformedURLException e) {
-            LOG.warn("Error constructing catalog URL: " + baseURL + " " + catalogName);
-        } catch (FileNotFoundException e) {
-            LOG.debug("Catalog " + catalogURL + " is not present in the module");
-        } catch (IOException e) {
-            LOG.warn("Failed to load catalog file: " + catalogURL, e);
-        }
-    }
-    
-    private static void loadOASISCatalog(Bus bus, URL catalogURL) {
+        
+    public static void loadOASISCatalog(Bus bus, URL catalogURL) {
         OASISCatalogManager catalog = new OASISCatalogManager();
         try {
             catalog.loadCatalog(catalogURL);

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java?rev=735186&r1=735185&r2=735186&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java
(original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java
Fri Jan 16 16:20:58 2009
@@ -33,6 +33,7 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.JNDIResolver;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.jaxws.ServerJNDIResolver;
@@ -96,9 +97,12 @@
         this.bus.setExtension(context, Context.class);
         this.bus.setExtension(holder, AnnotationHolder.class);
         
-        CXFCatalogUtils.loadOASISCatalog(this.bus, 
-                                         this.configurationBaseUrl, 
-                                         "WEB-INF/jax-ws-catalog.xml");
+        URL catalog = JAXWSUtils.getOASISCatalogURL(this.configurationBaseUrl, 
+                                                    classLoader, 
+                                                    JAXWSUtils.DEFAULT_CATALOG_WEB);
+        if (catalog != null) {
+            CXFCatalogUtils.loadOASISCatalog(this.bus, catalog);
+        }
     }
     
     public WebServiceContainer getWebServiceContainer() {

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java?rev=735186&r1=735185&r2=735186&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
(original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
Fri Jan 16 16:20:58 2009
@@ -16,7 +16,11 @@
  */
 package org.apache.geronimo.jaxws;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -26,8 +30,16 @@
 import javax.xml.ws.BindingType;
 import javax.xml.ws.WebServiceProvider;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public class JAXWSUtils {
     
+    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";
+
+    private static final Logger LOG = LoggerFactory.getLogger(JAXWSUtils.class);
+    
     private static final Map<String, String> BINDING_MAP = 
         new HashMap<String, String>();
     
@@ -291,4 +303,27 @@
         }
     }
     
+    public static URL getOASISCatalogURL(URL configurationBaseUrl, ClassLoader classLoader,
String catalogName) {
+        if (catalogName == null) {
+            return null;
+        }
+        URL catalogURL = classLoader.getResource(catalogName);
+        LOG.debug("Checking for {} catalog in classloader", catalogURL);  
+        if (catalogURL == null) {
+            try {
+                URL tmpCatalogURL = new URL(configurationBaseUrl, catalogName);
+                LOG.debug("Checking for {} catalog in module directory", catalogURL);   
        
+                tmpCatalogURL.openStream().close();
+                catalogURL = tmpCatalogURL;
+            } catch (MalformedURLException e) {
+                LOG.warn("Error constructing catalog URL {} {}", configurationBaseUrl, catalogName);
+            } catch (FileNotFoundException e) {
+                LOG.debug("Catalog {} is not present in the module", catalogName);
+            } catch (IOException e) {
+                LOG.warn("Failed to open catalog file: " + catalogURL, e);
+            }
+        }
+        return catalogURL;
+    }
+    
 }



Mime
View raw message