geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r736396 - in /geronimo/server/trunk/plugins: axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/ axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/ cxf/geronimo-cxf-builder/src/main/java/org/apach...
Date Wed, 21 Jan 2009 19:59:33 GMT
Author: gawor
Date: Wed Jan 21 11:59:33 2009
New Revision: 736396

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

Added:
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/CatalogJarWSDLLocator.java
  (with props)
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/JarWSDLLocator.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
    geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java
    geronimo/server/trunk/plugins/jaxws/jaxws-deployer/pom.xml

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java?rev=736396&r1=736395&r2=736396&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
Wed Jan 21 11:59:33 2009
@@ -61,7 +61,7 @@
                                 Map<Class, PortComponentRefType> portComponentRefMap)
throws DeploymentException {
         registerConfigGBean(module);
         EndpointInfoBuilder builder = new EndpointInfoBuilder(serviceInterfaceClass,
-                gerServiceRef, portComponentRefMap, module.getModuleFile(),
+                gerServiceRef, portComponentRefMap, module, cl, 
                 wsdlURI, serviceQName);
         builder.build();
 

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java?rev=736396&r1=736395&r2=736396&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
Wed Jan 21 11:59:33 2009
@@ -18,12 +18,17 @@
 package org.apache.geronimo.axis2.client;
 
 import java.net.URI;
+import java.net.URL;
 import java.util.Map;
 
+import javax.naming.NamingException;
 import javax.xml.namespace.QName;
 import javax.xml.ws.handler.HandlerResolver;
 
+import org.apache.axis2.jaxws.catalog.impl.OASISCatalogManager;
 import org.apache.axis2.jaxws.context.WebServiceContextImpl;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.gbean.AbstractName;
@@ -52,6 +57,26 @@
                                  Map<Object, EndpointInfo> seiInfoMap) {
         super(handlerChainsXML, seiInfoMap, name, serviceQName, wsdlURI, referenceClassName,
serviceClassName);
     }
