List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed
public Object proceed() throws Throwable;
From source file:com.thesoftwareguild.olympian.SimpleTimerAspect.java
public Object timeMethod(ProceedingJoinPoint jp) { try {//from ww w . j ava2s . com //getArgs() get all args of whatever method you passed in Object retVal = null; long start = System.currentTimeMillis(); retVal = jp.proceed(); long end = System.currentTimeMillis(); System.out.println("-----------------------------------------"); System.out.println(jp.getSignature().getName() + " took " + (end - start) + "ms to execute"); System.out.println("-----------------------------------------"); return retVal; } catch (Throwable ex) { Logger.getLogger(SimpleTimerAspect.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:com.thinkbiganalytics.install.inspector.aop.logging.LoggingAspect.java
License:Apache License
/** * Advice that logs when a method is entered and exited. * * @param joinPoint join point for advice * @return result/*from w w w. j av a 2 s. c om*/ * @throws Throwable throws IllegalArgumentException */ @Around("applicationPackagePointcut() && springBeanPointcut()") public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { if (log.isDebugEnabled()) { log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs())); } try { Object result = joinPoint.proceed(); if (log.isDebugEnabled()) { log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), result); } return result; } catch (IllegalArgumentException e) { log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()), joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName()); throw e; } }
From source file:com.thinkbiganalytics.nifi.rest.config.NifiRestClientAroundAspect.java
License:Apache License
@Around("execution(* com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient.*(..))") public Object NifiRestClientAroundAspect(ProceedingJoinPoint joinPoint) throws Throwable { try {//w w w .j a v a 2 s .c o m Object obj = joinPoint.proceed(); return obj; } catch (Throwable ex) { if (ex instanceof ClientErrorException) { String err = ((ClientErrorException) ex).getResponse().readEntity(String.class); logger.error("Nifi Client Error Message: {}", err); } ex = NifiRestClientExceptionTranslator.translateException(ex); throw ex; } }
From source file:com.thoughtworks.go.server.web.InterceptorInjector.java
License:Apache License
public HandlerExecutionChain mergeInterceptorsToTabs(ProceedingJoinPoint pjp) throws Throwable { HandlerExecutionChain handlerExecutionChain = (HandlerExecutionChain) pjp.proceed(); if (handlerExecutionChain == null) { return null; }//from ww w .ja va 2 s . c o m return new HandlerExecutionChain(handlerExecutionChain.getHandler(), mergeInterceptors(handlerExecutionChain)); }
From source file:com.thoughtworks.go.server.web.InterceptorInjectorTest.java
License:Apache License
@Test public void testShouldMergeInterceptors() throws Throwable { HandlerInterceptor interceptorOfFramework = new HandlerInterceptorSub(); HandlerInterceptor interceptorOfTab = new HandlerInterceptorSub(); HandlerInterceptor[] interceptorsOfFramework = new HandlerInterceptor[] { interceptorOfFramework }; HandlerInterceptor[] interceptorsOfTab = new HandlerInterceptor[] { interceptorOfTab }; ProceedingJoinPoint proceedingJoinPoint = mock(ProceedingJoinPoint.class); when(proceedingJoinPoint.proceed()).thenReturn(new HandlerExecutionChain(null, interceptorsOfTab)); InterceptorInjector injector = new InterceptorInjector(); injector.setInterceptors(interceptorsOfFramework); HandlerExecutionChain handlers = injector.mergeInterceptorsToTabs(proceedingJoinPoint); Assert.assertEquals(2, handlers.getInterceptors().length); Assert.assertSame(interceptorOfFramework, handlers.getInterceptors()[0]); Assert.assertSame(interceptorOfTab, handlers.getInterceptors()[1]); }
From source file:com.thoughtworks.go.server.web.InterceptorInjectorTest.java
License:Apache License
@Test public void testShouldReturnNullWhenNoHandlerFound() throws Throwable { ProceedingJoinPoint proceedingJoinPoint = mock(ProceedingJoinPoint.class); when(proceedingJoinPoint.proceed()).thenReturn(null); InterceptorInjector injector = new InterceptorInjector(); HandlerExecutionChain handlers = injector.mergeInterceptorsToTabs(proceedingJoinPoint); Assert.assertNull(handlers);/* ww w . j a v a 2s.com*/ }
From source file:com.thoughtworks.go.server.web.InterceptorInjectorTest.java
License:Apache License
@Test public void testShouldNotChangeHandler() throws Throwable { SimpleUrlHandlerMapping handler = new SimpleUrlHandlerMapping(); ProceedingJoinPoint proceedingJoinPoint = mock(ProceedingJoinPoint.class); when(proceedingJoinPoint.proceed()).thenReturn(new HandlerExecutionChain(handler, null)); InterceptorInjector injector = new InterceptorInjector(); HandlerExecutionChain handlers = injector.mergeInterceptorsToTabs(proceedingJoinPoint); Assert.assertSame(handler, handlers.getHandler()); }
From source file:com.thoughtworks.go.server.web.InterceptorInjectorTest.java
License:Apache License
@Test public void testShouldJustReturnInterceptorsOfFrameworkIfNoTabInterceptors() throws Throwable { HandlerInterceptor interceptorOfFramework = new HandlerInterceptorSub(); HandlerInterceptor[] interceptorsOfFramework = new HandlerInterceptor[] { interceptorOfFramework }; ProceedingJoinPoint proceedingJoinPoint = mock(ProceedingJoinPoint.class); when(proceedingJoinPoint.proceed()).thenReturn(new HandlerExecutionChain(null, null)); InterceptorInjector injector = new InterceptorInjector(); injector.setInterceptors(interceptorsOfFramework); HandlerExecutionChain handlers = injector.mergeInterceptorsToTabs(proceedingJoinPoint); Assert.assertEquals(1, handlers.getInterceptors().length); Assert.assertSame(interceptorOfFramework, handlers.getInterceptors()[0]); }
From source file:com.tikal.tallerWeb.servicio.monitor.imp.EditorMonitorImpV3.java
License:Apache License
@Around("modelChange()") public void updateProperty(ProceedingJoinPoint pjp) throws Throwable { if (encendido && activo) { Object target = pjp.getTarget(); Object proxyTarget = AopContext.currentProxy(); if (!(target instanceof Metadata)) { String methodName = pjp.getSignature().getName(); String propertyName = StringUtils.substringAfter(methodName, "set"); String primeraLetra = propertyName.charAt(0) + ""; propertyName = primeraLetra.toLowerCase() + StringUtils.substringAfter(propertyName, primeraLetra); processChange(proxyTarget, propertyName, pjp.getArgs()[0]); }// ww w .j a v a2 s.com } pjp.proceed(); }
From source file:com.trailmagic.image.ImageSecurityAspect.java
License:Open Source License
@Around("springAdvised()") public Object around(final ProceedingJoinPoint thisJoinPoint) throws Throwable { if (securityInterceptor != null) { /** Hack to get around the AroundClosure not getting defined unless we call proceed here **/ new Runnable() { @Override//from w ww .ja va 2s. c o m public void run() { try { thisJoinPoint.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } } }; return securityInterceptor.invoke(thisJoinPoint); } else { throw new IllegalStateException("null security interceptor"); } }