code: public void registerServiceInstance(ProvidedServiceInstance instance, final RegistrationCallback cb, Object context){
  
          ProtocolHeader header = new ProtocolHeader();
          header.setType(ProtocolType.RegisterServiceInstance);
  
          RegisterServiceInstanceProtocol p = new RegisterServiceInstanceProtocol(instance);
  
          ProtocolCallback pcb = new ProtocolCallback(){
  
              @Override
              public void call(boolean result, Response response,
                      ErrorCode error, Object ctx) {
                  cb.call(result, error, ctx);
              }
  
          };
  
          connection.submitCallbackRequest(header, p, pcb, context);
  
      }
docs: Register ServiceInstance with Callback.
  
  @param instance
  the ProvidedServiceInstance.
  @param cb
  the callback.
  @param context
  the context Object.