+    
+    @Override
+    public Object getContent() throws NamingException {
+        DescriptionBuilderComposite composite = null;
+        
+        URL catalogURL = getCatalog();
+        if (catalogURL != null) {
+            composite = new DescriptionBuilderComposite();
+            OASISCatalogManager catalogManager = new OASISCatalogManager();
+            catalogManager.setCatalogFiles(catalogURL.toString());
+            composite.setCatalogManager(catalogManager);
+        }
+        
+        ServiceDelegate.setServiceMetadata(composite);
+        try {
+            return super.getContent();
+        } finally {
+            ServiceDelegate.setServiceMetadata(null);
+        }
+    }
 
     protected HandlerChainsType getHandlerChains() {
         HandlerChainsType types = null;

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java?rev=736396&r1=736395&r2=736396&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java
(original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java
Wed Jan 21 11:59:33 2009
@@ -54,7 +54,7 @@
                                 QName serviceQName, URI wsdlURI, Class serviceReference,

                                 Map<Class, PortComponentRefType> portComponentRefMap)
throws DeploymentException {
         EndpointInfoBuilder builder = new EndpointInfoBuilder(serviceInterface,
-                gerServiceRef, portComponentRefMap, module.getModuleFile(),
+                gerServiceRef, portComponentRefMap, module, cl, 
                 wsdlURI, serviceQName);
         builder.build();
 

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java?rev=736396&r1=736395&r2=736396&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java
(original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java
Wed Jan 21 11:59:33 2009
@@ -16,19 +16,16 @@
  */
 package org.apache.geronimo.jaxws.builder;
 
+import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
 
 import javax.wsdl.Binding;
 import javax.wsdl.Definition;
@@ -44,21 +41,28 @@
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebServiceClient;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.client.EndpointInfo;
+import org.apache.geronimo.jaxws.wsdl.CatalogJarWSDLLocator;
+import org.apache.geronimo.jaxws.wsdl.CatalogWSDLLocator;
 import org.apache.geronimo.xbeans.geronimo.naming.GerPortType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
 import org.apache.geronimo.xbeans.javaee.PortComponentRefType;
-import org.xml.sax.InputSource;
+import org.apache.xml.resolver.Catalog;
+import org.apache.xml.resolver.CatalogManager;
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class EndpointInfoBuilder {
 
     private static final Logger LOG = LoggerFactory.getLogger(EndpointInfoBuilder.class);
 
-    private JarFile moduleFile;
+    private Module module;
+    
+    private ClassLoader classLoader;
 
     private URI wsdlURI;
 
@@ -75,13 +79,15 @@
     public EndpointInfoBuilder(Class serviceClass,
                                GerServiceRefType serviceRefType,
                                Map<Class, PortComponentRefType> portComponentRefMap,
-                               JarFile moduleFile,
+                               Module module,
+                               ClassLoader classLoader, 
                                URI wsdlURI,
                                QName serviceQName) {
         this.serviceClass = serviceClass;
         this.serviceRefType = serviceRefType;
         this.portComponentRefMap = portComponentRefMap;
-        this.moduleFile = moduleFile;
+        this.module = module;
+        this.classLoader = classLoader;
         this.wsdlURI = wsdlURI;
         this.serviceQName = serviceQName;
     }
@@ -136,15 +142,15 @@
             }
         }
         
-        JarWSDLLocator wsdlLocator = null;
-        URL wsdlURL = null;
-        try {
-            wsdlURL = new URL(this.wsdlURI.toString());
-        } catch (MalformedURLException e1) {
-            // not a URL, assume it's a local reference
-            wsdlLocator = new JarWSDLLocator(this.wsdlURI);
+        Catalog catalog = loadCatalog();
+        
+        WSDLLocator wsdlLocator = null;
+        if (isURL(this.wsdlURI.toString())) {
+            wsdlLocator = new CatalogWSDLLocator(this.wsdlURI.toString(), catalog);
+        } else {
+            wsdlLocator = new CatalogJarWSDLLocator(this.module.getModuleFile(), this.wsdlURI,
catalog);
         }
-
+        
         Definition definition;
         WSDLFactory wsdlFactory;
         try {
@@ -156,13 +162,7 @@
         wsdlReader.setFeature("javax.wsdl.importDocuments", true);
         wsdlReader.setFeature("javax.wsdl.verbose", false);
         try {
-            if (wsdlURL != null) {
-                definition = wsdlReader.readWSDL(wsdlURL.toString());
-            } else if (wsdlLocator != null) {
-                definition = wsdlReader.readWSDL(wsdlLocator);
-            } else {
-                throw new DeploymentException("unknown");
-            }
+            definition = wsdlReader.readWSDL(wsdlLocator);
         } catch (WSDLException e) {
             throw new DeploymentException("Failed to read wsdl document", e);
         } catch (RuntimeException e) {
@@ -386,85 +386,53 @@
         return null;
     }
     
-    private class JarWSDLLocator implements WSDLLocator {
-
-        private final List<InputStream> streams = new ArrayList<InputStream>();
-
-        private final URI wsdlURI;
-
-        private URI latestImportURI;
-
-        public JarWSDLLocator(URI wsdlURI) {
-            this.wsdlURI = wsdlURI;
-        }
-
-        public InputSource getBaseInputSource() {
-            InputStream wsdlInputStream = getModuleFile(wsdlURI);
-            streams.add(wsdlInputStream);
-            return new InputSource(wsdlInputStream);
-        }
-
-        public String getBaseURI() {
-            return wsdlURI.toString();
+    private boolean isURL(String name) {
+        try {
+            new URL(name);
+            return true;
+        } catch (MalformedURLException e1) {
+            return false;
         }
-
-        public InputSource getImportInputSource(String parentLocation,
-                                                String relativeLocation) {
-            URI parentURI = URI.create(parentLocation);
-            URI relativeURI = URI.create(relativeLocation);
-            InputStream importInputStream;
-            if (relativeURI.isAbsolute()) {
-                latestImportURI = relativeURI;
-                importInputStream = getExternalFile(latestImportURI);
-            } else if (parentURI.isAbsolute()) {
-                latestImportURI = parentURI.resolve(relativeLocation);
-                importInputStream = getExternalFile(latestImportURI);
-            } else {
-                latestImportURI = parentURI.resolve(relativeLocation);
-                importInputStream = getModuleFile(latestImportURI);
+    }
+    
+    private Catalog loadCatalog() {        
+        URL catalogURI = null;
+        try {
+            catalogURI = getCatalog(JAXWSUtils.DEFAULT_CATALOG_WEB);
+            if (catalogURI == null) {
+                catalogURI = getCatalog(JAXWSUtils.DEFAULT_CATALOG_EJB);
             }
-            streams.add(importInputStream);
-            InputSource inputSource = new InputSource(importInputStream);
-            inputSource.setSystemId(getLatestImportURI());
-            return inputSource;
-        }
-
-        public String getLatestImportURI() {
-            return latestImportURI.toString();
+        } catch (IOException e) {
+            LOG.warn("Failed to open OASIS catalog", e);
         }
-
-        private InputStream getExternalFile(URI file) {
+        
+        CatalogManager catalogManager = new CatalogManager();
+        catalogManager.setUseStaticCatalog(false);
+        catalogManager.setIgnoreMissingProperties(true);
+        CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
+        Catalog catalog = catalogResolver.getCatalog();
+        
+        if (catalogURI != null) {
+            LOG.debug("Found OASIS catalog {} ", catalogURI);
             try {
-                return file.toURL().openStream();
+                catalog.parseCatalog(catalogURI);
             } catch (Exception e) {
-                throw new RuntimeException(
-                        "Failed to import external file: " + latestImportURI, e);
+                LOG.warn("Failed to read OASIS catalog", e);
             }
         }
         
-        private InputStream getModuleFile(URI file) {
-            ZipEntry entry = moduleFile.getEntry(file.toString());
-            if (entry == null) {
-                throw new RuntimeException(
-                    "File does not exist in the module: " + file);
-            }
-            try {                
-                return moduleFile.getInputStream(entry);
-            } catch (Exception e) {
-                throw new RuntimeException(
-                    "Could not open stream to import file", e);
-            }
-        }
+        return catalog;
+    }
         
-        public void close() {
-            for (InputStream inputStream : this.streams) {
-                try {
-                    inputStream.close();
-                } catch (IOException e) {
-                    // ignore
-                }
+    private URL getCatalog(String name) throws IOException {
+        URL catalogURL = this.classLoader.getResource(name);
+        if (catalogURL == null) {
+            File f = this.module.getEarContext().getTargetFile(URI.create(name));
+            if (f.exists()) {
+                catalogURL = f.toURL();
             }
-            streams.clear();
         }
+        return catalogURL;
     }
+       
 }

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=736396&r1=736395&r2=736396&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
Wed Jan 21 11:59:33 2009
@@ -307,12 +307,12 @@
         if (catalogName == null) {
             return null;
         }
+        LOG.debug("Checking for {} catalog in classloader", catalogName);
         URL catalogURL = classLoader.getResource(catalogName);
-        LOG.debug("Checking for {} catalog in classloader", catalogURL);  
-        if (catalogURL == null) {
+        if (catalogURL == null && configurationBaseUrl != null) {
             try {
+                LOG.debug("Checking for {} catalog in module directory", catalogName);  
                 URL tmpCatalogURL = new URL(configurationBaseUrl, catalogName);
-                LOG.debug("Checking for {} catalog in module directory", catalogURL);   
        
                 tmpCatalogURL.openStream().close();
                 catalogURL = tmpCatalogURL;
             } catch (MalformedURLException e) {

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java?rev=736396&r1=736395&r2=736396&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java
(original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java
Wed Jan 21 11:59:33 2009
@@ -20,6 +20,7 @@
 import org.apache.geronimo.naming.reference.SimpleReference;
 import org.apache.geronimo.naming.reference.ClassLoaderAwareReference;
 import org.apache.geronimo.naming.reference.KernelAwareReference;
+import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.gbean.AbstractName;
 import org.slf4j.Logger;
@@ -62,6 +63,8 @@
     protected Class enhancedServiceClass;
     protected Callback[] methodInterceptors;
     protected FastConstructor serviceConstructor;
+    
+    protected transient URL moduleBaseUrl;
 
     public JAXWSServiceReference(String handlerChainsXML, Map<Object, EndpointInfo>
seiInfoMap, AbstractName name, QName serviceQName, URI wsdlURI, String referenceClassName,
String serviceClassName) {
         this.handlerChainsXML = handlerChainsXML;
@@ -79,8 +82,17 @@
 
     public void setKernel(Kernel kernel) {
         this.kernel = kernel;
+        init();
     }
 
+    private void init() {
+        try {
+            this.moduleBaseUrl = (URL) this.kernel.getAttribute(this.moduleName, "configurationBaseUrl");
+        } catch (Exception e) {
+            // ignore
+        }
+    }
+    
     private Class loadClass(String name) throws NamingException {
         try {
             return this.classLoader.loadClass(name);
@@ -96,24 +108,41 @@
         if (this.wsdlURI == null) {
             return null;
         }
+        
+        URL wsdlURL = null;
         try {
-            return new URL(this.wsdlURI.toString());
+            wsdlURL = new URL(this.wsdlURI.toString());
         } catch (MalformedURLException e1) {
             // not a URL, assume it's a local reference
-            try {
-                URL moduleBaseUrl = (URL) this.kernel.getAttribute(
-                        this.moduleName, "configurationBaseUrl");
-                return new URL(moduleBaseUrl.toString() + this.wsdlURI.toString());
-            } catch (Exception e) {
-                URL wsdlURL = this.classLoader.getResource(this.wsdlURI.toString());
+            
+            if (this.moduleBaseUrl != null) {
+                try {
+                    wsdlURL = new URL(this.moduleBaseUrl.toString() + this.wsdlURI.toString());
+                } catch (Exception e) {
+                    // ignore
+                }
+            }
+            
+            if (wsdlURL == null) {
+                wsdlURL = this.classLoader.getResource(this.wsdlURI.toString());
                 if (wsdlURL == null) {
-                    LOG.warn("Error obtaining WSDL: " + this.wsdlURI, e);
+                    LOG.warn("Failed to obtain WSDL: " + this.wsdlURI);
                 }
                 return wsdlURL;
             }
         }
+        
+        return wsdlURL;
     }
 
+    protected URL getCatalog() {
+        URL catalogURL = JAXWSUtils.getOASISCatalogURL(this.moduleBaseUrl, this.classLoader,
JAXWSUtils.DEFAULT_CATALOG_WEB);
+        if (catalogURL == null) {
+            catalogURL = JAXWSUtils.getOASISCatalogURL(this.moduleBaseUrl, this.classLoader,
JAXWSUtils.DEFAULT_CATALOG_EJB);
+        }
+        return catalogURL;
+    }
+    
     private Class getReferenceClass() throws NamingException {
         return (this.referenceClassName != null) ? loadClass(this.referenceClassName) : null;
     }

Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/CatalogJarWSDLLocator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/CatalogJarWSDLLocator.java?rev=736396&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/CatalogJarWSDLLocator.java
(added)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/CatalogJarWSDLLocator.java
Wed Jan 21 11:59:33 2009
@@ -0,0 +1,69 @@
+/**
+ * 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.jaxws.wsdl;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.jar.JarFile;
+
+import org.apache.xml.resolver.Catalog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.InputSource;
+
+public class CatalogJarWSDLLocator extends JarWSDLLocator {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(CatalogJarWSDLLocator.class);
+    
+    private Catalog catalog;
+        
+    public CatalogJarWSDLLocator(JarFile moduleFile, URI wsdlURI, Catalog catalog) {
+        super(moduleFile, wsdlURI);
+        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/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/CatalogJarWSDLLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/CatalogJarWSDLLocator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/CatalogJarWSDLLocator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/JarWSDLLocator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/JarWSDLLocator.java?rev=736396&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/JarWSDLLocator.java
(added)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/JarWSDLLocator.java
Wed Jan 21 11:59:33 2009
@@ -0,0 +1,136 @@
+/**
+ * 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.jaxws.wsdl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+
+import javax.wsdl.xml.WSDLLocator;
+
+import org.xml.sax.InputSource;
+
+public class JarWSDLLocator implements WSDLLocator {
+
+    private final List<InputStream> streams = new ArrayList<InputStream>();
+
+    private final JarFile moduleFile;
+    private final URI wsdlURI;
+
+    private URI latestImportURI;
+
+    public JarWSDLLocator(JarFile moduleFile, URI wsdlURI) {
+        this.moduleFile = moduleFile;
+        this.wsdlURI = wsdlURI;
+    }
+
+    public InputSource getBaseInputSource() {
+        return resolve("", wsdlURI.toString());
+    }
+
+    public String getBaseURI() {
+        return wsdlURI.toString();
+    }
+
+    public InputSource getImportInputSource(String parentLocation,
+                                            String relativeLocation) {
+        return resolve(parentLocation, relativeLocation);
+    }
+    
+    protected InputSource resolve(String parentLocation,
+                                  String relativeLocation) {
+        URI parentURI = URI.create(parentLocation);
+        URI relativeURI = URI.create(relativeLocation);
+        InputStream importInputStream;
+        if (relativeURI.isAbsolute()) {
+            latestImportURI = relativeURI;
+            importInputStream = getExternalFile(latestImportURI);
+        } else if (parentURI.isAbsolute()) {
+            latestImportURI = resolveRelative(parentURI, relativeURI);
+            importInputStream = getExternalFile(latestImportURI);
+        } else {
+            latestImportURI = parentURI.resolve(relativeLocation);
+            importInputStream = getModuleFile(latestImportURI);
+        }
+        streams.add(importInputStream);
+        InputSource inputSource = new InputSource(importInputStream);
+        inputSource.setSystemId(getLatestImportURI());
+        return inputSource;
+    }
+
+    public String getLatestImportURI() {
+        return latestImportURI.toString();
+    }
+
+    private URI resolveRelative(URI parentURI, URI relativeURI) {
+        if ("jar".equals(parentURI.getScheme())) {
+            String str = parentURI.toString();
+            int i = str.indexOf('!');
+            if (i != -1) {
+                String jarBase = str.substring(0, i + 1);
+                String jarEntry = str.substring(i + 1);
+                
+                URI jarEntryURI = URI.create(jarEntry);
+                URI resolvedRelatvieURI = jarEntryURI.resolve(relativeURI);
+                
+                return URI.create(jarBase + resolvedRelatvieURI.toString());
+            }
+        } 
+        return parentURI.resolve(relativeURI);
+    }
+    
+    private InputStream getExternalFile(URI file) {
+        try {
+            return file.toURL().openStream();
+        } catch (Exception e) {
+            throw new RuntimeException(
+                    "Failed to import external file: " + latestImportURI, e);
+        }
+    }
+    
+    private InputStream getModuleFile(URI file) {
+        ZipEntry entry = moduleFile.getEntry(file.toString());
+        if (entry == null) {
+            throw new RuntimeException(
+                "File does not exist in the module: " + file);
+        }
+        try {                
+            return moduleFile.getInputStream(entry);
+        } catch (Exception e) {
+            throw new RuntimeException(
+                "Could not open stream to import file", e);
+        }
+    }
+    
+    public void close() {
+        for (InputStream inputStream : this.streams) {
+            try {
+                inputStream.close();
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+        streams.clear();
+    }
+}

Propchange: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/JarWSDLLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/JarWSDLLocator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/wsdl/JarWSDLLocator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/jaxws/jaxws-deployer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/jaxws-deployer/pom.xml?rev=736396&r1=736395&r2=736396&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/jaxws-deployer/pom.xml (original)
+++ geronimo/server/trunk/plugins/jaxws/jaxws-deployer/pom.xml Wed Jan 21 11:59:33 2009
@@ -70,14 +70,14 @@
                     <dependencies>
                         <dependency>
                             <groupId>org.apache.geronimo.configs</groupId>
-                            <artifactId>j2ee-deployer</artifactId>
+                            <artifactId>webservices-common</artifactId>
                             <type>car</type>
+                            <import>classes</import>
                         </dependency>
                         <dependency>
                             <groupId>org.apache.geronimo.configs</groupId>
-                            <artifactId>webservices-common</artifactId>
+                            <artifactId>j2ee-deployer</artifactId>
                             <type>car</type>
-                            <import>classes</import>
                         </dependency>
                         <dependency>
                             <groupId>org.apache.geronimo.modules</groupId>



Mime
View raw message