Example usage for org.aspectj.lang ProceedingJoinPoint toShortString

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

Introduction

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

Prototype

String toShortString();

Source Link

Usage

From source file:com.variacode.utils.object.changelistener.ObservableObjectAspect.java

License:Apache License

@Around("execution(* *.set*(..)) && @within(annotation)")
public Object setMethod(ProceedingJoinPoint joinPoint, Observe annotation) throws Throwable {
    ObserverSingleton.INSTANCE.change(new Change(annotation.stream(),
            Introspector.decapitalize(joinPoint.toShortString()
                    .replaceFirst("execution\\(" + joinPoint.getThis().getClass().getSimpleName() + ".set", "")
                    .replaceAll("\\.", "").replaceAll("\\)", "").replaceAll("\\(", "")),
            joinPoint.getArgs()[0], joinPoint.getThis()));
    return joinPoint.proceed();
}

From source file:com.zoltran.perf.aspect.PerformanceMonitorAspect.java

License:Open Source License

@Around(value = "execution(@com.zoltran.perf.aspect.PerformanceMonitor * *(..)) && @annotation(annot)", argNames = "pjp,annot")
public Object performanceMonitoredMethod(ProceedingJoinPoint pjp, PerformanceMonitor annot) throws Throwable {
    final long start = System.currentTimeMillis();
    Object result = pjp.proceed();
    final long elapsed = System.currentTimeMillis() - start;
    MeasurementRecorderSource mrs = mrecSources.getUnchecked(annot.recorderSource());
    mrs.getRecorder(pjp.toLongString()).record(elapsed);
    if (elapsed > annot.warnThresholdMillis()) {
        if (elapsed > annot.errorThresholdMillis()) {
            LOG.error("Execution time  {} ms for {} exceeds error threshold of {} ms, arguments {}",
                    new Object[] { elapsed, pjp.toShortString(), annot.errorThresholdMillis(), pjp.getArgs() });
        } else {//from  www  . jav a 2  s.c o m
            LOG.warn("Execution time  {} ms for {} exceeds warning threshold of {} ms, arguments {}",
                    new Object[] { elapsed, pjp.toShortString(), annot.warnThresholdMillis(), pjp.getArgs() });
        }
    } else {
        LOG.debug("Execution time {} ms for {}, arguments {}",
                new Object[] { elapsed, pjp.toShortString(), pjp.getArgs() });
    }
    return result;
}

From source file:cs544.exercise13_1.TraceAdvice.java

@Around("execution (* cs544.exercise13_1.CustomerDAO.save(. .))")
public Object tracemethod3(ProceedingJoinPoint call) throws Throwable {
    StopWatch clock = new StopWatch("");
    clock.start(call.toShortString());
    Object object = call.proceed();
    clock.stop();// www . j av a 2  s . c o m
    System.out.println("Time to execute save = " + clock.getTotalTimeMillis() + " ms");

    return object;
}

From source file:curly.commons.logging.MethodExecutionAspectInterceptor.java

License:Apache License

@Around(value = "execution(* *(..)) && @annotation(loggable)) ", argNames = "joinPoint, loggable")
public Object invoke(ProceedingJoinPoint joinPoint, Loggable loggable) throws Throwable {
    if (executionEnabled) {
        StopWatch watch = new StopWatch(joinPoint.toShortString());
        watch.start();//from  w w  w  . j  a  v  a 2s. co m
        try {
            return joinPoint.proceed();
        } finally {
            watch.stop();
            synchronized (this) {
                if (actuatorEnabled && (gaugeService != null)) {
                    String gagueName = "gauge.execution." + joinPoint.getTarget() + "."
                            + joinPoint.getSignature().getName();
                    gaugeService.submit(gagueName, watch.getLastTaskTimeMillis());
                }
                log(loggable.value(), joinPoint.getTarget().getClass(), "Executed method {} in {} ms",
                        joinPoint.getSignature().getName(), watch.getLastTaskTimeMillis());
            }
        }

    }
    return joinPoint.proceed();
}

From source file:de.alexandria.cms.frontend.webapp.aop.AopMethodLogger.java

License:Apache License

/**
 *
 * Protokolliert die Laufzeit des join points. Das logging ist nur aktiv, wenn {@link #logger} mindestens
 * debug-Level hat./*  w w w. j  a  v a 2 s  .  com*/
 *
 * @param call
 * @return
 * @throws Throwable
 */
