Home » geronimo-2.2-source-release » org.apache.geronimo.jaxws.wsdl » [javadoc | source]

    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements. See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership. The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License. You may obtain a copy of the License at
    9    *
   10    * http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied. See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.
   18    */
   19   
   20   package org.apache.geronimo.jaxws.wsdl;
   21   
   22   import java.io.IOException;
   23   import java.net.URI;
   24   import java.util.jar.JarFile;
   25   
   26   import org.apache.xml.resolver.Catalog;
   27   import org.slf4j.Logger;
   28   import org.slf4j.LoggerFactory;
   29   import org.xml.sax.InputSource;
   30   
   31   public class CatalogJarWSDLLocator extends JarWSDLLocator {
   32       
   33       private static final Logger LOG = LoggerFactory.getLogger(CatalogJarWSDLLocator.class);
   34       
   35       private Catalog catalog;
   36           
   37       public CatalogJarWSDLLocator(JarFile moduleFile, URI wsdlURI, Catalog catalog) {
   38           super(moduleFile, wsdlURI);
   39           this.catalog = catalog;
   40       }
   41           
   42       @Override
   43       protected InputSource resolve(String parentLocation, String importLocation) {               
   44           String resolvedImportLocation = null;
   45           
   46           if (this.catalog != null) {
   47               try {
   48                   resolvedImportLocation = this.catalog.resolveSystem(importLocation);
   49                   if (resolvedImportLocation == null) {
   50                       resolvedImportLocation = catalog.resolveURI(importLocation);
   51                   }
   52                   if (resolvedImportLocation == null) {
   53                       resolvedImportLocation = catalog.resolvePublic(importLocation, parentLocation);
   54                   }
   55               } catch (IOException e) {
   56                   throw new RuntimeException("Catalog resolution failed", e);
   57               }
   58           }
   59           
   60           if (resolvedImportLocation == null) {
   61               // not found in the catalog
   62               return super.resolve(parentLocation, importLocation);
   63           } else {
   64               // found in the catalog
   65               return super.resolve("", resolvedImportLocation);            
   66           }
   67       }
   68           
   69   }

Home » geronimo-2.2-source-release » org.apache.geronimo.jaxws.wsdl » [javadoc | source]