Creates an interceptor chain.

@param <T> the function parameter type
@param <R> the function result type
@param innermost the function to be intercepted
@param interceptors an array of interceptor
@return the resulting function
481973
public static <T, R> Function<T, R> intercept(Function<T, R> innermost, Interceptor<T>... interceptors) {
        return new InterceptorChain<>(innermost, new ArrayIterator<Interceptor<T>>(interceptors));
    }
1371255
protected Interceptor ensureInterceptor( String n )
    {
        Interceptor i = null;
        if ( _interceptors == null )
        {
            _interceptors = new HashMap<String,Interceptor>();
        }
        else
        {
            i = _interceptors.get( n );
        }

        if ( i == null )
        {
            try
            {
                i  = (Interceptor) getControlService( getControlBeanContext().getClassLoader().loadClass( n ), null );
            }
            catch ( Exception e )
            {
                // Couldn't instantiate the desired service; usually this is because the service interface itself
                // isn't present on this system at runtime (ClassNotFoundException), or if the container of the
                // control didn't registers the service.

                /* TODO log a message here to that effect, but just swallow the exception for now. */
            }
            finally
            {
                // We want to always return an interceptor, so if we can't get the one we want, we'll substitute
                // a "null" interceptor that does nothing.
                if ( i == null)
                    i = new NullInterceptor();

                _interceptors.put( n, i );
            }
        }
        return i;
    }
835386
public Interceptors<Beans<T>> getOrCreateInterceptors()
   {
      Node node = childNode.getOrCreate("interceptors");
      Interceptors<Beans<T>> interceptors = new InterceptorsImpl<Beans<T>>(this, "interceptors", childNode, node);
      return interceptors;
   }
293694
@SafeVarargs
    public static <T> Callback<T> chain(Callback<T>... callbacks)
    {
        return chain(Arrays.asList(callbacks));
    }
36059
public EnvEntryType<InterceptorType<T>> getOrCreateEnvEntry()
   {
      List<Node> nodeList = childNode.get("env-entry");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new EnvEntryTypeImpl<InterceptorType<T>>(this, "env-entry", childNode, nodeList.get(0));
      }
      return createEnvEntry();
   }
385433
function _getLastInterceptor(method_definition, channel, responder) {
  var callback = (responder instanceof Function) ? responder : function() {};
  var emitter = (responder instanceof EventEmitter) ? responder :
                                                      new EventEmitter();
  var method_type = common.getMethodType(method_definition);
  var generator = interceptorGenerators[method_type];
  return generator(method_definition, channel, emitter, callback);
}
1080602
private static <T, G extends T> void generateSetInterceptor(DexMaker dexMaker,
                                                                TypeId<G> generatedType,
                                                                TypeId<T> baseType) {
        final FieldId<G, Interceptor> interceptorField =
                generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);

        final String methodName = ViewMethod.SET_INTERCEPTOR.getName();

        final MethodId<G, Void> methodId = generatedType.getMethod(VOID_TYPE, methodName,
                INTERCEPTOR_TYPE);
        final Code code = dexMaker.declare(methodId, PUBLIC);

        final Local<G> localThis = code.getThis(generatedType);
        final Local<Interceptor> localInterceptor = code.getParameter(0, INTERCEPTOR_TYPE);
        code.iput(interceptorField, localThis, localInterceptor);
        code.returnVoid();
    }
227545
public List<Interceptor<?>> getInterceptors(J2EEName ejbJ2EEName, Method method, InterceptionType interceptionType) {
        List<Interceptor<?>> interceptors = new ArrayList<Interceptor<?>>();

        //find the Interceptor Bindings for the ejb
        InterceptorBindings ejbInterceptors = allInterceptors.get(ejbJ2EEName);

        if (ejbInterceptors != null) {
            //get the method interceptors of the right type

            org.jboss.weld.interceptor.spi.model.InterceptionType internalInterceptionType =
                            org.jboss.weld.interceptor.spi.model.InterceptionType.valueOf(interceptionType.name());

            if (internalInterceptionType.isLifecycleCallback()) {
                List<Interceptor<?>> lifecycleInterceptors = ejbInterceptors.getLifecycleInterceptors(interceptionType);
                interceptors.addAll(lifecycleInterceptors);
            }
            else {
                List<Interceptor<?>> methodInterceptors = ejbInterceptors.getMethodInterceptors(interceptionType, method);
                interceptors.addAll(methodInterceptors);
            }
        }

        return interceptors;

    }
