public void queryService ( List < StringCommand > commands , final QueryServiceCallback cb , Object context ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . QueryService ) ; List < QueryCommand > cs = new ArrayList < QueryCommand > ( ) ; for ( StringCommand c : commands ) { cs . add ( c . getStringCommand ( ) ) ; } QueryServiceProtocol p = new QueryServiceProtocol ( cs ) ; ProtocolCallback pcb = new ProtocolCallback ( ) { @ Override public void call ( boolean result , Response response , ErrorCode error , Object ctx ) { List < ModelServiceInstance > rsp = null ; if ( response != null ) { rsp = ( ( QueryServiceResponse ) response ) . getInstances ( ) ; } cb . call ( result , rsp , error , ctx ) ; } } ; connection . submitCallbackRequest ( header , p , pcb , context ) ; }
Query service in Callback .