/** * Replaces the existing interceptor chain in the cache wih one represented by the interceptor * passed in. This utility updates dependencies on all components that rely on the interceptor * chain as well. * * @param cache cache that needs to be altered * @param interceptor the first interceptor in the new chain. */ public static void replaceInterceptorChain(Cache cache, CommandInterceptor interceptor) { ComponentRegistry cr = extractComponentRegistry(cache); // make sure all interceptors here are wired. CommandInterceptor i = interceptor; do { cr.wireDependencies(i); } while ((i = i.getNext()) != null); InterceptorChain inch = cr.getComponent(InterceptorChain.class); inch.setFirstInChain(interceptor); }
/** * Replaces an existing interceptor of the given type in the interceptor chain with a new * interceptor instance passed as parameter. * * @param replacingInterceptor the interceptor to add to the interceptor chain * @param toBeReplacedInterceptorType the type of interceptor that should be swapped with the new * one * @return true if the interceptor was replaced */ public static boolean replaceInterceptor( Cache cache, CommandInterceptor replacingInterceptor, Class<? extends CommandInterceptor> toBeReplacedInterceptorType) { ComponentRegistry cr = extractComponentRegistry(cache); // make sure all interceptors here are wired. CommandInterceptor i = replacingInterceptor; do { cr.wireDependencies(i); } while ((i = i.getNext()) != null); InterceptorChain inch = cr.getComponent(InterceptorChain.class); return inch.replaceInterceptor(replacingInterceptor, toBeReplacedInterceptorType); }
@Inject protected void injectDependencies(ComponentRegistry cr) { cr.wireDependencies(filter); }