public void printInterceptorChain ( InterceptorChain chain ) { Iterator < Interceptor < ? extends Message > > it = chain . iterator ( ) ; String phase = "" ; StringBuilder builder = null ; while ( it . hasNext ( ) ) { Interceptor < ? extends Message > interceptor = it . next ( ) ; if ( interceptor instanceof DemoInterceptor ) { continue ; } if ( interceptor instanceof PhaseInterceptor ) { PhaseInterceptor pi = ( PhaseInterceptor ) interceptor ; if ( ! phase . equals ( pi . getPhase ( ) ) ) { if ( builder != null ) { System . out . println ( builder . toString ( ) ) ; } else { builder = new StringBuilder ( 100 ) ; } builder . setLength ( 0 ) ; builder . append ( " " ) ; builder . append ( pi . getPhase ( ) ) ; builder . append ( ": " ) ; phase = pi . getPhase ( ) ; } String id = pi . getId ( ) ; int idx = id . lastIndexOf ( ' ' ) ; if ( idx != - 1 ) { id = id . substring ( idx + 1 ) ; } builder . append ( id ) ; builder . append ( ' ' ) ; } } }
Prints out the interceptor chain in a format that is easy to read . It also filters out instances of the DemoInterceptor so you can see what the chain would look like in a normal invokation .