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   
   24   import org.apache.xml.resolver.Catalog;
   25   import org.slf4j.Logger;
   26   import org.slf4j.LoggerFactory;
   27   import org.xml.sax.InputSource;
   28   
   29   public class CatalogWSDLLocator extends SimpleWSDLLocator {
   30       
   31       private static final Logger LOG = LoggerFactory.getLogger(CatalogWSDLLocator.class);
   32       
   33       private Catalog catalog;
   34           
   35       public CatalogWSDLLocator(String baseURI, Catalog catalog) {
   36           super(baseURI);
   37           this.catalog = catalog;
   38       }
   39           
   40       @Override
   41       protected InputSource resolve(String parentLocation, String importLocation) {               
   42           String resolvedImportLocation = null;
   43           
   44           if (this.catalog != null) {
   45               try {
   46                   resolvedImportLocation = this.catalog.resolveSystem(importLocation);
   47                   if (resolvedImportLocation == null) {
   48                       resolvedImportLocation = catalog.resolveURI(importLocation);
   49                   }
   50                   if (resolvedImportLocation == null) {
   51                       resolvedImportLocation = catalog.resolvePublic(importLocation, parentLocation);
   52                   }
   53               } catch (IOException e) {
   54                   throw new RuntimeException("Catalog resolution failed", e);
   55               }
   56           }
   57           
   58           if (resolvedImportLocation == null) {
   59               // not found in the catalog
   60               return super.resolve(parentLocation, importLocation);
   61           } else {
   62               // found in the catalog
   63               return super.resolve("", resolvedImportLocation);            
   64           }
   65       }
   66           
   67   }

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