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:com.hybris.integration.aop.WriteBackOperationStateAspect.java

License:Open Source License

@Around("pointcutService()")
public Object aroundServiceActions(ProceedingJoinPoint pjp) throws Throwable {
    LOGGER.trace("AOP started..... ");
    String marketplaceLogUUID = request.getParameter("marketplaceLogUUID");
    Object result = null;//  w w w.j  a  v a 2  s  .com
    try {
        result = pjp.proceed();
    } catch (Throwable e) {
        try {
            String executionMsg = null;
            String status = null;
            if (e instanceof TmallAppException) {
                JsonParser parser = new JsonParser();
                JsonObject jsonObject = parser.parse(e.getMessage()).getAsJsonObject();
                if (jsonObject.get("msg") != null) {
                    executionMsg = jsonObject.get("msg").getAsString();
                }
                status = DataHubLogService.STATUS_FAILURE;
                dhLogService.recordLog(null, marketplaceLogUUID, status, executionMsg);
            }
        } catch (Exception e1) {
            LOGGER.error(e1.getMessage(), e1);
        }
        throw e;
    }

    dhLogService.recordLog(null, marketplaceLogUUID, DataHubLogService.STATUS_SUCCEED, "Success");
    LOGGER.trace("End AOP execution..... ");
    return result;
}

From source file:com.hypersocket.annotation.AnnotationServiceImpl.java

License:Open Source License

@Override
public Object process(ProceedingJoinPoint pjp) throws Throwable {
    MethodSignature sig = (MethodSignature) pjp.getSignature();
    String id = sig.getDeclaringType().getName() + "/" + sig.getName();

    if (extensionPoints.containsKey(id)) {
        HypersocketExtensionPoint ext = extensionPoints.get(id);
        if (ext.isExtending(pjp)) {
            return extensionPoints.get(id).invoke(pjp);
        }/*from w  w  w  .ja v  a2  s  . co m*/
    }

    return pjp.proceed();

}

From source file:com.icoin.trading.tradeengine.infrastructure.profiling.ProfilingAspect.java

License:Apache License

@Around("methodsToBeProfiled()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
    StopWatch sw = new StopWatch(getClass().getSimpleName());
    try {//w w  w .  j a  va 2 s  .co  m
        sw.start(pjp.getSignature().getName());
        return pjp.proceed();
    } finally {
        sw.stop();
        //            System.out.println(sw.getLastTaskName() + sw.shortSummary());
        logger.info(sw.getLastTaskName() + sw.shortSummary());
    }
}

From source file:com.ideabase.repository.core.aspect.DataAccessEventAdvice.java

License:Open Source License

/**
 * Find Signature class. now publish event based on the specific class and
 * method signature.//from   www.  ja  va  2 s.  c  om
 */
@Around("com.ideabase.repository.core.aspect.ArchitecturePointcuts.dataAccessOperation()")
public Object aroundOperation(final ProceedingJoinPoint pProceedingJoinPoint) throws Throwable {
    // Determine source class and mehtod.
    final Signature signature = pProceedingJoinPoint.getSignature();
    final Class signatureClass = signature.getDeclaringType();
    final String signatureMethod = signature.getName();
    final Object[] arguments = pProceedingJoinPoint.getArgs();

    // Execute the operation
    final Object returned = pProceedingJoinPoint.proceed();

    // publish event
    addEvent(returned, signatureClass, signatureMethod, arguments);

    // Return the executed output.
    return returned;
}

From source file:com.ideabase.repository.core.aspect.IndexEventAdvice.java

License:Open Source License

@Around("com.ideabase.repository.core.aspect.ArchitecturePointcuts.indexOperation()")
public Object aroundOperation(final ProceedingJoinPoint pProceedingJoinPoint) throws Throwable {
    // Determine source class and mehtod.
    final Signature signature = pProceedingJoinPoint.getSignature();
    final Class signatureClass = signature.getDeclaringType();
    final String signatureMethod = signature.getName();
    final Object[] arguments = pProceedingJoinPoint.getArgs();

    // Execute the operation
    final Object returned = pProceedingJoinPoint.proceed();

    // publish event
    addEvent(signatureClass, signatureMethod, arguments);

    // Return the executed output.
    return returned;
}

From source file:com.iisigroup.cap.aop.DBExecuteAdvice.java

License:Open Source License

@Around("execution(* com..dao.*.*(..))")
public Object spendTime(ProceedingJoinPoint pjp) throws Throwable {
    String targetName = pjp.getStaticPart().toShortString();
    long start = System.currentTimeMillis();
    Object obj = pjp.proceed();
    long end = System.currentTimeMillis();
    logger.debug("DB execute time: " + (end - start) + "ms - " + targetName);
    return obj;//  w  w w.ja  v a 2  s. co  m

}

From source file:com.iisigroup.cap.base.aop.CapAuditLog4HandlerAdvice.java

License:Open Source License

