Example usage for org.aspectj.lang ProceedingJoinPoint proceed

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

Introduction

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

Prototype

public Object proceed() throws Throwable;

Source Link

Document

Proceed with the next advice or target method invocation

Usage

From source file:cn.com.xl.core.aop.PermissionAop.java

License:Apache License

@Around("cutPermission()")
public Object doPermission(ProceedingJoinPoint point) throws Throwable {
    MethodSignature ms = (MethodSignature) point.getSignature();
    Method method = ms.getMethod();
    Permission permission = method.getAnnotation(Permission.class);
    Object[] permissions = permission.value();
    if ((permissions.length == 1 && Func.toStr(permissions[0]).equals("ALL")) || permissions == null
            || permissions.length == 0) {
        ///*from  w  w w.  java2s .  c om*/
        boolean result = PermissionCheckManager.checkAll();
        if (result) {
            return point.proceed();
        } else {
            throw new NoPermissionException();
        }
    } else {
        //
        boolean result = PermissionCheckManager.check(permissions);
        if (result) {
            return point.proceed();
        } else {
            throw new NoPermissionException();
        }
    }

}

From source file:cn.mypandora.log.MyLogAspect.java

License:Apache License

/**
 * ??(?)//from  w  ww .j  a va2  s .c  om
 *
 * @param point
 * @return
 * @throws Throwable
 */
@Around("pointcut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
    logger.debug("begin around");
    Object object = point.proceed();
    logger.debug("end around");
    return object;
}

From source file:com.ace.erp.extra.aop.ResourceMenuCacheAspect.java

public Object findRolesCacheableAdvice(ProceedingJoinPoint pjp, User arg) throws Throwable {

    User user = arg;// w  w w .  j  a  v a 2  s .  c  o m

    String key = menusKey(user.getId());
    Object retVal = get(key);

    if (retVal != null) {
        log.debug("cacheName:{}, method:findRolesCacheableAdvice, hit key:{}", cacheName, key);
        return retVal;
    }
    log.debug("cacheName:{}, method:findRolesCacheableAdvice, miss key:{}", cacheName, key);

    retVal = pjp.proceed();

    put(key, retVal);

    return retVal;
}

From source file:com.ace.erp.extra.aop.UserCacheAspect.java

@Around(value = "userServicePointcut() && cacheablePointcut()")
public Object cacheableAdvice(ProceedingJoinPoint pjp) throws Throwable {

    String methodName = pjp.getSignature().getName();
    Object arg = pjp.getArgs().length >= 1 ? pjp.getArgs()[0] : null;

    String key = "";
    boolean isIdKey = false;
    if ("getUserById".equals(methodName)) {
        key = idKey(String.valueOf(arg));
        isIdKey = true;/*from  w ww  .  j  a v a 2s . c  om*/
    } else if ("getUserByName".equals(methodName)) {
        key = usernameKey((String) arg);
    } else if ("getUserByEmail".equals(methodName)) {
        key = emailKey((String) arg);
    } else if ("getUserByMobilePhoneNumber".equals(methodName)) {
        key = mobilePhoneNumberKey((String) arg);
    }

    User user = null;
    if (isIdKey == true) {
        user = get(key);
    } else {
        Integer id = get(key);
        if (id != null) {
            key = idKey(String.valueOf(id));
            user = get(key);
        }
    }
    //cache hit
    if (user != null) {
        log.debug("cacheName:{}, hit key:{}", cacheName, key);
        return user;
    }
    log.debug("cacheName:{}, miss key:{}", cacheName, key);

    //cache miss
    user = (User) pjp.proceed();

    //put cache
    put(user);
    return user;

}

From source file:com.aeells.hibernate.profiling.HibernateProfilingInterceptor.java

License:Open Source License

public void profileWrites(final ProceedingJoinPoint call, final Object model) throws Throwable {
    if (LOGGER.isTraceEnabled()) {
        final DateTime start = new DateTime();
        call.proceed();
        logProfileCall(call, model, (new Duration(start, new DateTime()).getMillis()));
    } else {//from w w  w  .j  a  v  a2 s  . co m
        call.proceed();
    }
}

From source file:com.aeells.hibernate.profiling.HibernateProfilingInterceptor.java

License:Open Source License

public Object profileFind(final ProceedingJoinPoint call) throws Throwable {
    if (LOGGER.isTraceEnabled()) {
        final DateTime start = new DateTime();
        final Object model = call.proceed();
        logProfileCall(call, model, (new Duration(start, new DateTime()).getMillis()));
        return model;
    } else {/*w  w  w.j av a  2s .  c  o m*/
        return call.proceed();
    }
}

From source file:com.aeells.hibernate.profiling.HibernateProfilingInterceptor.java

License:Open Source License

public Object profileFindList(final ProceedingJoinPoint call) throws Throwable {
    if (LOGGER.isTraceEnabled()) {
        final DateTime start = new DateTime();
        @SuppressWarnings({ "unchecked" })
        final List<Object> models = (List<Object>) call.proceed();
        logProfileCall(call, models, (new Duration(start, new DateTime()).getMillis()));
        return models;
    } else {//  ww  w  .ja v  a  2  s  .  c om
        return call.proceed();
    }
}

From source file:com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.WorkflowNotifierManager.java

License:Open Source License

@Around("execution(* com.agiletec.plugins.jacms.aps.system.services.content.IContentManager.saveContent(..)) && args(content,..)")
public void listenContentSaving(ProceedingJoinPoint pjp, Object content) {
    try {//from ww  w. j a va2  s  .  co  m
        boolean notify = true;
        Content currentContent = (Content) content;
        String contentId = currentContent.getId();
        if (null != contentId) {
            Content previousContent = this.getContentManager().loadContent(contentId, false);
            if (previousContent.getStatus().equals(currentContent.getStatus())) {
                notify = false;
            }
        }
        pjp.proceed();
        if (notify) {
            this.saveContentStatusChanged(currentContent);
        }
    } catch (Throwable t) {
        _logger.error("Error notifying content status change", t);
    }
}

From source file:com.alibaba.china.plugin.cache.spring.aop.CacheAopSupport.java

License:Open Source License

private Object proceedJoinPoint(ProceedingJoinPoint joinPoint) {
    try {/*from  w  w w . j a  va 2s.  c o m*/
        return joinPoint.proceed();
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
}

From source file:com.aliyun.odps.OdpsDeprecatedLogger.java

License:Apache License

@Around("@annotation(Deprecated)")
public Object around(ProceedingJoinPoint point) throws Throwable {
    try {//from   w  w  w  .ja v a 2 s . c om
        String methodSignature = point.getSignature().toString();
        Long calledTimes = getDeprecatedCalls().get(methodSignature);
        if (calledTimes == null) {
            calledTimes = 1L;
        } else {
            calledTimes += 1L;
        }
        getDeprecatedCalls().put(methodSignature, calledTimes);
    } catch (Throwable e) {
        //do nothing.
    }
    return point.proceed();
}