Some details
Loaders
A lot of the code is based on Loaders, well really DelegateLoaders.
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
which do what you might expect.
Although I can support raw Loaders in some places (e.g. as parents of a Domain),
most places need DelegateLoaders. That is a Loader associated with a ClassLoaderPolicy
and transitively a ClassLoader.
DelegateLoaders
The DelegateLoaders are Loaders associated with a Policy.
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
They can also implement additional rules. e.g. for handling imports or exports
you can add a filter.
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
ClassFilter
ClassFilters let you decide what parts of a delegate classloader you are going to
import or export.
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
There are some standard ones defined like EVERYTHING and NOTHING in that class.
Examples.
A DelegateLoader that imports only a certain package
| new FilteredDelegateLoader(policy, new PackageClassFilter(new String[] {
"com.acme" });
|
Only importing java.* and javax.* from the parent of your domain
| ClassLoadingSystem system = ClassLoadingSystem.getInstance();
| system.createAndRegisterDomain("MyDomain",
ParentPolicy.BEFORE_BUT_ONLY_JAVA);
|
See
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
for more on the parent policy.
Domains allow multiple hierarchies and not just delegation to another domain.
| Loader parent = ...;
| system.createAndRegisterDomain("MyDomain", ParentPolicy.BEFORE, parent);
|
this works because ClassLoadingDomains are also Loaders.
If you don't specify a parent then it uses the ClassLoader that defines
the org.jboss.classloader classes as the parent, via an adapter
https://svn.jboss.org/repos/jbossas/projects/microcontainer/trunk/classlo...
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041344#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...