You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2007/03/22 21:13:55 UTC
svn commit: r521435 -
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentClassLoader.java
Author: dims
Date: Thu Mar 22 13:13:51 2007
New Revision: 521435
URL: http://svn.apache.org/viewvc?view=rev&rev=521435
Log:
add support for getting resources from the embedded jars
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentClassLoader.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentClassLoader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentClassLoader.java?view=diff&rev=521435&r1=521434&r2=521435
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentClassLoader.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentClassLoader.java Thu Mar 22 13:13:51 2007
@@ -25,6 +25,8 @@
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
@@ -133,7 +135,9 @@
entryName = entry.getName();
if (entryName != null &&
entryName.endsWith(resource)) {
- return new URL("jar", "", -1, urls[0] + "!/" + libjar_name + "!/" + entryName, new JarFileUrlStreamHandler());
+ byte[] raw = IOUtils.getStreamAsByteArray(zin);
+ return new URL("jar", "", -1, urls[0] + "!/" + libjar_name + "!/" + entryName,
+ new ByteUrlStreamHandler(raw));
}
}
} catch (Exception e) {
@@ -169,7 +173,9 @@
entryName = entry.getName();
if (entryName != null &&
entryName.endsWith(resource)) {
- resources.add(new URL("jar", "", -1, urls[0] + "!/" + libjar_name + "!/" + entryName, new JarFileUrlStreamHandler()));
+ byte[] raw = IOUtils.getStreamAsByteArray(zin);
+ resources.add(new URL("jar", "", -1, urls[0] + "!/" + libjar_name + "!/" + entryName,
+ new ByteUrlStreamHandler(raw)));
}
}
} catch (Exception ex) {
@@ -233,5 +239,33 @@
*/
private InputStream getJarAsStream(String libjar_name) throws Exception {
return new ByteArrayInputStream(getBytes(urls[0].openStream(), libjar_name));
+ }
+
+ public static class ByteUrlStreamHandler extends URLStreamHandler {
+ private byte[] bytes;
+
+ public ByteUrlStreamHandler(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ protected URLConnection openConnection(URL u) throws IOException {
+ return new ByteURLConnection(u, bytes);
+ }
+ }
+
+ public static class ByteURLConnection extends URLConnection {
+ protected byte[] bytes;
+
+ public ByteURLConnection(URL url, byte[] bytes) {
+ super(url);
+ this.bytes = bytes;
+ }
+
+ public void connect() {
+ }
+
+ public InputStream getInputStream() {
+ return new ByteArrayInputStream(bytes);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org