List of usage examples for org.aspectj.lang ProceedingJoinPoint getSignature
Signature getSignature();
getStaticPart().getSignature()
returns the same object From source file:io.curly.commons.logging.MethodExecutionAspectInterceptor.java
License:Apache License
@SuppressWarnings("ArgNamesErrorsInspection") @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 .c o 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:io.github.resilience4j.bulkhead.configure.BulkheadAspect.java
License:Apache License
@Around(value = "matchAnnotatedClassOrMethod(bulkheadAnnotation)", argNames = "proceedingJoinPoint, bulkheadAnnotation") public Object bulkheadAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, @Nullable Bulkhead bulkheadAnnotation) throws Throwable { Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod(); String methodName = method.getDeclaringClass().getName() + "#" + method.getName(); if (bulkheadAnnotation == null) { bulkheadAnnotation = geBulkheadAnnotation(proceedingJoinPoint); }//from w ww . j a va 2 s. c o m if (bulkheadAnnotation == null) { //because annotations wasn't found return proceedingJoinPoint.proceed(); } String backend = bulkheadAnnotation.name(); io.github.resilience4j.bulkhead.Bulkhead bulkhead = getOrCreateBulkhead(methodName, backend); Class<?> returnType = method.getReturnType(); if (StringUtils.isEmpty(bulkheadAnnotation.fallbackMethod())) { return proceed(proceedingJoinPoint, methodName, bulkhead, returnType); } FallbackMethod fallbackMethod = FallbackMethod.create(bulkheadAnnotation.fallbackMethod(), method, proceedingJoinPoint.getArgs(), proceedingJoinPoint.getTarget()); return fallbackDecorators .decorate(fallbackMethod, () -> proceed(proceedingJoinPoint, methodName, bulkhead, returnType)) .apply(); }
From source file:io.github.resilience4j.circuitbreaker.autoconfigure.CircuitBreakerAspect.java
License:Apache License
@Around(value = "matchAnnotatedClassOrMethod(backendMonitored)", argNames = "proceedingJoinPoint, backendMonitored") public Object circuitBreakerAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, CircuitBreaker backendMonitored) throws Throwable { Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod(); String methodName = method.getDeclaringClass().getName() + "#" + method.getName(); if (backendMonitored == null) { backendMonitored = getBackendMonitoredAnnotation(proceedingJoinPoint); }/*from www. j av a2s .co m*/ String backend = backendMonitored.backend(); io.github.resilience4j.circuitbreaker.CircuitBreaker circuitBreaker = getOrCreateCircuitBreaker(methodName, backend); return handleJoinPoint(proceedingJoinPoint, circuitBreaker, methodName); }
From source file:io.github.resilience4j.circuitbreaker.configure.CircuitBreakerAspect.java
License:Apache License
@Around(value = "matchAnnotatedClassOrMethod(circuitBreakerAnnotation)", argNames = "proceedingJoinPoint, circuitBreakerAnnotation") public Object circuitBreakerAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, @Nullable CircuitBreaker circuitBreakerAnnotation) throws Throwable { Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod(); String methodName = method.getDeclaringClass().getName() + "#" + method.getName(); if (circuitBreakerAnnotation == null) { circuitBreakerAnnotation = getCircuitBreakerAnnotation(proceedingJoinPoint); }//w ww. j a va2 s . c om if (circuitBreakerAnnotation == null) { //because annotations wasn't found return proceedingJoinPoint.proceed(); } String backend = circuitBreakerAnnotation.name(); io.github.resilience4j.circuitbreaker.CircuitBreaker circuitBreaker = getOrCreateCircuitBreaker(methodName, backend); Class<?> returnType = method.getReturnType(); if (StringUtils.isEmpty(circuitBreakerAnnotation.fallbackMethod())) { return proceed(proceedingJoinPoint, methodName, circuitBreaker, returnType); } FallbackMethod fallbackMethod = FallbackMethod.create(circuitBreakerAnnotation.fallbackMethod(), method, proceedingJoinPoint.getArgs(), proceedingJoinPoint.getTarget()); return fallbackDecorators.decorate(fallbackMethod, () -> proceed(proceedingJoinPoint, methodName, circuitBreaker, returnType)).apply(); }
From source file:io.github.resilience4j.ratelimiter.autoconfigure.RateLimiterAspect.java
License:Apache License
@Around(value = "matchAnnotatedClassOrMethod(limitedService)", argNames = "proceedingJoinPoint, limitedService") public Object rateLimiterAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, RateLimiter limitedService) throws Throwable { RateLimiter targetService = limitedService; Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod(); String methodName = method.getDeclaringClass().getName() + "#" + method.getName(); if (targetService == null) { targetService = getRateLimiterAnnotation(proceedingJoinPoint); }// w w w .j a va 2s . c om String name = targetService.name(); io.github.resilience4j.ratelimiter.RateLimiter rateLimiter = getOrCreateRateLimiter(methodName, name); return handleJoinPoint(proceedingJoinPoint, rateLimiter, methodName); }
From source file:io.github.resilience4j.ratelimiter.configure.RateLimiterAspect.java
License:Apache License
@Around(value = "matchAnnotatedClassOrMethod(rateLimiterAnnotation)", argNames = "proceedingJoinPoint, rateLimiterAnnotation") public Object rateLimiterAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, @Nullable RateLimiter rateLimiterAnnotation) throws Throwable { Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod(); String methodName = method.getDeclaringClass().getName() + "#" + method.getName(); if (rateLimiterAnnotation == null) { rateLimiterAnnotation = getRateLimiterAnnotation(proceedingJoinPoint); }/*from ww w .j av a 2s . co m*/ if (rateLimiterAnnotation == null) { //because annotations wasn't found return proceedingJoinPoint.proceed(); } String name = rateLimiterAnnotation.name(); io.github.resilience4j.ratelimiter.RateLimiter rateLimiter = getOrCreateRateLimiter(methodName, name); Class<?> returnType = method.getReturnType(); if (StringUtils.isEmpty(rateLimiterAnnotation.fallbackMethod())) { return proceed(proceedingJoinPoint, methodName, returnType, rateLimiter); } FallbackMethod fallbackMethod = FallbackMethod.create(rateLimiterAnnotation.fallbackMethod(), method, proceedingJoinPoint.getArgs(), proceedingJoinPoint.getTarget()); return fallbackDecorators .decorate(fallbackMethod, () -> proceed(proceedingJoinPoint, methodName, returnType, rateLimiter)) .apply(); }
From source file:io.github.resilience4j.retry.configure.RetryAspect.java
License:Apache License
@Around(value = "matchAnnotatedClassOrMethod(retryAnnotation)", argNames = "proceedingJoinPoint, retryAnnotation") public Object retryAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, @Nullable Retry retryAnnotation) throws Throwable { Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod(); String methodName = method.getDeclaringClass().getName() + "#" + method.getName(); if (retryAnnotation == null) { retryAnnotation = getRetryAnnotation(proceedingJoinPoint); }//from ww w . ja v a 2 s . com if (retryAnnotation == null) { //because annotations wasn't found return proceedingJoinPoint.proceed(); } String backend = retryAnnotation.name(); io.github.resilience4j.retry.Retry retry = getOrCreateRetry(methodName, backend); Class<?> returnType = method.getReturnType(); if (StringUtils.isEmpty(retryAnnotation.fallbackMethod())) { return proceed(proceedingJoinPoint, methodName, retry, returnType); } FallbackMethod fallbackMethod = FallbackMethod.create(retryAnnotation.fallbackMethod(), method, proceedingJoinPoint.getArgs(), proceedingJoinPoint.getTarget()); return fallbackDecorators .decorate(fallbackMethod, () -> proceed(proceedingJoinPoint, methodName, retry, returnType)) .apply(); }
From source file:io.helixservice.feature.jpa.transaction.TransactionalAspect.java
License:Open Source License
@SuppressWarnings("DuplicateThrows") @Around(value = "(execution(public * *(..)) && @annotation(transactional))" + " || (execution(public * *(..)) && within(@javax.transaction.Transactional *) && @annotation(transactional))") public Object around(ProceedingJoinPoint pjp, Transactional transactional) throws Throwable, SuspendExecution { Object result;//from w w w. j a v a2 s .c om Signature method = pjp.getSignature(); Object target = pjp.getTarget(); LOG.info("Managing transaction for method=" + method.getName() + ", target=" + target.getClass().getName() + ", txType=" + transactional.value()); validateTransactionalAnnotation(target, method, transactional); boolean commit = false; String persistenceContextName = beginTransaction(target); try { result = pjp.proceed(); commit = true; } catch (Throwable t) { commit = shouldCommitOnThrowable(transactional, t); LOG.info("Caught throwable=" + t.getClass().getName() + ", which results in commit=" + commit); throw t; } finally { LOG.trace("Skipping non-transactional method=" + method.getName() + ", target=" + target.getClass().getName()); endTransaction(persistenceContextName, commit); } return result; }
From source file:io.helixservice.feature.worker.BlockingWorkerAspect.java
License:Open Source License
private void assertRunningOnVertxWorkerThread(ProceedingJoinPoint pjp) { if (!onWorkerThread()) { /**/* w w w . j av a 2 s.co m*/ * This should never happen, it's a sanity check */ Signature signature = pjp.getSignature(); throw new IllegalStateException("Expected " + signature.getDeclaringTypeName() + "::" + signature.getName() + " to run on a Vert.x worker thread"); } }
From source file:io.jmnarloch.spring.boot.rxjava.utils.AopUtils.java
License:Apache License
public static Method getJointPointMethod(ProceedingJoinPoint joinPoint) { Method method = null;/*w w w. j av a 2 s . co m*/ if (joinPoint.getSignature() instanceof MethodSignature) { method = ((MethodSignature) joinPoint.getSignature()).getMethod(); } return method; }