201702
public T withEventInterceptors(List<Interceptor<?>> interceptors) {
        configMap.put(EVENT_INTERCEPTORS, interceptors);
        return getThis();
    }
911507
@SuppressWarnings({ "unchecked", "rawtypes" })
    public <T> T createProxy(ClassLoader classLoader) {

        LettuceAssert.notNull(classLoader, "ClassLoader must not be null");

        Class<?>[] interfaces = this.interfaces.toArray(new Class[0]);

        return (T) Proxy.newProxyInstance(classLoader, interfaces, new InterceptorChainInvocationHandler(interceptors));
    }
879371
public static Interceptor getChainedInterceptor(Collection<Interceptor> instances) {
        final int size = instances.size();
        return size == 1 ? instances.iterator().next() : new ChainedInterceptor(instances.toArray(Interceptor.EMPTY_ARRAY));
    }
1048479
public Interceptor create(final InterceptorFactoryContext context) {
        final InterceptorFactory[] factories = interceptorFactories;
        final int length = factories.length;
        final Interceptor[] interceptors = new Interceptor[length];
        for (int i = 0; i < length; i++) {
            interceptors[i] = factories[i].create(context);
        }
        return new ChainedInterceptor(interceptors);
    }
639920
function iterate(self, interceptors, args, after) {
      if (!interceptors || !interceptors.length) {
        after.apply(self, args);
        return;
      }

      var i = 0;
      var len = interceptors.length;
      if (!len) {
        after.apply(self, args);
        return;
      }

      function nextInterceptor() {
        if (i === len) {
          i++;
          after.apply(self, arguments);
        }
        else if (i < len) {
          var used = false;
          var interceptor = interceptors[i++];
          interceptor.apply(self, Array.prototype.slice.call(arguments, 1).concat(function next(err) {
            //
            // Do not allow multiple continuations
            //
            if (used) { return; }

            used = true;
            if (!err || !callback) {
              nextInterceptor.apply(null, waterfall ? arguments : args);
            } else {
              after.call(self, err);
            }
          }));
        }
      }
      nextInterceptor.apply(null, args);
    }
770258
public HttpServerInterceptorChain<I, O, II, OO> next(final Interceptor<II, OO> next) {
        return new HttpServerInterceptorChain<>(new TransformingInterceptor<I, O, II, OO>() {
            @Override
            public RequestHandler<I, O> intercept(RequestHandler<II, OO> handler) {
                return interceptor.intercept(next.intercept(handler));
            }
        });
    }
70805
@Internal
    public static Interceptor[] resolveAroundInterceptors(BeanContext beanContext, ExecutableMethod<?, ?> method, Interceptor... interceptors) {
        instrumentAnnotationMetadata(beanContext, method);
        return resolveInterceptorsInternal(method, Around.class, interceptors);
    }
411570
private static <T, G extends T> void generateConstructorAndFields(DexMaker dexMaker,
                                                                      TypeId<G> generatedType,
                                                                      TypeId<T> baseType) {
        final FieldId<G, Interceptor> interceptorField =
                generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);
        dexMaker.declare(interceptorField, PRIVATE, null);

        final TypeId<?>[] types = classArrayToTypeArray(CONSTRUCTOR_ARG_TYPES);
        final MethodId<?, ?> constructor = generatedType.getConstructor(types);
        final Code constructorCode = dexMaker.declare(constructor, PUBLIC);

        final Local<?>[] params = new Local[types.length];
        for (int i = 0; i < params.length; ++i) {
            params[i] = constructorCode.getParameter(i, types[i]);
        }

        final MethodId<T, ?> superConstructor = baseType.getConstructor(types);
        final Local<G> thisRef = constructorCode.getThis(generatedType);
        constructorCode.invokeDirect(superConstructor, null, thisRef, params);
        constructorCode.returnVoid();
    }
1069174
@Override
    public Response intercept(Interceptor.Chain chain) throws IOException {
        Request newRequest = this.signHeader(chain.request());
        return chain.proceed(newRequest);
    }