[jboss-dev-forums] [Design of AOP on JBoss (Aspects/JBoss)] - AOP ClassLoader/Scoping needs thoroughly revising

adrian@jboss.org do-not-reply at jboss.com
Thu Jul 5 08:44:38 EDT 2007


There is a fundamentally bad assumption going on with AOP usage of classloading 
and scoping. The problem is exemplified by this code in ScopedClassLoaderDomain
(but it is a more general issue that I will explain as I go on):


  |    private LoaderRepository getAspectRepository(Object aspect)
  |    {
  |       ClassLoader cl = aspect.getClass().getClassLoader();
  |       ClassLoader parent = cl;
  |       while (parent != null)
  |       {
  |          if (parent instanceof RepositoryClassLoader)
  |          {
  |             return ((RepositoryClassLoader)parent).getLoaderRepository();
  |          }
  |          parent = parent.getParent();
  |       }
  |       return null;
  |    }
  | 

The above code is like using Class.forName() instead of the context classloader.
It assumes co-location (either aspect and code or aspect and config or config and code)
which just isn't true in all cases. 

When I say co-location I'm really talking about what AOP calls Domains 
although the way this currently implemented, it is closely related to classloading.

In fact, the way AOP tries to guess what is going on and create domains
itself based on "hardwired rules" is clearly wrong.

The only reason it works is because of the "big ball mud" classloading model
currently used by JBoss or the standalone classpath specified on the command line.

It is also exemplified by the conflicting (overloaded) usage of Domains:
1) As a scoped configuration repository for the user
2) As a way to scope classloading where a class is deployed multiple times
in different deployments
3) Like (1) but done by us, e.g. the ejb3 confurgation domain

Before I explain what I would like to see, let me explain some of the use cases
which are either not supported or at least difficult to do.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060789#4060789

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060789



More information about the jboss-dev-forums mailing list