/**
 * Log Around AjaxHandler execute./*from  www.  j a  v  a  2s.  c  om*/
 * 
 * @param pjp
 *            the join point
 * @param data
 *            the data
 * @param parent
 *            the parent
 * @throws Throwable
 * @return Object
 */
public Object logAroundAjaxHandlerExecute(ProceedingJoinPoint pjp, Request params) throws Throwable {
    long start = System.currentTimeMillis();
    params.put(CapConstants.C_AUDITLOG_START_TS, String.valueOf(System.currentTimeMillis()));
    final String TITLE = StrUtils.concat("#[AL_AROUND][", System.nanoTime(), "]");

    String targetName = pjp.getTarget().getClass().getName();

    Method method = CapBeanUtil.findMethod(pjp.getTarget().getClass(), params.get(CapConstants.P_FORM_ACTION),
            (Class<?>) null);
    String logAuditInfo = "none";
    if (method != null) {
        String action = null, function = null;
        CapAuditLogAction auditLogAction = method.getAnnotation(CapAuditLogAction.class);

        action = (auditLogAction != null && auditLogAction.actionType() != null)
                ? auditLogAction.actionType().toString()
                : null;
        function = (auditLogAction != null && auditLogAction.functionCode() != null)
                ? auditLogAction.functionCode().getCode()
                : null;
        if (action != null && function != null) {
            logAuditInfo = StrUtils.concat(auditLogAction.actionType().name(), CapConstants.SPACE,
                    auditLogAction.functionCode().name(), CapConstants.SPACE,
                    auditLogAction.functionCode().getUrlPath());
        }
    }
    if (logger.isTraceEnabled()) {
        logger.trace("{} ENTRY: {} Start Time: {} Audit Information: {}",
                new Object[] { TITLE, targetName, new Date(start), logAuditInfo });
    }

    Object obj = pjp.proceed();

    logger.info("{} TOTAL_COST= {} ms", TITLE, (System.currentTimeMillis() - start));

    return obj;
}

From source file:com.isotrol.impe3.pms.core.impl.AuthorizationAspect.java

License:Open Source License

@Around("@annotation(com.isotrol.impe3.pms.core.impl.Authorized)")
public Object global(ProceedingJoinPoint pjp) throws Throwable {
    final Authorization a = component.getAuthorization();
    if (a == null) {
        log(pjp, "Not logged in. Not authorized");
        throw new NoSessionException();
    }//  www  .  j av  a 2 s.  com
    final Method m = ((MethodSignature) (pjp.getSignature())).getMethod();
    final Method targetMethod = pjp.getTarget().getClass().getMethod(m.getName(), m.getParameterTypes());
    final Authorized ann = targetMethod.getAnnotation(Authorized.class);
    // Required global authorities
    final boolean hasGA = ann.global().length > 0;
    // Required portal authorities
    final boolean hasPA = ann.portal().length > 0;
    // If no authorities are required the operation is allowed to proceed.
    if (!hasGA && !hasPA) {
        log(pjp, "No required authorities. Proceed");
        return pjp.proceed();
    }
    // If the user is root and the operation is allowed to root, let it go
    if (a.isRoot() && ann.root()) {
        log(pjp, "Root access allowed. Proceed");
        return pjp.proceed();
    }
    // Global authorities.
    if (hasGA && a.hasGlobal(Arrays.asList(ann.global()))) {
        log(pjp, "Global authorities checked. Proceed");
        return pjp.proceed();
    }
    if (hasPA && a.hasPortal(getPortalId(pjp), Arrays.asList(ann.portal()))) {
        log(pjp, "Portal authorities checked. Proceed");
        return pjp.proceed();
    }
    log(pjp, "Not authorized");
    throw new AuthorizationException();
}

From source file:com.isotrol.impe3.pms.core.impl.TimingAspect.java

License:Open Source License

@Around("@within(org.springframework.stereotype.Service)")
public Object time(ProceedingJoinPoint pjp) throws Throwable {
    final Stopwatch w = Stopwatch.createStarted();
    try {/*  w w w .java  2 s.c  om*/
        return pjp.proceed();
    } finally {
        final long t = w.elapsed(TimeUnit.MILLISECONDS);
        final String key = pjp.getTarget().getClass().getName() + "." + pjp.getSignature().toShortString();
        map.add(key, t);
        if (t > 500) {
            logger.warn(String.format("[%s] took [%d] ms", key, t));
        }
    }
}

From source file:com.isotrol.impe3.web20.impl.ServiceExceptionAspect.java

License:Open Source License

@Around("@within(org.springframework.stereotype.Service)")
public Object transform(ProceedingJoinPoint pjp) throws Throwable {
    try {/*from   w  ww . j a  v a  2  s .  c om*/
        return pjp.proceed();
    } catch (ServiceException e) {
        throw e;
    } catch (Exception e) {
        final UUID id = uuidGenerator.get();
        final String msg = String.format("Internal service exception %s", id);
        logger.error(msg, e);
        throw new InternalServiceException(id);
    }
}