javax.interceptor.Interceptor.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中javax.interceptor.Interceptor.<init>()方法的一些代码示例,展示了Interceptor.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Interceptor.<init>()方法的具体详情如下:
包路径:javax.interceptor.Interceptor
类名称:Interceptor
方法名:<init>

Interceptor.<init>介绍

暂无

代码示例

代码示例来源:origin: javaee-samples/javaee7-samples

/**
 * Class used to enable (activate) the dynamic interceptor and sets its priority
 * 
 * @author Arjan Tijms
 *
 */
@Interceptor
@Priority(200)
public class HelloInterceptorEnabler {

}

代码示例来源:origin: javaee-samples/javaee7-samples

/**
 * @author Arun Gupta
 */
@Priority(Interceptor.Priority.APPLICATION + 10)
@Interceptor
@MyAroundConstructInterceptorBinding
public class MyAroundConstructInterceptor {

  @AroundConstruct
  public void validateConstructor(InvocationContext context) {
    System.out.println("MyAroundConstructInterceptor.validateConstructor");
  }
}

代码示例来源:origin: javaee-samples/javaee7-samples

/**
 * 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();
  }
}

代码示例来源:origin: javaee-samples/javaee7-samples

/**
 * 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();
  }
}

代码示例来源:origin: jersey/jersey

@Priority(value = Interceptor.Priority.PLATFORM_BEFORE + 199)
@Interceptor
@Transactional
@JerseyVetoed

代码示例来源:origin: oracle/helidon

/**
 * 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);
  }
}

代码示例来源:origin: oracle/helidon

/**
 * 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();
  }
}

代码示例来源:origin: jersey/jersey

@Interceptor
@Priority(Interceptor.Priority.PLATFORM_AFTER + 800)
public class CdiInterceptorWrapper {

代码示例来源:origin: oracle/helidon

@Interceptor
@CommandBinding
@Priority(Interceptor.Priority.LIBRARY_AFTER)
public class CommandInterceptor {

代码示例来源:origin: oracle/helidon

@Interceptor
@Priority(Interceptor.Priority.PLATFORM_BEFORE + 8)
final class InterceptorCounted extends InterceptorBase<Counter, Counted> {

代码示例来源:origin: hibernate/hibernate-validator

@Interceptor
@Priority(Interceptor.Priority.PLATFORM_AFTER + 800)
public class ValidationInterceptor implements Serializable {

代码示例来源:origin: io.silverware/cdi-microservice-provider

@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();
 }
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Interceptor
@Priority(1002)
@Binding
public class Interceptor2 extends SuperInterceptor2 {

  @AroundInvoke
  public Object intercept1(InvocationContext ctx) throws Exception {
    ActionSequence.addAction(Interceptor2.class.getSimpleName());
    return ctx.proceed();
  }
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Interceptor
@Priority(1001)
@Binding
public class Interceptor1 extends MiddleInterceptor1 {

  @AroundTimeout
  public Object interceptTimeout2(InvocationContext ctx) throws Exception {
    ActionSequence.addAction(Interceptor1.class.getSimpleName());
    return ctx.proceed();
  }
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Priority(995)
@Transactional
@Interceptor
public class GloballyEnabledInterceptor1 extends AbstractInterceptor {

}

代码示例来源:origin: com.github.endoscope/endoscope-cdi-plugin

@Priority(Interceptor.Priority.APPLICATION)
@Interceptor
@WithEndoscope
public class CdiInterceptor {
  @AroundInvoke
  public Object monitorOperation(InvocationContext ctx) throws Exception {
    return Endoscope.monitorEx(getCallNameFromContext(ctx), () -> ctx.proceed() );
  }

  protected String getCallNameFromContext(InvocationContext ctx) {
    return ctx.getMethod().getDeclaringClass().getSimpleName() + "." + ctx.getMethod().getName();
  }
}

代码示例来源:origin: weld/core

@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();
  }
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@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());
  }
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Priority(1015)
@Transactional
@Interceptor
public class GloballyEnabledInterceptor3 extends AbstractInterceptor {

}

代码示例来源:origin: org.talend.sdk.component/component-server-proxy

@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()));
  }
}

相关文章