protected String selectSubprotocol ( String requestedSubprotocols ) { if ( requestedSubprotocols == null || subprotocols . length == 0 ) { return null ; } String [ ] requestedSubprotocolArray = requestedSubprotocols . split ( "," ) ; for ( String p : requestedSubprotocolArray ) { String requestedSubprotocol = p . trim ( ) ; for ( String supportedSubprotocol : subprotocols ) { if ( SUB_PROTOCOL_WILDCARD . equals ( supportedSubprotocol ) || requestedSubprotocol . equals ( supportedSubprotocol ) ) { selectedSubprotocol = requestedSubprotocol ; return requestedSubprotocol ; } } } // No match found return null ; }
Selects the first matching supported sub protocol