接口 Protocol
-
- 所有已知实现类:
AbstractProtocol
,AbstractProxyProtocol
,DubboProtocol
,HessianProtocol
,HttpProtocol
,InjvmProtocol
,MemcachedProtocol
,MockProtocol
,ProtocolFilterWrapper
,ProtocolListenerWrapper
,QosProtocolWrapper
,RedisProtocol
,RegistryProtocol
,RestProtocol
,RmiProtocol
,ThriftProtocol
,WebServiceProtocol
@SPI("dubbo") public interface Protocol
Protocol. (API/SPI, Singleton, ThreadSafe)
-
-
方法详细资料
-
getDefaultPort
int getDefaultPort()
Get default port when user doesn't config the port.- 返回:
- default port
-
export
@Adaptive <T> Exporter<T> export(Invoker<T> invoker) throws RpcException
Export service for remote invocation:
1. Protocol should record request source address after receive a request: RpcContext.getContext().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- 类型参数:
T
- Service type- 参数:
invoker
- Service invoker- 返回:
- exporter reference for exported service, useful for unexport the service later
- 抛出:
RpcException
- thrown when error occurs during export the service, for example: port is occupied
-
refer
@Adaptive <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException
Refer a remote service:
1. When user calls `invoke()` method of `Invoker` object which's returned from `refer()` call, the protocol needs to correspondingly execute `invoke()` method of `Invoker` object
2. It's protocol's responsibility to implement `Invoker` which's returned from `refer()`. Generally speaking, protocol sends remote request in the `Invoker` implementation.
3. When there's check=false set in URL, the implementation must not throw exception but try to recover when connection fails.- 类型参数:
T
- Service type- 参数:
type
- Service classurl
- URL address for the remote service- 返回:
- invoker service's local proxy
- 抛出:
RpcException
- when there's any error while connecting to the service provider
-
destroy
void destroy()
Destroy protocol:
1. Cancel all services this protocol exports and refers
2. Release all occupied resources, for example: connection, port, etc.
3. Protocol can continue to export and refer new service even after it's destroyed.
-
-