Here is my CustomClassLoader written in a two days at least to load
class type data from a modified class path. I started my class with the
Java in a Nutshell Book example.
Basically it emulates the primordial class loader.
It does almost everything.
It does not implement `getResource( String name )' object, because it needs
URLStreamHandler object to implement a new URL protocol.
I'd like it do set up a URL of
`privateresource:/DUMMY_ZIP_HOST/+/foo/bar/duke.gif'
Hence the protocol is `privateresource' just the `http' or `ftp' or
even `systemresource'. So what one needs is a specialised protocol handler
to complete the class loader otherwise `getResourceAsInputStream' will
work. For my application it much better to use URLs, because that is what
god intended reference for, instead opening input streams. Anyway I digress ...
My invented specialised URLStreamHandler would find the GIF in the modified
class path. This result would be the GIF image resource "duke.gif".
I suspect that the URL string "systemresource:/ZIP7/+/foo/bar/duke.gif'
is interpret like this. The dummy hostname `/ZIP7/' is really means the 7th ZIP
file inside a private internally maintained (Vector) list of ZIP filename paths
which is grokked from the primordial CLASSPATH. The '+' is just a magic
placeholder to identify the filename in the zip. Ah this look my sort of URL, ce
n'est pas?
All you do, then, is find the 7th one and get the fully qualified filename to it
say "/opt/my/loard/frogger/hendrix.zip' and then retrieve the zip file entry
and then get the input stream for it. And that your custom URLStreamHandler
witten done. The only problem is how do you change the URL stream handler
factory or customise it so that you add another protocol a runtime?
Any help appreciated
Peter
BTW: CC-Mail is really a pile of s**t, the proper name of the attachment is
`CustomClassLoader.java'
______________________________ Reply Separator _________________________________
Subject: Re: Implementating ClassLoader.getResource?
Author: dulitz ([EMAIL PROTECTED]) at lon-mime
Date: 10/03/99 13:09
Hi Peter,
Sorry, I don't know the answer to your question.
I do want to mention, though, that over the last few months a few people
on java-linux have expressed a desire to use or look at a ClassLoader
such as the one you have written. No biggie, but it might save a few
people a day of work each.
FYI,
daniel dulitz
Valley Technologies, Inc. Peak Performance Real-Time DSP
State College, PA
custom~1.jav