Search in sources :

Example 1 with JsonRpcServer

use of com.googlecode.jsonrpc4j.JsonRpcServer in project dubbo by alibaba.

the class HttpProtocol method doExport.

@Override
protected <T> Runnable doExport(final T impl, Class<T> type, URL url) throws RpcException {
    String addr = getAddr(url);
    ProtocolServer protocolServer = serverMap.get(addr);
    if (protocolServer == null) {
        RemotingServer remotingServer = httpBinder.bind(url, new InternalHandler(url.getParameter("cors", false)));
        serverMap.put(addr, new ProxyProtocolServer(remotingServer));
    }
    final String path = url.getAbsolutePath();
    final String genericPath = path + "/" + GENERIC_KEY;
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    JsonRpcServer skeleton = new JsonRpcServer(mapper, impl, type);
    JsonRpcServer genericServer = new JsonRpcServer(mapper, impl, GenericService.class);
    skeletonMap.put(path, skeleton);
    skeletonMap.put(genericPath, genericServer);
    return () -> {
        skeletonMap.remove(path);
        skeletonMap.remove(genericPath);
    };
}
Also used : ProtocolServer(org.apache.dubbo.rpc.ProtocolServer) JsonRpcServer(com.googlecode.jsonrpc4j.JsonRpcServer) RemotingServer(org.apache.dubbo.remoting.RemotingServer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonRpcServer (com.googlecode.jsonrpc4j.JsonRpcServer)1 RemotingServer (org.apache.dubbo.remoting.RemotingServer)1 ProtocolServer (org.apache.dubbo.rpc.ProtocolServer)1