Search code examples
javaspringspring-aophessianpointcut

Spring AOP ignores some methods of Hessian Service


I have an Aspect with the following pointcut definition

@Pointcut("execution(public de.company.project..* *(..))")

and a spring configuration containing the following

<aop:aspectj-autoproxy />

<bean id="myaspect"
        class="de.company.project.impl.MyAspect" />

<bean id="someService" class="de.company.project.impl.SomeService" />

<bean name="/SomeService"
    class="org.springframework.remoting.caucho.HessianServiceExporter">
    <property name="service" ref="someService" />
    <property name="serviceInterface"
        value="de.company.project.interf.SomeService" />
</bean>

(there are multiple services in the real configuration)

I see the aspect getting invoked in some methods, but not on all. I am suspecting (but not completely shure yet) only the methods declared directly in the interface get wrapped in the aspect and methods declared in a superinterface get ignored (although that interface should match the same pointcut).

Is this expected behaviour? How can I change it? What else might be going on?


Solution

  • The answer is: I messed up the Pointcut pattern. Looks like this

    @Pointcut("execution(public de.company.project..* *(..))")
    

    specifies the package of the return type, while this

    @Pointcut("execution(public de.company.project..*(..))")
    

    specifies the package of the type which has the method.

    see I need a Spring AOP pointcut explanation