use of org.apache.xmlrpc.webserver.XmlRpcServletServer in project dubbo by alibaba.
the class XmlRpcProtocol method doExport.
@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
final URL httpUrl = url.setProtocol("http");
String addr = httpUrl.getIp() + ":" + httpUrl.getPort();
ProtocolServer protocolServer = serverMap.get(addr);
if (protocolServer == null) {
RemotingServer remotingServer = httpBinder.bind(httpUrl, new InternalHandler(httpUrl.getParameter("cors", false)));
serverMap.put(addr, new ProxyProtocolServer(remotingServer));
}
final String path = httpUrl.getAbsolutePath();
XmlRpcServletServer xmlRpcServer = new XmlRpcServletServer();
PropertyHandlerMapping propertyHandlerMapping = new PropertyHandlerMapping();
try {
propertyHandlerMapping.setRequestProcessorFactoryFactory(new RequestProcessorFactoryFactory() {
@Override
public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException {
return new RequestProcessorFactory() {
@Override
public Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException {
return impl;
}
};
}
});
propertyHandlerMapping.addHandler(XmlRpcProxyFactoryBean.replace(type.getName()), type);
} catch (Exception e) {
throw new RpcException(e);
}
xmlRpcServer.setHandlerMapping(propertyHandlerMapping);
XmlRpcServerConfigImpl xmlRpcServerConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
xmlRpcServerConfig.setEnabledForExceptions(true);
xmlRpcServerConfig.setContentLengthOptional(false);
skeletonMap.put(path, xmlRpcServer);
return new Runnable() {
@Override
public void run() {
skeletonMap.remove(path);
}
};
}
Aggregations