[jboss-dev] Classloading and partial deployments

Mladen Turk mturk at redhat.com
Fri Oct 17 05:06:56 EDT 2008


Hi,

Have some weired idea and would like to hear if someone
already faced something similar.

It's not directly related neither to AS nor Tomcat
but both of them have the conceptually similar application
classloaders where you put some component .jar in
some (usually) lib/ folder and it gets loaded and
hopefully unloaded on undeployment.

Now, the handy feature I need would be similar to Operating
System "Move on reboot" or "Reboot required" functionality.

In essence, like with some native installations there are two
major issues. Depending on what you are installing it might
just go on, or it might require OS reboot. Installation might
just be done for current user or it might require elevated
security.

So the first thing, if for example, my .war or .ear needs to
install something to core AS or to the catalina.home/ext
is the option to tell the deployer to unpack something in
a different location, and mark the "OS" (in this case my
container) to reboot. This requires delegating this
to the parent classloader or even to the
sun.misc.Launcher$ExtClassLoader

The second thing is undeployment or uninstall where some
part of what was installed can be physically deleted only on
reboot (probably either by some cleanup task on shutdown or
by some cleanup on startup)

This probably breaks a whole bunch of specs and has potential
security implications, but given "admin" security credentials
it can be done without impacting "user" security.

Dunno how Adrian did it for MC, but I suppose it just
sweeps trough some given .jar list on deployment and loads
those classes.

My idea was to write down the generic .jar pre-loader
that would get loaded instead real .jar, figure out the
required parent classloader, use own action mechanism
for physical deployment (unpacking native libraries
from .jar for example) and do an actual classloading.
On undeploy pre-loader would get notified (dunno how yet)
and install shutdown hook so that everything gets
cleaned up "on reboot".

Next thing are partial deployments, where pre-loader
would need to figure out if the previous package is already
installed (redeployment without reboot) in which case
the versioning of the components would either allow
to continue doing nothing or refuse to load until
reboot is done. The second is common behavior now if a
package contains native library references cause they
are all referenced in system classloader regardless of
actual classloader used (and that is what I wish to
resolve basically; packing java and native code inside
archive and make everything plug-and-play). There is
Java Module API JSR-227 (for Java7 thought)
and it defines the native libraries as resource concept,
but since (according to the spec) it'll forward the
System.loadLibrary() to the defining class loader of
the calling class the issue will still remain.

Does this make any sense?


Need some theory on how for example I could write
a code that would get notified when my .jar get
loaded and unloaded by defining classloader.
Since there's no module classloading API (has to be generic)
I can use (eg. a simple URLClassLoader) I suppose
I'll need some voodoo for that :)


Regards
-- 
^(TM)



More information about the jboss-development mailing list