public static InterceptorComponent replaceInterceptor(final Class match,
			final InterceptorComponent replacement, final InterceptorComponent chain) {
		if (chain == null) {
			return null;
		}

		InterceptorComponent current = chain;
		InterceptorComponent previous = null;
		InterceptorComponent updatedChain = null;

		while (updatedChain == null) {
			if (match.isInstance(current)) {
				// Found the interceptor that needs to be replaced.
				replacement.setBackingComponent(current.getBackingComponent());
				if (previous == null) {
					updatedChain = replacement;
				} else {
					previous.setBackingComponent(replacement);
					updatedChain = chain;
				}
			} else {
				previous = current;
				WebComponent next = current.getBackingComponent();

				if (next instanceof InterceptorComponent) {
					current = (InterceptorComponent) next;
				} else {
					// Reached the end of the chain. No replacement done.
					updatedChain = chain;
				}
			}
		}

		return updatedChain;
	}
public static InterceptorComponent replaceInterceptor ( final Class match , final InterceptorComponent replacement , final InterceptorComponent chain ) { if ( chain == null ) { return null ; } InterceptorComponent current = chain ; InterceptorComponent previous = null ; InterceptorComponent updatedChain = null ; while ( updatedChain == null ) { if ( match . isInstance ( current ) ) { replacement . setBackingComponent ( current . getBackingComponent ( ) ) ; if ( previous == null ) { updatedChain = replacement ; } else { previous . setBackingComponent ( replacement ) ; updatedChain = chain ; } } else { previous = current ; WebComponent next = current . getBackingComponent ( ) ; if ( next instanceof InterceptorComponent ) { current = ( InterceptorComponent ) next ; } else { updatedChain = chain ; } } } return updatedChain ; }
Utility method for replacing an individual interceptor within an existing chain.

@param match the type of the interceptor to be replaced.
@param replacement the new interceptor to be used as a replacement.
@param chain the existing interceptor chain in which the replacement will take place.
@return the modified interceptor chain. If no match was found, the existing interceptor chain is returned
unchanged.