DUBBO-402 开源http协议支持timeout和client属性配置

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@1979 1a56cb94-b969-4eaa-88fa-be21384802f2
This commit is contained in:
william.liangf 2012-06-13 07:22:30 +00:00
parent 937520600d
commit a744e3961f
1 changed files with 8 additions and 8 deletions

View File

@ -56,7 +56,7 @@ public class HttpProtocol extends AbstractProxyProtocol {
private HttpBinder httpBinder;
public HttpProtocol() {
super(IOException.class);
super(RemoteAccessException.class);
}
public void setHttpBinder(HttpBinder httpBinder) {
@ -117,11 +117,7 @@ public class HttpProtocol extends AbstractProxyProtocol {
httpProxyFactoryBean.setServiceUrl(url.toIdentityString());
httpProxyFactoryBean.setServiceInterface(serviceType);
String client = url.getParameter(Constants.CLIENT_KEY);
if ("commons".equals(client)) {
CommonsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new CommonsHttpInvokerRequestExecutor();
httpInvokerRequestExecutor.setReadTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT));
httpProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
} else if ("simple".equals(client)) {
if (client == null || client.length() == 0 || "simple".equals(client)) {
SimpleHttpInvokerRequestExecutor httpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor() {
protected void prepareConnection(HttpURLConnection con,
int contentLength) throws IOException {
@ -131,6 +127,10 @@ public class HttpProtocol extends AbstractProxyProtocol {
}
};
httpProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
} else if ("commons".equals(client)) {
CommonsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new CommonsHttpInvokerRequestExecutor();
httpInvokerRequestExecutor.setReadTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT));
httpProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
} else if (client != null && client.length() > 0) {
throw new IllegalStateException("Unsupported http protocol client " + client + ", only supported: simple, commons");
}
@ -142,8 +142,8 @@ public class HttpProtocol extends AbstractProxyProtocol {
if (e instanceof RemoteAccessException) {
e = e.getCause();
}
if (e != null && e.getCause() != null) {
Class<?> cls = e.getCause().getClass();
if (e != null) {
Class<?> cls = e.getClass();
// 是根据测试Case发现的问题对RpcException.setCode进行设置
if (SocketTimeoutException.class.equals(cls)) {
return RpcException.TIMEOUT_EXCEPTION;