001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.wsdl11;
019:
020: import java.io.InputStream;
021: import java.net.URL;
022:
023: import javax.wsdl.xml.WSDLLocator;
024: import org.xml.sax.InputSource;
025:
026: import org.apache.cxf.Bus;
027: import org.apache.cxf.catalog.CatalogWSDLLocator;
028: import org.apache.cxf.catalog.OASISCatalogManager;
029: import org.apache.cxf.resource.ResourceManager;
030:
031: public class ResourceManagerWSDLLocator implements WSDLLocator {
032: WSDLLocator parent;
033: Bus bus;
034: String wsdlUrl;
035: InputSource last;
036:
037: public ResourceManagerWSDLLocator(String wsdlUrl,
038: WSDLLocator parent, Bus bus) {
039: this .wsdlUrl = wsdlUrl;
040: this .bus = bus;
041: this .parent = parent;
042: }
043:
044: public ResourceManagerWSDLLocator(String wsdlUrl, Bus bus) {
045: this .wsdlUrl = wsdlUrl;
046: this .bus = bus;
047: this .parent = new CatalogWSDLLocator(wsdlUrl,
048: OASISCatalogManager.getCatalogManager(bus));
049: }
050:
051: public void close() {
052: if (last != null) {
053: parent.close();
054: }
055: }
056:
057: public InputSource getBaseInputSource() {
058: InputSource is = parent.getBaseInputSource();
059: if (is == null) {
060: InputStream ins = bus.getExtension(ResourceManager.class)
061: .getResourceAsStream(wsdlUrl);
062: is = new InputSource(ins);
063: is.setSystemId(wsdlUrl);
064: is.setPublicId(wsdlUrl);
065:
066: URL url = bus.getExtension(ResourceManager.class)
067: .resolveResource(wsdlUrl, URL.class);
068: if (url != null) {
069: is.setSystemId(url.toString());
070: is.setPublicId(url.toString());
071: }
072: last = is;
073: } else {
074: last = null;
075: }
076:
077: return is;
078: }
079:
080: public String getBaseURI() {
081: getBaseInputSource();
082: if (last == null) {
083: return parent.getBaseURI();
084: }
085: return last.getPublicId();
086: }
087:
088: public InputSource getImportInputSource(String parentLocation,
089: String importLocation) {
090: // TODO Auto-generated method stub
091: return parent.getImportInputSource(parentLocation,
092: importLocation);
093: }
094:
095: public String getLatestImportURI() {
096: // TODO Auto-generated method stub
097: return parent.getLatestImportURI();
098: }
099:
100: }
|