Save This Page
Home » openejb-3.1.2-src » org.apache » openejb » server » axis2 » util » [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.openejb.server.axis2.util;
   21   
   22   import org.apache.openejb.util.Logger;
   23   import org.apache.openejb.util.LogCategory;
   24   import org.xml.sax.InputSource;
   25   
   26   import javax.wsdl.xml.WSDLLocator;
   27   import java.io.IOException;
   28   
   29   public class SimpleWsdlLocator implements WSDLLocator {
   30       private static final Logger logger = Logger.getInstance(LogCategory.AXIS2, SimpleWsdlLocator.class);
   31   
   32       private String baseURI;
   33       private String lastImportLocation;
   34       private SimpleUriResolver resolver;
   35   
   36       public SimpleWsdlLocator(String baseURI) {
   37           this.baseURI = baseURI;
   38           this.resolver = new SimpleUriResolver();
   39       }
   40   
   41       public InputSource getBaseInputSource() {
   42           return resolve("", this.baseURI);
   43       }
   44   
   45       public String getBaseURI() {
   46           return this.baseURI;
   47       }
   48   
   49       public InputSource getImportInputSource(String parentLocation, String importLocation) {
   50           return resolve(parentLocation, importLocation);
   51       }
   52   
   53       protected InputSource resolve(String parentLocation, String importLocation) {
   54           if (logger.isDebugEnabled()) {
   55               logger.debug("Resolving '" + importLocation + "' relative to '" + parentLocation + "'");
   56           }
   57           try {
   58               this.resolver.resolve(parentLocation, importLocation);
   59               if (this.resolver.isResolved()) {
   60                   this.lastImportLocation = this.resolver.getURI().toString();
   61                   if (logger.isDebugEnabled()) {
   62                       logger.debug("Resolved location '" + this.lastImportLocation + "'");
   63                   }
   64                   return new InputSource(this.resolver.getInputStream());
   65               }
   66           } catch (IOException e) {
   67               // ignore
   68           }
   69           return null;
   70       }
   71   
   72       public String getLatestImportURI() {
   73           return this.lastImportLocation;
   74       }
   75   
   76       public void close() {
   77       }
   78   }

Save This Page
Home » openejb-3.1.2-src » org.apache » openejb » server » axis2 » util » [javadoc | source]