Example usage for org.aspectj.lang ProceedingJoinPoint getArgs

List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs

Introduction

In this page you can find the example usage for org.aspectj.lang ProceedingJoinPoint getArgs.

Prototype

Object[] getArgs();

Source Link

Usage

From source file:org.kuali.student.common.util.spring.MethodArgsToObjectEhcacheAdvice.java

License:Educational Community License

private MultiKey getCacheKey(ProceedingJoinPoint pjp) {
    List<Object> keyList = new ArrayList<Object>();
    keyList.add(pjp.getSignature().getName());
    for (Object arg : pjp.getArgs()) {
        if (arg == null) {
            keyList.add("_null_");
        } else {//w w w. java2s. c  o m
            keyList.add(arg.toString());
        }
    }
    return new MultiKey(keyList.toArray());
}

From source file:org.lexevs.cache.MethodCachingProxy.java

License:Open Source License

@Override
protected Object[] getArguments(ProceedingJoinPoint joinPoint) {
    return joinPoint.getArgs();
}

From source file:org.libreplan.web.common.concurrentdetection.ConcurrentModificationHandling.java

License:Open Source License

/**
 * It intercepts the calls to public methods of Spring beans marked with {@link OnConcurrentModification}.
 *
 * When an {@link OptimisticLockingFailureException} happens the page for concurrent
 * modification is shown and the user is returned to the page specified by {@link OnConcurrentModification}.
 *
 * @param jointPoint//  ww  w .  j  av  a 2s . co  m
 * @param onConcurrentModification
 *            the annotation applied to object's type
 * @return the object that would be originally returned
 */
@Around("methodWithinConcurrentModificationMarkedType(onConcurrentModification) && execution(public * * (..))")
public Object whenConcurrentModification(ProceedingJoinPoint jointPoint,
        OnConcurrentModification onConcurrentModification) throws Throwable {

    try {
        return jointPoint.proceed(jointPoint.getArgs());
    } catch (OptimisticLockingFailureException e) {
        ConcurrentModificationController.showException(e, onConcurrentModification.goToPage());
        throw e;
    }
}

From source file:org.mifos.rest.approval.aop.AspectJRESTApprovalInterceptor.java

License:Open Source License

@Around("restMethods() && requestMapping() && excludeAPI() && exludeRestfulServices()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
    Signature signature = pjp.getStaticPart().getSignature();
    LOG.debug(this.getClass().getSimpleName() + " staring");

    // FIXME : somehow autowiring is not working
    if (approvalService == null) {
        approvalService = ApplicationContextProvider.getBean(ApprovalService.class);
    }/*from w w w .  ja v a  2  s  . c om*/
    if (configurationServiceFacade == null) {
        configurationServiceFacade = ApplicationContextProvider.getBean(ConfigurationServiceFacade.class);
    }
    if (parameterNameDiscoverer == null) {
        parameterNameDiscoverer = ApplicationContextProvider.getBean(ParameterNameDiscoverer.class);
    }

    if (!RESTConfigKey.isApprovalRequired(configurationServiceFacade)) {
        LOG.debug(pjp.getSignature() + " skip approval");
        return pjp.proceed();
    }

    if (signature instanceof MethodSignature) {
        MethodSignature ms = (MethodSignature) signature;
        Method m = ms.getMethod();
        RequestMapping mapping = m.getAnnotation(RequestMapping.class);

        if (isReadOnly(mapping)) {
            LOG.debug(m.getName() + " is read only, hence returning control");
            return pjp.proceed();
        }

        Class<?> methodClassType = m.getDeclaringClass();

        if (!methodClassType.getSimpleName().endsWith("RESTController")) {
            LOG.debug(m.getName() + " is not from REST controller, hence returning control");
            return pjp.proceed();
        }

        Object[] argValues = pjp.getArgs();

        Class<?>[] argTypes = m.getParameterTypes();
        String methodName = m.getName();
        String[] names = parameterNameDiscoverer.getParameterNames(m);

        MethodArgHolder args = new MethodArgHolder(argTypes, argValues, names);
        ApprovalMethod method = new ApprovalMethod(methodName, methodClassType, args);
        approvalService.create(method);
    }
    return pjp.proceed();
}

