[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] @DeclareParents problems

Wow. I found something.

First up, my previous postings about having consistant results by using the Spring interface in with AJDT was incorrect. The advice I was using was filtering for yet another interface in that test. So the advice never got applied making it appear as though the code was never woven. So throw that out. :(

This morning I got an idea that turned out to work. Maybe you all have an explanation as to why.

I noticed that if I wrote my own interface, it worked. The problem manifested itself when the new parent class implemented Spring's interface. What if my interface extended the Spring interface? So I tried it and that worked!

I wrote a proxy interface. All this proxy interface does is override the one method found in ApplicationContextAware.

==================================================
import org.springframework.context.ApplicationContext ;
import org.springframework.context.ApplicationContextAware;

public interface ApplicationContextAwareProxy extends ApplicationContextAware {

    public void setApplicationContext( ApplicationContext context );
   
}
==================================================

This is the only way I have found that works so far. Considering this works, I am not going to put too much more into this. However, I would like to find out why this works. And I would like to know why I don't have to go through this hoop when using non-annotated AspectJ. Is this a bug in @AspectJ annotation style?

To double check, I changed the default implemented class back to implementing ApplicationContextAware (not the proxy). I changed the aspect to reflect the change. Sure enough, the application would not run.

Any ideas on what could cause this? And why can't @AspectJ annotation style handle it? Could this be a java compiler mismatch issue? But then again, if it was, the original non-annotated style would not like it either.

The other confusing thing is that AJDT appears to not have this issue. Maybe this is an isolated case. Anyway. If you are interested in tracking this down, I would like to help in any way possible.

-Scott