classloader issue

"Pam" <[email protected]> Tue, 22 Apr 2003 20:43:54 +0200
Newsgroups gmane.comp.java.aspectwerkz
Message-ID <[email protected]>
Hi

I am inspecting how AspectWerkz is done in its internal and I am quite
surprised with a portion of code. I am trying to keep in mind that I want
the AOP framework works within an app server ie with hierarchical class
loaders.

While lurking at AspectWerkz.initialize() which calls
AspectWerkz.loadMethods() (in 0.4 src) I understood that the XML definition
is loaded, Aspects are registered and the target classes are immediately
loaded to create a method repository and some other internal stuff. The
following code in loadMethods gives some tips :

        for (Iterator it = advisedClassNames.iterator(); it.hasNext(); i++)
{
            try {
                 advisedClasses[i] = Thread.currentThread().

getContextClassLoader().loadClass((String)it.next());
            }
            catch (ClassNotFoundException e) {
                throw new WrappedRuntimeException(e);
            }

I am wondering why you are agressively trying to load aspected class with
aspects. I am pretty sure (at least as I understood the sources) that if I
plug aspectWerkz in a servlet container (eg), the aspected struts Action
class (eg) will have to be on the server classpath and not only in the
web-inf/lib of my deployed sample.war (eg).

I assume this is not a JMangler issue since JMangler affects the java system
classLoader to plug in it, so it will indeed affect the classloader
hierarchy (we already talk a bit about that thru some emails - I have to
check JMangler details about this).

Jonas, may be you have some tips or design reason behind this. Any way, I
think thinking a AOP framework with app server class loading scheme in mind
complicates the whole so I hope the subject is interesting (think about
having struts deployed in two web-app, with two different struts version you
want to advise differently. If its based on the class full qualified name it
will break, but If I want it to be based on some others things I have to
deploy my aspects at each level : webapp and system class loader because the
XML descriptor is not enough., and when you reached the deployment stage,
you have to handle redeploy / undeploy without having memory leaks in aspect
/ advices / point-cuts repositories).

Any way I will defnitely give a try soon to all those points.

Alex






-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf