madhava (2) [Avatar] Offline

Referring to the listing 2.9 and the description surrounding using spring's aop:aspectj-autoproxy:
I used spring-2.5.6 and just created one aspect, one interface and one implementation class. Then I declared a bean that is of implementation class type. When I get the bean in a main() method using getbean() of ApplicationContext, i get the 'aspected' version. Note that i have NOT specified the aop:aspectj-autoproxy tag or any bean that of the aspect type.
What gives?

madhava (2) [Avatar] Offline
Re: aspectj-autoproxy
One more thing: I'm using Eclipse with AJDT, and aspectjrt.jar is in the classpath along with spring-2.5.6.jar.

Perhaps presence of aspect in the classpath is sufficient for the implementation class to get aspected?

public aspect TracingAspect {
pointcut captureimpl() : execution(void ServiceInterface+.service*(..));
before() : captureimpl() {
System.out.println("TracingAspect.before() ServiceInterface+.service");

public class ServiceDefaultImpl implements ServiceInterface {
public void service(String name) {
System.out.println("ServiceDefaultImpl.service() with " + name);

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="" >
xmlnssmiliesi="" xmlns:aop=""
<!--<aop:aspectj-autoproxy /> -->
<bean id="defaultImpl" class="com.madhav.aspects.service.impl.ServiceDefaultImpl" />

public class AspectTester {

public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"springContext.xml"});
ServiceInterface interfaced = (ServiceInterface)context.getBean("defaultImpl");
interfaced.service("using spring context");
ramnivas (171) [Avatar] Offline
Re: aspectj-autoproxy
Yes, if the project is an AspectJ project, AJDT will weave the aspects. Spring's <aop:aspectj-autoproxy> is needed only when you want to enable proxy-based weaving.