From memory,

Your ClassLoader has a constructor MyClassLoader() : 'inside' the constructor you call 'super( this.getClass().getClassLoader() )' - NB you can't actually do this as it involves doing stuff before the call to the super constructor, but the semantics are the same.

Now you override the loadClass( name ) method and use the name to derive the bytestream you need (the Class definition). This will only be called if the current Class loading delegation model can't find the class.
[That's the point at which I would load a blob ...]


After that, 'ClassNotFoundException's are your problem ;-)

tim

Tim Shaw wrote:
I've done a lot of dynamic class loading ... and have never needed to use a custom class loader ('cept one time when I stored them in a DB ... don't go there!). I would re-evaluate why you need a class loader rather than Class.forName( "someClassName" ).newInstance().
My gut feeling is, if you don't know all about class loaders, you don't need to use one (explicitly).


My 2p

tim

Anna wrote:

i need to do some kind of dynamic plugin managment ... i retrieve files from directory .. and extract names ... after that i use these names to load classes dynamicaly ...
i catched article what did you post ... but i have some problems with this ... could you plz explain me how i can set my "classloader's parent to the current classloader"


Anna





you need to set your classloader's parent to the current classloader. Have you reviewed Tomcat's classloader document so that you understand how tomcat works before trying to load your own classes?
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html


Is there a reason to do this as opposed to moving your classes into tomcat's WEB-INF directory? I wouldn't do this if you are just trying to avoid copying your files to tomcat's directory from your network drive.

Charlie




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to