[Design the new POJO MicroContainer] - Re: New ClassLoader initial checkin
by adrian@jboss.org
Design.
ClassLoaderPolicy
In the new ClassLoader, you don't really deal with classloaders at all.
You deal with ClassLoaderPolicys.
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
This includes things like what packages you export, what you import, how to get
resources and other things related to defining classes.
ClassLoaderSystem and Domains
Additionally, the idea of a LoaderRepository is replaced with a ClassLoaderDomain
[url]https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/cla...'
and a ClassLoaderSystem acting as a factory and a repository of domains.
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
Each ClassLoaderSystem has a "default domain".
Example psuedo code:
| // NOTE: Singleton using the spi, but implementations can be instantiated
| // directly to produce multiple classloading systems
| // (which has proved useful in the tests)
|
| ClassLoaderSystem system = ClassLoaderSystem.getInstance();
|
| // Whatever
| MyClassLoadPolicy policy = ...
|
| // Register with the default domain, there are other methods to create
| // and register with different domains
| ClassLoader cl = system.registerClassLoaderPolicy(policy);
|
Uglyness and security
To remove some ugliness from the code, the spi is split into 2 parts.
The main part is what people will use
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
but these extend base implementations
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
The idea is that the base implementations use package private methods
to talk to each other about state, registration, etc. and issue well defined "callbacks"
into the main spi. The advantages being:
1) Removal of ugliness - you don't see "nitty gritty" in the main spi
2) Security - you can't break the spi nor can anybody get access to things
they shouldn't.
For the same reason, I've defined a lot of callbacks methods in the main spi
as protected since they should only be used as callbacks not by any random code.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041338#4041338
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4041338
18 years, 11 months
[Design the new POJO MicroContainer] - New ClassLoader initial checkin
by adrian@jboss.org
The new ClassLoader is in SVN.
https:/svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classloader
(for non jboss committers replace https://svn.jboss.org/... with http://anonsvn.jboss.org/
when the mirroring catches up).
First some housekeeping points.
1) Although I committed this to the microcontainer project, it doesn't really belong there.
It's only real dependency is the jboss logger.
I'm leaving it their for now while I work on the VFS/Deployer integration.
Eventually it should be moved to a top level project.
2) The original intention was to use the Felix ClassLoader and retrofit it with
UnifiedClassLoader/Repository like behaviour. In fact, it was easier to refactor
the UCL/R style classloader to add OSGI style behaviour.
The only things I've really used from the felix as the idea of delegate/filtered
classloaders and the hack you can find in ClassLoaderUtils::isRequestFromJDK()
This was mainly because the Felix classloader links directly into the OSGi
module system and more importantly doesn't include the fixes/workarounds
for the ClassCircularityError/deadlock problems.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041335#4041335
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4041335
18 years, 11 months