com.alibaba.dubbo.rpc.protocol
Class AbstractProxyProtocol

java.lang.Object
  extended by com.alibaba.dubbo.rpc.protocol.AbstractProtocol
      extended by com.alibaba.dubbo.rpc.protocol.AbstractProxyProtocol
All Implemented Interfaces:
Protocol
Direct Known Subclasses:
HessianProtocol, HttpProtocol, RmiProtocol, WebServiceProtocol

public abstract class AbstractProxyProtocol
extends AbstractProtocol

AbstractProxyProtocol

Author:
william.liangf

Constructor Summary
AbstractProxyProtocol()
           
AbstractProxyProtocol(Class<?>... exceptions)
           
 
Method Summary
 void addRpcException(Class<?> exception)
           
<T> Exporter<T>
export(Invoker<T> invoker)
          暴露远程服务:
1.
 ProxyFactory getProxyFactory()
           
<T> Invoker<T>
refer(Class<T> type, URL url)
          引用远程服务:
1.
 void setProxyFactory(ProxyFactory proxyFactory)
           
 
Methods inherited from class com.alibaba.dubbo.rpc.protocol.AbstractProtocol
destroy
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.alibaba.dubbo.rpc.Protocol
getDefaultPort
 

Constructor Detail

AbstractProxyProtocol

public AbstractProxyProtocol()

AbstractProxyProtocol

public AbstractProxyProtocol(Class<?>... exceptions)
Method Detail

addRpcException

public void addRpcException(Class<?> exception)

getProxyFactory

public ProxyFactory getProxyFactory()

setProxyFactory

public void setProxyFactory(ProxyFactory proxyFactory)

export

public <T> Exporter<T> export(Invoker<T> invoker)
                   throws RpcException
Description copied from interface: Protocol
暴露远程服务:
1. 协议在接收请求时,应记录请求来源方地址信息:RpcContext.getContext().setRemoteAddress();
2. export()必须是幂等的,也就是暴露同一个URL的Invoker两次,和暴露一次没有区别。
3. export()传入的Invoker由框架实现并传入,协议不需要关心。

Type Parameters:
T - 服务的类型
Parameters:
invoker - 服务的执行体
Returns:
exporter 暴露服务的引用,用于取消暴露
Throws:
RpcException - 当暴露服务出错时抛出,比如端口已占用

refer

public <T> Invoker<T> refer(Class<T> type,
                            URL url)
                 throws RpcException
Description copied from interface: Protocol
引用远程服务:
1. 当用户调用refer()所返回的Invoker对象的invoke()方法时,协议需相应执行同URL远端export()传入的Invoker对象的invoke()方法。
2. refer()返回的Invoker由协议实现,协议通常需要在此Invoker中发送远程请求。
3. 当url中有设置check=false时,连接失败不能抛出异常,并内部自动恢复。

Type Parameters:
T - 服务的类型
Parameters:
type - 服务的类型
url - 远程服务的URL地址
Returns:
invoker 服务的本地代理
Throws:
RpcException - 当连接服务提供方失败时抛出


Copyright © 2012–2017 Alibaba. All rights reserved.