@ SuppressWarnings ( "unchecked" ) public void call ( Serializer ser , InputStream is , OutputStream os ) throws IOException { Object obj = null ; try { obj = ser . readMapOrList ( is ) ; } catch ( Exception e ) { String msg = "Unable to deserialize request: " + e . getMessage ( ) ; ser . write ( new RpcResponse ( null , RpcException . Error . PARSE . exc ( msg ) ) . marshal ( ) , os ) ; return ; } if ( obj instanceof List ) { List list = ( List ) obj ; List respList = new ArrayList ( ) ; for ( Object o : list ) { RpcRequest rpcReq = new RpcRequest ( ( Map ) o ) ; respList . add ( call ( rpcReq ) . marshal ( ) ) ; } ser . write ( respList , os ) ; } else if ( obj instanceof Map ) { RpcRequest rpcReq = new RpcRequest ( ( Map ) obj ) ; ser . write ( call ( rpcReq ) . marshal ( ) , os ) ; } else { ser . write ( new RpcResponse ( null , RpcException . Error . INVALID_REQ . exc ( "Invalid Request" ) ) . marshal ( ) , os ) ; } }
Reads a RpcRequest from the input stream deserializes it invokes the matching handler method serializes the result and writes it to the output stream .