Next time yes...this time. Already checked in :)
thanks,
dims
On 12/2/05, Alex Artigues <[EMAIL PROTECTED]> wrote:
> [Sorry for repost, first time had attachment and we weren't sure if it got
> through. We have included it inline here.]
>
> > A patch would be awesome!! we could possibly help with perf testing as
> > well if we see the patch.
>
> And here it is!
>
> This patch does not include any attempts at optimization. It addresses the
> following issues:
>
> 1) Resources cannot be loaded from jars inside of the service .aar
> getResourceAsStream() has been overridden to allow this.
>
> 2) ZipInputStreams were left open by getBytes() if the target was not found.
> An additional try/catch block has been added after the search loop to make
> sure this happens.
>
> 3) Minor change in findLibJars() to normalize the path for startsWith() and
> endsWith() checks.
>
>
> What's missing from this patch is optimization code to address the extended
> loading times of the DeploymentClassLoader. We still don't know how to best
> deal with this.
>
> We forgot to extend a big "Thank You" to everyone out there working on this
> project in the last post. Thanks!
>
> --Alex & Ralf
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
> Sidenote: Should we post this to JIRA also?
>
>
>
> Patch:
> ################################################
> ---
> /home/alex/archive/axis2src/modules/core/src/org/apache/axis2/deployment/DeploymentClassLoader.java
> 2005-09-25 20:11:58.000000000 -0400
> +++ modules/core/src/org/apache/axis2/deployment/DeploymentClassLoader.java
> 2005-12-02 12:43:01.000000000 -0500
> @@ -18,6 +18,7 @@
>
> import org.apache.axis2.i18n.Messages;
>
> +import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.File;
> import java.io.FileInputStream;
> @@ -79,9 +80,10 @@
> * id the entry name start with /lib and end with .jar
> * then those entry name will be added to the arraylist
> */
> - if (entryName != null && (entryName.startsWith("lib/") ||
> - entryName.startsWith("Lib/")) &&
> - entryName.endsWith(".jar")) {
> + if ( entryName != null &&
> + entryName.toLowerCase().startsWith("lib/") &&
> + entryName.toLowerCase().endsWith(".jar") )
> + {
> lib_jars_list.add(entryName);
> }
> }
> @@ -183,6 +185,10 @@
> return raw;
> }
> }
> + try {
> + zin.close();
> + } catch (IOException ioe) {//already closed
> + }
> } catch (IOException e) {
> throw e;
> }
> @@ -190,5 +196,57 @@
> }
> throw new
> ClassNotFoundException(Messages.getMessage(DeploymentErrorMsgs.CLASS_NOT_FOUND,
> filename));
> }
> -}
> -
> +
> +
> + public InputStream getResourceAsStream(String name)
> + {
> + /*
> + * This override locates resources similar to the way that getBytes()
> locates classes.
> + * We do not store the bytes from resources in memory, as
> + * the size of resources is generally unpredictable
> + */
> + if (name==null)
> + return null;
> +
> + InputStream is = super.getResourceAsStream(name);
> + if (is == null)
> + {
> + for (int i = 0; i < lib_jars_list.size(); i++)
> + {
> + String libjar_name = (String) lib_jars_list.get(i);
> + try
> + {
> + InputStream in = super.getResourceAsStream(libjar_name);
> + ZipInputStream zin = new ZipInputStream(in);
> + ZipEntry entry;
> + String entryName = "";
> + while ((entry = zin.getNextEntry()) != null)
> + {
> + entryName = entry.getName();
> + if (entryName != null && entryName.equals(name))
> + {
> + byte data[] = new byte[2048];
> + ByteArrayOutputStream out = new
> ByteArrayOutputStream();
> + int count;
> + while ((count = zin.read(data, 0, 2048)) != -1)
> + {
> + out.write(data, 0, count);
> + }
> + byte raw[] = out.toByteArray();
> + out.close();
> + zin.close();
> + return new ByteArrayInputStream(raw);
> + }
> + }
> + try {
> + zin.close();
> + } catch (IOException ioe) {//already closed
> + }
> + } catch (IOException e) {
> + }
> + }
> + }
> +
> + return is;
> + }
> +}
> \ No newline at end of file
>
>
--
Davanum Srinivas : http://wso2.com/blogs/