@Around("methodsToBeLogged()")
public Object logMethodDuration(ProceedingJoinPoint call) throws Throwable { // NOSONAR
    // proceed bentigt das Weiterreichen der Exception (throws Throwable)...
    Object returnValue;
    if (logger.isDebugEnabled()) {
        String targetClassName = call.getTarget().getClass().getName();
        String targetMethodName = call.getSignature().getName();
        Logger targetLog = LoggerFactory.getLogger(targetClassName);
        if (targetLog.isDebugEnabled()) {
            StopWatch clock = new StopWatch(getClass().getName());
            try {
                clock.start(call.toShortString());
                returnValue = call.proceed();
            } finally {
                clock.stop();
                String msg = createMsgForLogMethodDuration(targetMethodName, clock.getTotalTimeMillis());
                targetLog.debug(msg);
            }
        } else {
            returnValue = call.proceed();
        }
    } else {
        returnValue = call.proceed();
    }
    return returnValue;
}

From source file:de.codecentric.spring.boot.chaos.monkey.watcher.SpringComponentAspect.java

License:Apache License

@Around("classAnnotatedWithComponentPointcut() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()")
public Object intercept(ProceedingJoinPoint pjp) throws Throwable {
    // metrics//from   w ww. j a  v  a 2  s.c  o m
    if (metricEventPublisher != null)
        metricEventPublisher.publishMetricEvent(calculatePointcut(pjp.toShortString()), MetricType.COMPONENT);

    MethodSignature signature = (MethodSignature) pjp.getSignature();

    chaosMonkey.callChaosMonkey(createSignature(signature));

    return pjp.proceed();
}

From source file:de.codecentric.spring.boot.chaos.monkey.watcher.SpringControllerAspect.java

License:Apache License

@Around("classAnnotatedWithControllerPointcut() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()")
public Object intercept(ProceedingJoinPoint pjp) throws Throwable {

    MethodSignature signature = (MethodSignature) pjp.getSignature();
    // metrics/*w ww.j a v a  2 s  . c om*/
    if (metricEventPublisher != null)
        metricEventPublisher.publishMetricEvent(calculatePointcut(pjp.toShortString()), MetricType.CONTROLLER);

    chaosMonkey.callChaosMonkey(createSignature(signature));

    return pjp.proceed();
}

From source file:de.codecentric.spring.boot.chaos.monkey.watcher.SpringRepositoryAspect.java

License:Apache License

@Around("implementsCrudRepository() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()")
public Object intercept(ProceedingJoinPoint pjp) throws Throwable {

    // metrics/*from w  w  w.j a  va2s .  c  om*/
    if (metricEventPublisher != null)
        metricEventPublisher.publishMetricEvent(calculatePointcut(pjp.toShortString()), MetricType.REPOSITORY);

    MethodSignature signature = (MethodSignature) pjp.getSignature();

    chaosMonkey.callChaosMonkey(createSignature(signature));

    return pjp.proceed();
}

From source file:de.codecentric.spring.boot.chaos.monkey.watcher.SpringRestControllerAspect.java

License:Apache License

@Around("classAnnotatedWithControllerPointcut() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()")
public Object intercept(ProceedingJoinPoint pjp) throws Throwable {

    // metrics/*  w w  w. j  a v a  2  s .  c  om*/
    if (metricEventPublisher != null)
        metricEventPublisher.publishMetricEvent(calculatePointcut(pjp.toShortString()),
                MetricType.RESTCONTROLLER);

    MethodSignature signature = (MethodSignature) pjp.getSignature();

    chaosMonkey.callChaosMonkey(createSignature(signature));

    return pjp.proceed();
}

From source file:de.codecentric.spring.boot.chaos.monkey.watcher.SpringServiceAspect.java

License:Apache License

@Around("classAnnotatedWithControllerPointcut() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()")
public Object intercept(ProceedingJoinPoint pjp) throws Throwable {
    LOGGER.debug(//  w w  w .j a v  a2  s  .co m
            LOGGER.isDebugEnabled() ? "Service class and public method detected: " + pjp.getSignature() : null);

    if (metricEventPublisher != null)
        metricEventPublisher.publishMetricEvent(calculatePointcut(pjp.toShortString()), MetricType.SERVICE);

    MethodSignature signature = (MethodSignature) pjp.getSignature();

    chaosMonkey.callChaosMonkey(createSignature(signature));

    return pjp.proceed();
}