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.swcguild.flooringmasteryspring.aspect.TimingAspect.java

public Object checkTimeElapsed(ProceedingJoinPoint jp) {
    Object ret = null;//from w  w w  . j av a 2s.  c o  m
    try {
        long start = System.currentTimeMillis();
        ret = jp.proceed();
        long end = System.currentTimeMillis();
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        System.out.println(jp.getSignature().getName() + " took " + (end - start) + " ms");
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
    } catch (Throwable t) {
        System.out.println("Exception in TimingAspect.checkTimeElapsed()");
    }
    return ret;
}

From source file:com.swcguild.olympian.SimpleTimerAspect.java

public Object timeMethod(ProceedingJoinPoint jp) {
    Object ret = null;/*w  w  w  . j  a v a  2 s .c  o m*/

    try {
        long start = System.currentTimeMillis();

        ret = jp.proceed();

        long end = System.currentTimeMillis();
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        System.out.println(jp.getSignature().getName() + " took " + (end - start) + " ms");
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
    } catch (Throwable t) {
        System.out.println("Exception in SimpleTimerAspect.timeMethod()");
    }

    return ret;
}

From source file:com.swguild.olympians.OlympicOfficial.java

public Object timeMethod(ProceedingJoinPoint jp) throws Throwable {
    Object ret = null;// ww  w  . j  a v  a2s  . c o  m

    try {
        // Note 2 - start timer
        long start = System.currentTimeMillis();
        // Note 3 - this allows the target method to execute
        ret = jp.proceed();
        // Note 4 - target method has returned, end timer and calc
        // elapsed time
        long end = System.currentTimeMillis();
        System.out.println("++++++++++++++++++++++++++++++++++++++++++");
        System.out.println(jp.getSignature().getName() + " took " + (end - start) + " ms");
        System.out.println("++++++++++++++++++++++++++++++++++++++++++");
    } catch (Throwable ex) {
        System.out.println("Exception in SimpleTimerAspect.timeMethod()");
    }
    // Note 5 - return whatever was returned by the target method (see
    // Note 3)
    return ret;
}

From source file:com.tasktop.c2c.server.common.service.ServiceLoggingAdvice.java

License:Open Source License

public Object doLogging(ProceedingJoinPoint pjp) throws Throwable {
    StopWatch stopWatch = new StopWatch();

    Throwable t = null;//w  w  w.j  a v  a2 s  . c  om
    Object result = null;
    try {
        stopWatch.start();
        result = pjp.proceed();
    } catch (Throwable e) {
        t = e;
    } finally {
        stopWatch.stop();
    }

    StringBuilder msg = new StringBuilder();

    msg.append("(time: ").append(stopWatch.getLastTaskTimeMillis() + "ms)");
    msg.append(" (user: ");

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth == null) {
        msg.append("<NO AUTH>"); // Should never hapen
    } else if (auth instanceof AnonymousAuthenticationToken) {
        msg.append("<ANONYMOUS>");
    } else {
        msg.append(auth.getName());
    }
    msg.append(")");

    msg.append(" (project: ").append(getProjectId()).append(") ");

    logCall(pjp, t, result, msg);

    logger.info(msg.toString());

    if (t != null) {
        throw t;
    } else {
        return result;
    }
}

From source file:com.thesoftwareguild.flooringmaster.aop.Audit.java

private Object logOrder(ProceedingJoinPoint jp) throws IOException {
    PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter("AuditLog.txt", true)));
    Object ret = null;/*from   w  w  w . j av  a  2s  .c o  m*/

    try {
        LocalDateTime logTime = LocalDateTime.now();
        String logTimeString = logTime.toString();
        writer.println(jp.getSignature().getName() + "::" + logTimeString);
        writer.flush();
        writer.close();
        ret = jp.proceed();
    } catch (Throwable ex) {
        System.out.println("Exception in Audit.logOrder()");

    }
    return ret;

}

From source file:com.thesoftwareguild.flooringmaster.aop.TimerAspect.java

public Object timeMethod(ProceedingJoinPoint jp) {

    Object ret = null;/*from  w ww  .  j  av a  2  s.c  o m*/
    try {

        long start = System.currentTimeMillis();
        ret = jp.proceed();
        long end = System.currentTimeMillis();
        System.out.println("+++++++++++++++++++++++++++++++++");
        System.out.println(jp.getSignature().getName() + " took " + (end - start) + "ms.");
        System.out.println("+++++++++++++++++++++++++++++++++");

    } catch (Throwable ex) {
        System.out.println("Exception in simpleTimerAspect.timeMethod()");

    }
    return ret;

}

From source file:com.thesoftwareguild.mavenflooringmastery.aspects.AuditAspect.java

public Object logCreate(ProceedingJoinPoint jp) {

    Object retVal = null;//from  www .java 2s  .  c  o m

    try {
        retVal = jp.proceed();

        Order order = (Order) jp.getArgs()[0];
        Date now = new Date();
        AuditEntry entry = new AuditEntry(now, order, "CREATED");

        dao.log(entry);

    } catch (Throwable ex) {
        Logger.getLogger(AuditAspect.class.getName()).log(Level.SEVERE, null, ex);
    }

    return retVal;

}

From source file:com.thesoftwareguild.mavenflooringmastery.aspects.AuditAspect.java

public Object logUpdate(ProceedingJoinPoint jp) {

    Object retVal = null;//from  ww  w .  j  a va 2  s.  c  o m

    try {
        retVal = jp.proceed();

        Order order = (Order) jp.getArgs()[0];
        Date now = new Date();
        AuditEntry entry = new AuditEntry(now, order, "UPDATED");

        dao.log(entry);

    } catch (Throwable ex) {
        Logger.getLogger(AuditAspect.class.getName()).log(Level.SEVERE, null, ex);
    }

    return retVal;

}

From source file:com.thesoftwareguild.mavenflooringmastery.aspects.AuditAspect.java

public Object logDelete(ProceedingJoinPoint jp) {

    Object retVal = null;//from   w w w.  j ava 2 s .  co m

    try {
        //retVal = jp.proceed(); CANT DO THIS BECAUSE AFTER THE METHOD DELETE IN ORDERDAO IS CALLED, the order is gone. It'll throw a nullpointerexception!

        Integer orderNumber = (Integer) jp.getArgs()[0]; //This is an Integer because the argument passed in the delete method is an integer
        Order order = odao.get(orderNumber);

        retVal = jp.proceed();

        Date now = new Date();
        AuditEntry entry = new AuditEntry(now, order, "DELETED");

        dao.log(entry);

    } catch (Throwable ex) {
        Logger.getLogger(AuditAspect.class.getName()).log(Level.SEVERE, null, ex);
    }

    return retVal;

}

From source file:com.thesoftwareguild.mavenflooringmastery.aspects.TimingAspect.java

public Object timeMethod(ProceedingJoinPoint jp) {

    Object ret = null;/*from  w  w w .  j  av  a2s .c  o m*/

    try {
        long start = System.currentTimeMillis();

        ret = jp.proceed();

        long end = System.currentTimeMillis();
        System.out.println("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
        System.out.println(jp.getSignature().getName() + " took " + (end - start) + " ms to execute.");
        System.out.println("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");

    } catch (Throwable ex) {
        System.out.println("Exception in TimingAspect.timeMethod()");
    }

    return ret;
}