From source file:org.nebula.builder.AsyncMethodAspect.java

License:Apache License

@Around("executeAsyncMethods()")
public Promise around(ProceedingJoinPoint pjp) throws Throwable {

    for (Object arg : pjp.getArgs()) {
        if (arg instanceof Promise && !((Promise) arg).isReady()) {
            return new Promise();
        }/*from w  ww .ja  va 2 s.  c  o  m*/
    }

    return (Promise) pjp.proceed();
}

From source file:org.nebula.service.logging.Mnemos.java

License:Apache License

/**
 * Make a string out of point.//from  ww  w. ja va 2  s.  c  o m
 * @param point The point
 * @param trim Shall we trim long texts?
 * @param skip Shall we skip details and output just dots?
 * @return Text representation of it
 * @since 0.7.19
 */
public static String toText(final ProceedingJoinPoint point, final boolean trim, final boolean skip) {
    return Mnemos.toText(MethodSignature.class.cast(point.getSignature()).getMethod(), point.getArgs(), trim,
            skip);
}

From source file:org.nekorp.workflow.desktop.servicio.imp.EditorMonitorImp.java

License:Apache License

public void updateProperty(ProceedingJoinPoint pjp) throws Throwable {
    Object target = pjp.getTarget();
    if (!(target instanceof Metadata)) {
        String methodName = pjp.getSignature().getName();
        String propertyName = StringUtils.substringAfter(methodName, "set");
        String primeraLetra = propertyName.charAt(0) + "";
        propertyName = primeraLetra.toLowerCase() + StringUtils.substringAfter(propertyName, primeraLetra);
        Object oldValue = PropertyUtils.getProperty(target, propertyName);
        if (!oldValue.equals(pjp.getArgs()[0])) {
            EditorLog log = new EditorLog();
            log.setTarget(target);//w  w  w  . jav  a2s.com
            log.setProperty(propertyName);
            log.setOldValue(oldValue);
            redoLog = new LinkedList<>();
            this.addUndo(log);
        }
    }
    pjp.proceed();
}

From source file:org.nekorp.workflow.desktop.view.binding.imp.BindingManagerImp.java

License:Apache License

@Around("modelChange()")
public void updateProperty(ProceedingJoinPoint pjp) throws Throwable {
    //BindingManagerImp.LOGGER.debug("evento:"+pjp.getTarget());
    pjp.proceed();/* ww w  .ja va 2 s  .co  m*/
    String methodName = pjp.getSignature().getName();
    String propertyName = StringUtils.substringAfter(methodName, "set");
    String primeraLetra = propertyName.charAt(0) + "";
    propertyName = primeraLetra.toLowerCase() + StringUtils.substringAfter(propertyName, primeraLetra);
    //TODO to weak code :<
    processModelUpdate(pjp.getTarget(), propertyName, pjp.getArgs()[0]);
}

From source file:org.obiba.mica.core.DebugMethodImpl.java

License:Open Source License

@Around("execution(@org.obiba.mica.core.DebugMethod * *(..)) && @annotation(debugMethodAnnotation)")
public Object logDuration(ProceedingJoinPoint joinPoint, DebugMethod debugMethodAnnotation) throws Throwable {

    logger.debug(String.format("Method called [%s] with params [%s]", joinPoint.getSignature(),
            Arrays.toString(joinPoint.getArgs())));

    return joinPoint.proceed();
}

From source file:org.obiba.mica.core.LoggingAspect.java

License:Open Source License

@Around(WITHIN_EXPR)
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
    logger.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
    try {/* w w  w . j av a2  s  . co m*/
        Object result = joinPoint.proceed();
        logger.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(),
                joinPoint.getSignature().getName(), result);
        return result;
    } catch (IllegalArgumentException e) {
        logger.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()),
                joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
        throw e;
    }
}