Author: dkulp
Date: Tue Jan 27 17:47:59 2009
New Revision: 738166
URL: http://svn.apache.org/viewvc?rev=738166&view=rev
Log:
[CXF-1140] For http urls to wsdl/schema, well cache the results as wsdl4j
doesn't call "close()" till the end which results in the connection to the
server being held open consuming ports on the server. Caching allows the
keepalives to work and everything transferred over one connection.
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/ExtendedURIResolver.java
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/ExtendedURIResolver.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/ExtendedURIResolver.java?rev=738166&r1=738165&r2=738166&view=diff
==============================================================================
---
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/ExtendedURIResolver.java
(original)
+++
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/ExtendedURIResolver.java
Tue Jan 27 17:47:59 2009
@@ -52,9 +52,9 @@
}
InputStream in = currentResolver.getInputStream();
resourceOpened.addElement(in);
- InputSource source = new InputSource(in);
- source.setSystemId(curUri);
- source.setPublicId(lastestImportUri);
+ InputSource source = new InputSource(in);
+ source.setSystemId(curUri);
+ source.setPublicId(curUri);
return source;
}
} catch (IOException e) {
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java?rev=738166&r1=738165&r2=738166&view=diff
==============================================================================
---
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
(original)
+++
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
Tue Jan 27 17:47:59 2009
@@ -28,12 +28,17 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLConnection;
+import java.util.HashMap;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.Base64Utility;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
/**
* Resolves a File, classpath resource, or URL according to the follow rules:
@@ -48,6 +53,8 @@
public class URIResolver {
private static final Logger LOG = LogUtils.getLogger(URIResolver.class);
+ private Map<String, LoadingByteArrayOutputStream> cache
+ = new HashMap<String, LoadingByteArrayOutputStream>();
private File file;
private URI uri;
private URL url;
@@ -159,7 +166,7 @@
}
base = base.resolve(relative);
- if (base.isAbsolute()) {
+ if (base.isAbsolute() &&
"file".equalsIgnoreCase(base.getScheme())) {
try {
baseFile = new File(base);
if (baseFile.exists()) {
@@ -173,6 +180,9 @@
tryClasspath(base.toString().startsWith("file:")
? base.toString().substring(5) :
base.toString());
}
+ } else {
+ tryClasspath(base.toString().startsWith("file:")
+ ? base.toString().substring(5) :
base.toString());
}
}
} catch (URISyntaxException e) {
@@ -285,9 +295,18 @@
private void tryRemote(String uriStr) throws IOException {
try {
+ LoadingByteArrayOutputStream bout = cache.get(uriStr);
url = new URL(uriStr);
uri = new URI(url.toString());
- is = url.openStream();
+ if (bout == null) {
+ URLConnection connection = url.openConnection();
+ is = connection.getInputStream();
+ bout = new LoadingByteArrayOutputStream(1024);
+ IOUtils.copy(is, bout);
+ is.close();
+ cache.put(uriStr, bout);
+ }
+ is = bout.createInputStream();
} catch (MalformedURLException e) {
// do nothing
} catch (URISyntaxException e) {
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java?rev=738166&r1=738165&r2=738166&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
Tue Jan 27 17:47:59 2009
@@ -96,8 +96,6 @@
}
public InputSource getImportInputSource(String parent, String
importLocation) {
- this.baseUri = parent;
-
String resolvedImportLocation = null;
if (catalogResolver != null) {
try {
@@ -115,7 +113,7 @@
InputSource in = null;
if (resolvedImportLocation == null) {
- in = this.resolver.resolve(importLocation, this.baseUri);
+ in = this.resolver.resolve(importLocation, parent);
} else {
in = this.resolver.resolve(resolvedImportLocation, null);
}