cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Aspects around to intercept different methods

Former Member
764

Hi all.

I have to create two aspects/arounds in order to intercept two different methods of two different classes.

Now, I already created an aspect class that intercepts an OOB method correctly.

Here is what I did:

I created the aop.xml like this:

<aspectj>
    <weaver options="-Xset:weaveJavaxPackages=true">
        <include within="de.hybris.platform.cronjob.jalo.CronJob"/>
        <include within="com.example.aspects.*"/>
    </weaver>
    <aspects>
        <aspect name="com.example.aspects.ExampleCronJobEmailAspect"/>
    </aspects>
</aspectj>

and an aspect java class:

@Aspect
public class ExampleCronJobAspect
{
    @Around("execution(* de.hybris.platform.cronjob.jalo.CronJob.getRendererNotificationContext(..))")
    public CronJobNotificationTemplateContext getRendererNotificationContext(
            final ProceedingJoinPoint joinPoint) throws Throwable {
        //myLogic
    }
}

And it works fine.

So I just want to know if it is possibile to use the same xml and the same java class to intercept another method of an other class. How can I do it? How have I to edit my apo.xml to reach this goal?

Thank in advance.

Stochino

Accepted Solutions (0)

Answers (1)

Answers (1)

arvind-kumar_avinash
Active Contributor

The following should work for you:

@Around("execution(* de.hybris.platform.cronjob.jalo.CronJob.getRendererNotificationContext(..)) || execution(* some-other-class-method(..))")