@ SuppressWarnings ( "rawtypes" ) public static List < Handler > sortHandlers ( List < Handler > handlers ) { List < LogicalHandler < ? > > logicalHandlers = new ArrayList < LogicalHandler < ? > > ( ) ; List < Handler < ? > > protocolHandlers = new ArrayList < Handler < ? > > ( ) ; for ( Handler < ? > handler : handlers ) { if ( handler instanceof LogicalHandler ) { logicalHandlers . add ( ( LogicalHandler < ? > ) handler ) ; } else { protocolHandlers . add ( handler ) ; } } List < Handler > sortedHandlers = new ArrayList < Handler > ( logicalHandlers . size ( ) + protocolHandlers . size ( ) ) ; sortedHandlers . addAll ( logicalHandlers ) ; sortedHandlers . addAll ( protocolHandlers ) ; return sortedHandlers ; }
sorts the handlers into correct order . All of the logical handlers first followed by the protocol handlers