Exemplo n.º 1
0
  @Override
  public Object intercept(InterceptionType type, T instance, final InvocationContext ctx) {
    final org.jboss.weld.interceptor.spi.model.InterceptionType interceptionType =
        org.jboss.weld.interceptor.spi.model.InterceptionType.valueOf(type.name());
    final List<InterceptorMethodInvocation> methodInvocations =
        interceptorMetadata
            .getInterceptorInvocation(instance, interceptionType)
            .getInterceptorMethodInvocations();

    Set<Annotation> interceptorBindings = null;
    if (ctx instanceof ExperimentalInvocationContext) {
      interceptorBindings =
          Reflections.<ExperimentalInvocationContext>cast(ctx).getInterceptorBindings();
    }

    try {
      /*
       * Calling Interceptor.intercept() may result in multiple interceptor method invocations (provided the interceptor class
       * interceptor methods on superclasses). This requires cooperation with InvocationContext.
       *
       * We use a wrapper InvocationContext for the purpose of executing the chain of
       * interceptor methods of this interceptor.
       */
      return new WeldInvocationContext(ctx, methodInvocations, interceptorBindings, null).proceed();
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new WeldException(e);
    }
  }
Exemplo n.º 2
0
 @Override
 public boolean intercepts(InterceptionType type) {
   return interceptorMetadata.isEligible(
       org.jboss.weld.interceptor.spi.model.InterceptionType.valueOf(type.name()));
 }
Exemplo n.º 3
0
 public static InterceptionType valueOf(
     javax.enterprise.inject.spi.InterceptionType interceptionType) {
   return valueOf(interceptionType.name());
 }