Search in sources :

Example 26 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project trafficController by amitkhosla.

the class TaskHelper method getTaskExecutorBasedOnAsyncProps.

/**
 * Get task executor for Controlled.
 * This method creates task executor with max consumer details.
 * @param async Controlled
 * @param joinPoint Join point
 * @return Task executor for required inputs
 */
protected TaskExecutor getTaskExecutorBasedOnAsyncProps(Controlled async, ProceedingJoinPoint joinPoint) {
    int maxConsumers = getConsumers(async.maxConsumer(), joinPoint);
    int maxSlowConsumers = getConsumers(async.maxSlowConsumer(), joinPoint);
    return getTaskExecutorForConsumersDetails(maxConsumers, maxSlowConsumers);
}
Also used : ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Example 27 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project gocd by gocd.

the class InterceptorInjectorTest method testShouldMergeInterceptors.

@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);
    assertEquals(2, handlers.getInterceptors().length);
    assertSame(interceptorOfFramework, handlers.getInterceptors()[0]);
    assertSame(interceptorOfTab, handlers.getInterceptors()[1]);
}
Also used : HandlerInterceptor(org.springframework.web.servlet.HandlerInterceptor) HandlerExecutionChain(org.springframework.web.servlet.HandlerExecutionChain) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Test(org.junit.jupiter.api.Test)

Example 28 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project gocd by gocd.

the class InterceptorInjectorTest method testShouldJustReturnInterceptorsOfFrameworkIfNoTabInterceptors.

@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);
    assertEquals(1, handlers.getInterceptors().length);
    assertSame(interceptorOfFramework, handlers.getInterceptors()[0]);
}
Also used : HandlerInterceptor(org.springframework.web.servlet.HandlerInterceptor) HandlerExecutionChain(org.springframework.web.servlet.HandlerExecutionChain) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Test(org.junit.jupiter.api.Test)

Example 29 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project gocd by gocd.

the class InterceptorInjectorTest method testShouldNotChangeHandler.

@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);
    assertSame(handler, handlers.getHandler());
}
Also used : HandlerExecutionChain(org.springframework.web.servlet.HandlerExecutionChain) SimpleUrlHandlerMapping(org.springframework.web.servlet.handler.SimpleUrlHandlerMapping) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Test(org.junit.jupiter.api.Test)

Example 30 with ProceedingJoinPoint

use of org.aspectj.lang.ProceedingJoinPoint in project spring-framework by spring-projects.

the class ProxyTargetClassTrueConfig method doubleReturnValue.

@Around("execution(int *.getAge())")
public Object doubleReturnValue(ProceedingJoinPoint pjp) throws Throwable {
    ++this.invocations;
    int result = (Integer) pjp.proceed();
    return result * this.multiple;
}
Also used : JoinPoint(org.aspectj.lang.JoinPoint) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Aggregations

ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)78 Around (org.aspectj.lang.annotation.Around)33 MethodSignature (org.aspectj.lang.reflect.MethodSignature)16 Method (java.lang.reflect.Method)14 Test (org.junit.Test)14 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)10 SimpleDateFormat (java.text.SimpleDateFormat)8 ArrayList (java.util.ArrayList)8 JoinPoint (org.aspectj.lang.JoinPoint)8 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)7 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)7 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)7 MockProceedingJoinPoint (org.finra.herd.core.MockProceedingJoinPoint)7 Annotation (java.lang.annotation.Annotation)5 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)4 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)4 Date (java.util.Date)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 Action (org.apache.nifi.action.Action)4 MessageHeader (org.finra.herd.model.dto.MessageHeader)4