Refine search
/** * Class used to enable (activate) the dynamic interceptor and sets its priority * * @author Arjan Tijms * */ @Interceptor @Priority(200) public class HelloInterceptorEnabler { }
/** * @author Arun Gupta */ @Priority(Interceptor.Priority.APPLICATION + 10) @Interceptor @MyAroundConstructInterceptorBinding public class MyAroundConstructInterceptor { @AroundConstruct public void validateConstructor(InvocationContext context) { System.out.println("MyAroundConstructInterceptor.validateConstructor"); } }
/** * Interceptors with smaller priority values are called first. * * @author Radim Hanus */ @Interceptor @MyInterceptorBinding @Priority(Interceptor.Priority.APPLICATION + 100) public class HighPriorityInterceptor { @AroundInvoke public Object log(InvocationContext context) throws Exception { Object[] parameters = context.getParameters(); if (parameters.length > 0 && parameters[0] instanceof String) { String param = (String) parameters[0]; parameters[0] = "Hi " + param + " !"; context.setParameters(parameters); } return context.proceed(); } }
/** * Interceptors with smaller priority values are called first. * * @author Radim Hanus */ @Interceptor @MyInterceptorBinding @Priority(Interceptor.Priority.APPLICATION + 200) public class LowPriorityInterceptor { @AroundInvoke public Object log(InvocationContext context) throws Exception { Object[] parameters = context.getParameters(); if (parameters.length > 0 && parameters[0] instanceof String) { String param = (String) parameters[0]; parameters[0] = param + " Nice to meet you."; context.setParameters(parameters); } return context.proceed(); } }
@Priority(value = Interceptor.Priority.PLATFORM_BEFORE + 199) @Interceptor @Transactional @JerseyVetoed
/** * Interceptor for {@link Timed} annotation. */ @Timed @Interceptor @Priority(Interceptor.Priority.PLATFORM_BEFORE + 10) final class InterceptorTimed extends InterceptorBase<Timer, Timed> { @Inject InterceptorTimed(MetricRegistry registry) { super(registry, Timed.class, Timed::name, Timed::absolute, MetricRegistry::getTimers, "timer"); } @Override protected Object prepareAndInvoke(Timer timer, Timed annotation, InvocationContext context) throws Exception { return timer.time(context::proceed); } }
/** * Interceptor for {@link Metered} annotation. */ @Metered @Interceptor @Priority(Interceptor.Priority.PLATFORM_BEFORE + 9) final class InterceptorMetered extends InterceptorBase<Meter, Metered> { @Inject InterceptorMetered(MetricRegistry registry) { super(registry, Metered.class, Metered::name, Metered::absolute, MetricRegistry::getMeters, "meter"); } @Override protected Object prepareAndInvoke(Meter meter, Metered annotation, InvocationContext context) throws Exception { meter.mark(); return context.proceed(); } }
@Interceptor @Priority(Interceptor.Priority.PLATFORM_AFTER + 800) public class CdiInterceptorWrapper {
@Interceptor @CommandBinding @Priority(Interceptor.Priority.LIBRARY_AFTER) public class CommandInterceptor {
@Interceptor @Priority(Interceptor.Priority.PLATFORM_BEFORE + 8) final class InterceptorCounted extends InterceptorBase<Counter, Counted> {
@Interceptor @Priority(Interceptor.Priority.PLATFORM_AFTER + 800) public class ValidationInterceptor implements Serializable {
@Dependent @Interceptor() @Priority(Interceptor.Priority.APPLICATION) @SuppressWarnings("checkstyle:JavadocType") public static class LoggingInterceptor { @AroundInvoke public Object log(final InvocationContext ic) throws Exception { log.info("AroundInvoke " + ic.toString()); return ic.proceed(); } }
@Interceptor @Transactional(Transactional.TxType.REQUIRED) @Priority(Interceptor.Priority.PLATFORM_BEFORE + 200) public class RequiredInterceptor extends InterceptorBase { @AroundInvoke public Object intercept(final InvocationContext ic) throws Exception { return super.intercept(ic); } @Override protected TransactionPolicy getPolicy() throws SystemException { return new TxRequired(getTransactionManager()); } }
@Priority(TestInterceptor.PRIORITY) @Interceptor @TestInterceptorBinding public class TestInterceptor implements Serializable{ public static final int PRIORITY = 10; @AroundInvoke public Object intercept(InvocationContext ctx) throws Exception { return ctx.proceed(); } }
@HelloAdder @Interceptor @Priority(500) public class HelloAdderInterceptor { @AroundInvoke public Object modifyGreet(InvocationContext context) throws Exception { if (context.getMethod().getName().equals("setGreet")) { context.setParameters(new Object[] { "Hello " + context.getParameters()[0] }); } return context.proceed(); } }
@Priority(Interceptor.Priority.APPLICATION + 420) @ProductInterceptorBinding3 @Interceptor public class ProductInterceptor3 { @AroundInvoke public Object aroundInvoke(InvocationContext invocationContext) throws Exception { ActionSequence.addAction(this.getClass().getSimpleName()); return (1 + (Integer)invocationContext.proceed()); } }
@Interceptor @Priority(1001) @Binding public class Interceptor1 extends MiddleInterceptor1 { @AroundInvoke public Object intercept2(InvocationContext ctx) throws Exception { ActionSequence.addAction(Interceptor1.class.getSimpleName()); return ctx.proceed(); } }
@Priority(Interceptor.Priority.APPLICATION + 400) @ProductInterceptorBinding1 @Interceptor public class ProductInterceptor1 { @AroundInvoke public Object aroundInvoke(InvocationContext invocationContext) throws Exception { ActionSequence.addAction(this.getClass().getSimpleName()); return (1 + (Integer)invocationContext.proceed()); } }
@Priority(1015) @Transactional @Interceptor public class GloballyEnabledInterceptor3 extends AbstractInterceptor { }
@Interceptor @AutoErrorHandling(single = false) @Priority(Interceptor.Priority.LIBRARY_BEFORE - 1) public class MultipleErrorHandlerInterceptor implements Serializable { @Inject private ErrorProcessor errorProcessor; @AroundInvoke public Object handle(final InvocationContext context) throws Exception { return errorProcessor.handleResponses(CompletionStage.class.cast(context.proceed())); } }