List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs
Object[] getArgs();
From source file:org.springframework.cloud.netflix.metrics.RestTemplateUrlTemplateCapturingAspect.java
License:Apache License
@Around("execution(* org.springframework.web.client.RestOperations+.*(String, ..))") Object captureUrlTemplate(ProceedingJoinPoint joinPoint) throws Throwable { try {// w w w . jav a 2s .co m String urlTemplate = (String) joinPoint.getArgs()[0]; RestTemplateUrlTemplateHolder.setRestTemplateUrlTemplate(urlTemplate); return joinPoint.proceed(); } finally { RestTemplateUrlTemplateHolder.clear(); } }
From source file:org.springframework.cloud.netflix.metrics.spectator.RestTemplateUrlTemplateCapturingAspect.java
License:Apache License
@Around("execution(* org.springframework.web.client.RestTemplate.*(String, ..))") void captureUrlTemplate(ProceedingJoinPoint joinPoint) throws Throwable { try {// w ww. ja v a 2s .co m String urlTemplate = (String) joinPoint.getArgs()[0]; RestTemplateUrlTemplateHolder.setRestTemplateUrlTemplate(urlTemplate); joinPoint.proceed(); } finally { RestTemplateUrlTemplateHolder.clear(); } }
From source file:org.springframework.cloud.sleuth.instrument.async.TraceAsyncAspect.java
License:Apache License
@Around("execution (* org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.*(..))") public Object traceThreadPoolTaskExecutor(final ProceedingJoinPoint pjp) throws Throwable { LazyTraceThreadPoolTaskExecutor executor = new LazyTraceThreadPoolTaskExecutor(this.beanFactory, (ThreadPoolTaskExecutor) pjp.getTarget()); Method methodOnTracedBean = getMethod(pjp, executor); if (methodOnTracedBean != null) { return methodOnTracedBean.invoke(executor, pjp.getArgs()); }//from w w w. j a v a 2s .c om return pjp.proceed(); }
From source file:org.springframework.cloud.sleuth.instrument.web.client.feign.TraceFeignAspect.java
License:Apache License
@Around("execution (* feign.Client.*(..)) && !within(is(FinalType))") public Object feignClientWasCalled(final ProceedingJoinPoint pjp) throws Throwable { Object[] args = pjp.getArgs(); Request request = (Request) args[0]; Request.Options options = (Request.Options) args[1]; Object bean = pjp.getTarget(); if (!(bean instanceof TraceFeignClient)) { return new TraceFeignClient(this.beanFactory, (Client) bean).execute(request, options); }/*w ww . ja v a2s . com*/ return pjp.proceed(); }
From source file:org.springframework.data.gemfire.serialization.json.JSONRegionAdvice.java
License:Apache License
@Around("execution(* org.apache.geode.cache.Region.create(..))" + " || execution(* org.apache.geode.cache.Region.put(..))" + " || execution(* org.apache.geode.cache.Region.putIfAbsent(..))" + " || execution(* org.apache.geode.cache.Region.replace(..))") public Object put(ProceedingJoinPoint pjp) { Object returnValue = null;//w w w . ja v a 2 s . c o m try { if (isIncludedJsonRegion(pjp.getTarget())) { Object[] newArgs = Arrays.copyOf(pjp.getArgs(), pjp.getArgs().length); Object val = newArgs[1]; newArgs[1] = convertToPdx(val); returnValue = pjp.proceed(newArgs); logger.debug("Converting [{}] to JSON", returnValue); returnValue = convertToJson(returnValue); } else { returnValue = pjp.proceed(); } } catch (Throwable cause) { handleThrowable(cause); } return returnValue; }
From source file:org.springframework.data.gemfire.serialization.json.JSONRegionAdvice.java
License:Apache License
@Around("execution(* org.apache.geode.cache.Region.putAll(..))") public Object putAll(ProceedingJoinPoint pjp) { Object returnValue = null;/*from ww w. jav a 2 s . c o m*/ try { if (isIncludedJsonRegion(pjp.getTarget())) { Object[] newArgs = Arrays.copyOf(pjp.getArgs(), pjp.getArgs().length); Map<?, ?> map = (Map<?, ?>) newArgs[0]; Map<Object, Object> newArg = new HashMap<>(); for (Entry<?, ?> entry : map.entrySet()) { newArg.put(entry.getKey(), convertToPdx(entry.getValue())); } newArgs[0] = newArg; returnValue = pjp.proceed(newArgs); } else { returnValue = pjp.proceed(); } } catch (Throwable cause) { handleThrowable(cause); } return returnValue; }
From source file:org.springframework.data.gemfire.support.JSONRegionAdvice.java
License:Apache License
@Around("execution(* com.gemstone.gemfire.cache.Region.put(..)) || " + "execution(* com.gemstone.gemfire.cache.Region.create(..)) ||" + "execution(* com.gemstone.gemfire.cache.Region.putIfAbsent(..)) ||" + "execution(* com.gemstone.gemfire.cache.Region.replace(..))") public Object put(ProceedingJoinPoint pjp) { boolean JSONRegion = isIncludedSONRegion(pjp.getTarget()); Object returnValue = null;//from w ww. ja v a 2s .c o m try { if (JSONRegion) { Object[] newArgs = Arrays.copyOf(pjp.getArgs(), pjp.getArgs().length); Object val = newArgs[1]; newArgs[1] = convertArgumentToPdxInstance(val); returnValue = pjp.proceed(newArgs); log.debug("converting " + returnValue + " to JSON string"); returnValue = convertPdxInstanceToJSONString(returnValue); } else { returnValue = pjp.proceed(); } } catch (Throwable t) { handleThrowable(t); } return returnValue; }
From source file:org.springframework.data.gemfire.support.JSONRegionAdvice.java
License:Apache License
@Around("execution(* com.gemstone.gemfire.cache.Region.putAll(..))") public Object putAll(ProceedingJoinPoint pjp) { boolean JSONRegion = isIncludedSONRegion(pjp.getTarget()); Object returnValue = null;/* ww w . j av a2 s . c o m*/ try { if (JSONRegion) { Object[] newArgs = Arrays.copyOf(pjp.getArgs(), pjp.getArgs().length); Map<?, ?> val = (Map<?, ?>) newArgs[0]; Map<Object, Object> newArg = new HashMap<Object, Object>(); for (Entry<?, ?> entry : val.entrySet()) { newArg.put(entry.getKey(), convertArgumentToPdxInstance(entry.getValue())); } newArgs[0] = newArg; returnValue = pjp.proceed(newArgs); } else { returnValue = pjp.proceed(); } } catch (Throwable t) { handleThrowable(t); } return returnValue; }
From source file:org.squashtest.tm.service.annotation.PreventConcurrentAspect.java
License:Open Source License
private <T> T findAnnotatedParam(ProceedingJoinPoint pjp, Class<? extends Annotation> expected) { MethodSignature sig = (MethodSignature) pjp.getSignature(); Method meth = sig.getMethod(); Annotation[][] annotations = meth.getParameterAnnotations(); LOGGER.trace("Advising method {}{}.", pjp.getSignature().getDeclaringTypeName(), meth.getName()); T annotatedParam = null;/*from w ww .j a v a 2 s. c o m*/ argsLoop: for (int iArg = 0; iArg < annotations.length; iArg++) { Annotation[] curArg = annotations[iArg]; annLoop: for (int jAnn = 0; jAnn < curArg.length; jAnn++) { if (curArg[jAnn].annotationType().equals(expected)) { LOGGER.trace("Found required @{} on arg #{} of method {}", new Object[] { expected.getSimpleName(), iArg, meth.getName() }); annotatedParam = (T) pjp.getArgs()[iArg]; break argsLoop; } } } if (annotatedParam == null) { throw new IllegalArgumentException("I coult not find any arg annotated @" + expected.getSimpleName() + " in @PreventConcurrent method '" + pjp.getSignature().getDeclaringTypeName() + '.' + meth.getName() + "' This must be a structural programming error"); } return annotatedParam; }
From source file:org.squashtest.tm.service.annotation.PreventConcurrentAspect.java
License:Open Source License
private <T> T findIdForNamedParam(ProceedingJoinPoint pjp, String paramName, Class<? extends Annotation> expected) { MethodSignature sig = (MethodSignature) pjp.getSignature(); Method meth = sig.getMethod(); Annotation[][] annotations = meth.getParameterAnnotations(); LOGGER.debug("Prevent Concurency - Advising method {}{}.", pjp.getSignature().getDeclaringTypeName(), meth.getName());//from ww w. j av a 2s. c o m T annotatedParam = null; argsLoop: for (int iArg = 0; iArg < annotations.length; iArg++) { Annotation[] curArg = annotations[iArg]; annLoop: for (int jAnn = 0; jAnn < curArg.length; jAnn++) { if (curArg[jAnn].annotationType().equals(expected)) { String annoValue = findAnnotationParamName(curArg[jAnn]); if (annoValue.equals(paramName)) { LOGGER.trace("Found required @{} on arg #{} of method {}", new Object[] { expected.getSimpleName(), iArg, meth.getName() }); annotatedParam = (T) pjp.getArgs()[iArg]; } else { throw new IllegalArgumentException("I coult not find any arg annotated @" + expected.getSimpleName() + " with a value of " + paramName + " in @PreventConcurrent method '" + pjp.getSignature().getDeclaringTypeName() + '.' + meth.getName() + ". Instead an @Id was found with a value of " + annoValue + "' This must be a structural programming error"); } break argsLoop; } } } if (annotatedParam == null) { throw new IllegalArgumentException("I coult not find any arg annotated @" + expected.getSimpleName() + " in @PreventConcurrent method '" + pjp.getSignature().getDeclaringTypeName() + '.' + meth.getName() + "' This must be a structural programming error"); } return annotatedParam; }