Search in sources :

Example 31 with ProceedingJoinPoint

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

the class MultiplyReturnValue 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 : ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Example 32 with ProceedingJoinPoint

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

the class SimpleSpringBeforeAdvice method aroundAdviceOne.

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

Example 33 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project T-MVP by north2016.

the class SysPermissionAspect method aroundJoinPoint.

@Around("execution(@com.app.annotation.aspect.Permission * *(..)) && @annotation(permission)")
public void aroundJoinPoint(ProceedingJoinPoint joinPoint, Permission permission) throws Throwable {
    AppCompatActivity ac = (AppCompatActivity) App.getAppContext().getCurActivity();
    new AlertDialog.Builder(ac).setTitle("提示").setMessage("为了应用可以正常使用,请您点击确认申请权限。").setNegativeButton("取消", null).setPositiveButton("允许", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            MPermissionUtils.requestPermissionsResult(ac, 1, permission.value(), new MPermissionUtils.OnPermissionListener() {

                @Override
                public void onPermissionGranted() {
                    try {
                        // 获得权限,执行原方法
                        joinPoint.proceed();
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                }

                @Override
                public void onPermissionDenied() {
                    MPermissionUtils.showTipsDialog(ac);
                }
            });
        }
    }).create().show();
}
Also used : DialogInterface(android.content.DialogInterface) AppCompatActivity(android.support.v7.app.AppCompatActivity) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Example 34 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project aws-xray-sdk-java by aws.

the class BaseAbstractXRayInterceptor method processXRayTrace.

protected Object processXRayTrace(ProceedingJoinPoint pjp) throws Throwable {
    try {
        Subsegment subsegment = AWSXRay.beginSubsegment(pjp.getSignature().getName());
        if (subsegment != null) {
            subsegment.setMetadata(generateMetadata(pjp, subsegment));
        }
        return XRayInterceptorUtils.conditionalProceed(pjp);
    } catch (Exception e) {
        AWSXRay.getCurrentSegmentOptional().ifPresent(x -> x.addException(e));
        throw e;
    } finally {
        logger.trace("Ending Subsegment");
        AWSXRay.endSubsegment();
    }
}
Also used : AWSXRay(com.amazonaws.xray.AWSXRay) Map(java.util.Map) Subsegment(com.amazonaws.xray.entities.Subsegment) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) Pointcut(org.aspectj.lang.annotation.Pointcut) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around) Subsegment(com.amazonaws.xray.entities.Subsegment)

Example 35 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project alfresco-repository by Alfresco.

the class AJExtender method extendAroundAdvice.

/**
 * Around advice helper that matches the advised method with its
 * corresponding extension method, sets up aspectJ call contexts (egg. the
 * local-proceed context) and delegates to the extension method.
 *
 * @param thisJoinPoint
 * @param extensible
 * @param extendAnnotation
 * @param extension
 * @return the result of the extended method
 */
static Object extendAroundAdvice(JoinPoint thisJoinPoint, Extensible extensible, Extend extendAnnotation, Object extension) {
    MethodSignature ms = (MethodSignature) thisJoinPoint.getSignature();
    Method method = ms.getMethod();
    try {
        ajLocalProceedingJoinPoints.get().push(new ProceedingContext(extendAnnotation, (ProceedingJoinPoint) thisJoinPoint));
        Method extensionMethod = extension.getClass().getMethod(method.getName(), method.getParameterTypes());
        if (logger.isDebugEnabled()) {
            oneTimeLiveLog(AJExtender.logger, new ExtensionRoute(extendAnnotation, method, extensionMethod));
        }
        return extensionMethod.invoke(extension, thisJoinPoint.getArgs());
    } catch (IllegalAccessException error) {
        throw new InvalidExtension("Ivalid extension : " + error.getMessage(), error);
    } catch (IllegalArgumentException error) {
        throw new InvalidExtension("Ivalid extension : " + error.getMessage(), error);
    } catch (InvocationTargetException error) {
        Throwable targetException = error.getTargetException();
        if (targetException instanceof RuntimeException) {
            throw (RuntimeException) targetException;
        } else {
            throw new ExtensionTargetException(targetException);
        }
    } catch (NoSuchMethodException error) {
        throw new InvalidExtension("Ivalid extension : " + error.getMessage(), error);
    } catch (SecurityException error) {
        throw new InvalidExtension("Ivalid extension : " + error.getMessage(), error);
    } finally {
        ajLocalProceedingJoinPoints.get().pop();
    }
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) Method(java.lang.reflect.Method) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)78 Around (org.aspectj.lang.annotation.Around)33 MethodSignature (org.aspectj.lang.reflect.MethodSignature)16 Method (java.lang.reflect.Method)14 Test (org.junit.Test)14 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)10 SimpleDateFormat (java.text.SimpleDateFormat)8 ArrayList (java.util.ArrayList)8 JoinPoint (org.aspectj.lang.JoinPoint)8 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)7 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)7 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)7 MockProceedingJoinPoint (org.finra.herd.core.MockProceedingJoinPoint)7 Annotation (java.lang.annotation.Annotation)5 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)4 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)4 Date (java.util.Date)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 Action (org.apache.nifi.action.Action)4 MessageHeader (org.finra.herd.model.dto.MessageHeader)4