On Wed, 31 Jul 2002, Babu Wisor wrote:

> Date: Wed, 31 Jul 2002 10:15:08 -0700 (PDT)
> From: Babu Wisor <[EMAIL PROTECTED]>
> Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> To: Tomcat Developers List <[EMAIL PROTECTED]>
> Cc: [EMAIL PROTECTED]
> Subject: Re: how to do auto update/reload of a class?
>
> Hi All,
>       Does anyone have any thoughts as to how to auto
> re-load the classes, which have been loaded into JVM
> using Custom Class loader? I tried writing custom
> class loader and loaded all the classes, but don't
> know how to re-load the same class, if it has been
> modified (re-compiled) without shutting down JVM,
> similar to JSP engine, where if we put updated JSP
> file, it picks up the new file.
>

Jasper does this by creating a class loader for each page, and throwing
away the class loader when the page is recompiled.  The JVM doesn't let
you do things any other way.

> Note: I learnt that, we need to recreate new class
> loader and load all the classes again, but don't know
> exactly how to apply that technique in the system. Any
> help is greatly appreciated.
>

My personal advice, after living through (barely :-) getting a class
loader that would reload a webapp to work, is to abandon this approach
unless you are just doing it for fun and learning how class loading works.
You are going to find that the fundamental architecture of Java isn't
really oriented towards incremental replacement of classes (although there
is a little bit better support in 1.4).

> Thank you,
> Babu

Craig

> --- Ian Darwin <[EMAIL PROTECTED]> wrote:
> > On July 28, 2002 10:32 pm, you wrote:
> > >     Does anyone know, how to do auto update of
> > classes
> > > into the JVM? I
> > > tried to write my own custom class loader, and
> > loaded
> > > all the classes
> > > through it, however if I put new updated class, it
> > > won't reload the
> > > class again. Have anyone tried this before? Help
> > is
> > > very much
> > > appreciated.
> >
> > This better asked on an advanced-java list; not
> > tomcat specific.
> >
> > For all the cleverness of Java's dynamic loading
> > mechanism (ClassLoader,
> > Class.forName, newInstance(), etc.), there is no
> > published API for unloading or reloading.
> > They just didn't think of it in time, perhaps.
> >
> > What I think Tomcat and others do is basically to
> > manage the class loader for each Context
> > (which has to be separate from the CL for each other
> > Context for configuration
> > and security reasons anyway) in such a way that you
> > can delete
> > it (un-reference it) and assign a new one and reload
> > the classes
> > for the given Context.
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - Feel better, live better
> http://health.yahoo.com
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


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

Reply via email to