Class MockProtocol

java.lang.Object
org.apache.dubbo.rpc.protocol.AbstractProtocol
org.apache.dubbo.rpc.support.MockProtocol
All Implemented Interfaces:
ScopeModelAware, Protocol

public final class MockProtocol extends AbstractProtocol
MockProtocol is used for generating a mock invoker by URL and type on consumer side
  • Constructor Details

    • MockProtocol

      public MockProtocol()
  • Method Details

    • getDefaultPort

      public int getDefaultPort()
      Description copied from interface: Protocol
      Get default port when user doesn't config the port.
      Returns:
      default port
    • export

      public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException
      Description copied from interface: Protocol
      Export service for remote invocation:
      1. Protocol should record request source address after receive a request: RpcContext.getServerAttachment().setRemoteAddress();
      2. export() must be idempotent, that is, there's no difference between invoking once and invoking twice when export the same URL
      3. Invoker instance is passed in by the framework, protocol needs not to care
      Type Parameters:
      T - Service type
      Parameters:
      invoker - Service invoker
      Returns:
      exporter reference for exported service, useful for unexport the service later
      Throws:
      RpcException - thrown when error occurs during export the service, for example: port is occupied
    • protocolBindingRefer

      public <T> Invoker<T> protocolBindingRefer(Class<T> type, URL url) throws RpcException
      Throws:
      RpcException