Search in sources :

Example 6 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project spring-framework by spring-projects.

the class AspectJAroundAdvice method invoke.

@Override
public Object invoke(MethodInvocation mi) throws Throwable {
    if (!(mi instanceof ProxyMethodInvocation)) {
        throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
    }
    ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
    ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
    JoinPointMatch jpm = getJoinPointMatch(pmi);
    return invokeAdviceMethod(pjp, jpm, null, null);
}
Also used : ProxyMethodInvocation(org.springframework.aop.ProxyMethodInvocation) JoinPointMatch(org.aspectj.weaver.tools.JoinPointMatch) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Example 7 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project spring-framework by spring-projects.

the class AbstractAspectJAdvice method calculateArgumentBindings.

/**
	 * Do as much work as we can as part of the set-up so that argument binding
	 * on subsequent advice invocations can be as fast as possible.
	 * <p>If the first argument is of type JoinPoint or ProceedingJoinPoint then we
	 * pass a JoinPoint in that position (ProceedingJoinPoint for around advice).
	 * <p>If the first argument is of type {@code JoinPoint.StaticPart}
	 * then we pass a {@code JoinPoint.StaticPart} in that position.
	 * <p>Remaining arguments have to be bound by pointcut evaluation at
	 * a given join point. We will get back a map from argument name to
	 * value. We need to calculate which advice parameter needs to be bound
	 * to which argument name. There are multiple strategies for determining
	 * this binding, which are arranged in a ChainOfResponsibility.
	 */
public final synchronized void calculateArgumentBindings() {
    // The simple case... nothing to bind.
    if (this.argumentsIntrospected || this.parameterTypes.length == 0) {
        return;
    }
    int numUnboundArgs = this.parameterTypes.length;
    Class<?>[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
    if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
        numUnboundArgs--;
    } else if (maybeBindJoinPointStaticPart(parameterTypes[0])) {
        numUnboundArgs--;
    }
    if (numUnboundArgs > 0) {
        // need to bind arguments by name as returned from the pointcut match
        bindArgumentsByName(numUnboundArgs);
    }
    this.argumentsIntrospected = true;
}
Also used : JoinPoint(org.aspectj.lang.JoinPoint) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Example 8 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project spring-framework by spring-projects.

the class TestBeanAdvisor method doubleReturnValue.

@Around("execution(int *.getAge())")
public Object doubleReturnValue(ProceedingJoinPoint pjp) throws Throwable {
    ++this.invocations;
    int result = (Integer) pjp.proceed();
    return result * this.multiple;
}
Also used : JoinPoint(org.aspectj.lang.JoinPoint) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Example 9 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project spring-framework by spring-projects.

the class ProceedTestingAspect method doubleOrQuits.

public Object doubleOrQuits(ProceedingJoinPoint pjp) throws Throwable {
    int value = ((Integer) pjp.getArgs()[0]).intValue();
    pjp.getArgs()[0] = new Integer(value * 2);
    return pjp.proceed();
}
Also used : JoinPoint(org.aspectj.lang.JoinPoint) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Example 10 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project spring-framework by spring-projects.

the class SimpleSpringBeforeAdvice method aroundAdviceTwo.

public int aroundAdviceTwo(ProceedingJoinPoint pjp) {
    int ret = -1;
    this.collaborator.aroundAdviceTwo(this.name);
    try {
        ret = ((Integer) pjp.proceed()).intValue();
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
    this.collaborator.aroundAdviceTwo(this.name);
    return ret;
}
Also used : ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Aggregations

ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)10 JoinPoint (org.aspectj.lang.JoinPoint)4 Around (org.aspectj.lang.annotation.Around)4 Activity (android.app.Activity)1 DialogInterface (android.content.DialogInterface)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 TbSysBeanHelpExprMap (com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap)1 IPresenter (com.yydcdut.note.presenters.IPresenter)1 HashMap (java.util.HashMap)1 JoinPointMatch (org.aspectj.weaver.tools.JoinPointMatch)1 ProxyMethodInvocation (org.springframework.aop.ProxyMethodInvocation)1