Search in sources :

Example 1 with HttpServer

use of com.alibaba.dubbo.remoting.http.HttpServer in project dubbo by alibaba.

the class HessianProtocol method doExport.

protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
    String addr = url.getIp() + ":" + url.getPort();
    HttpServer server = serverMap.get(addr);
    if (server == null) {
        server = httpBinder.bind(url, new HessianHandler());
        serverMap.put(addr, server);
    }
    final String path = url.getAbsolutePath();
    HessianSkeleton skeleton = new HessianSkeleton(impl, type);
    skeletonMap.put(path, skeleton);
    return new Runnable() {

        public void run() {
            skeletonMap.remove(path);
        }
    };
}
Also used : HttpServer(com.alibaba.dubbo.remoting.http.HttpServer) HessianSkeleton(com.caucho.hessian.server.HessianSkeleton)

Example 2 with HttpServer

use of com.alibaba.dubbo.remoting.http.HttpServer in project dubbo by alibaba.

the class WebServiceProtocol method doExport.

protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
    String addr = url.getIp() + ":" + url.getPort();
    HttpServer httpServer = serverMap.get(addr);
    if (httpServer == null) {
        httpServer = httpBinder.bind(url, new WebServiceHandler());
        serverMap.put(addr, httpServer);
    }
    final ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
    serverFactoryBean.setAddress(url.getAbsolutePath());
    serverFactoryBean.setServiceClass(type);
    serverFactoryBean.setServiceBean(impl);
    serverFactoryBean.setBus(bus);
    serverFactoryBean.setDestinationFactory(transportFactory);
    serverFactoryBean.create();
    return new Runnable() {

        public void run() {
            serverFactoryBean.destroy();
        }
    };
}
Also used : HttpServer(com.alibaba.dubbo.remoting.http.HttpServer) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean)

Example 3 with HttpServer

use of com.alibaba.dubbo.remoting.http.HttpServer in project dubbo by alibaba.

the class HttpProtocol method doExport.

protected <T> Runnable doExport(final T impl, Class<T> type, URL url) throws RpcException {
    String addr = url.getIp() + ":" + url.getPort();
    HttpServer server = serverMap.get(addr);
    if (server == null) {
        server = httpBinder.bind(url, new InternalHandler());
        serverMap.put(addr, server);
    }
    final HttpInvokerServiceExporter httpServiceExporter = new HttpInvokerServiceExporter();
    httpServiceExporter.setServiceInterface(type);
    httpServiceExporter.setService(impl);
    try {
        httpServiceExporter.afterPropertiesSet();
    } catch (Exception e) {
        throw new RpcException(e.getMessage(), e);
    }
    final String path = url.getAbsolutePath();
    skeletonMap.put(path, httpServiceExporter);
    return new Runnable() {

        public void run() {
            skeletonMap.remove(path);
        }
    };
}
Also used : HttpInvokerServiceExporter(org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter) RpcException(com.alibaba.dubbo.rpc.RpcException) HttpServer(com.alibaba.dubbo.remoting.http.HttpServer) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) RpcException(com.alibaba.dubbo.rpc.RpcException) RemoteAccessException(org.springframework.remoting.RemoteAccessException) SocketTimeoutException(java.net.SocketTimeoutException)

Aggregations

HttpServer (com.alibaba.dubbo.remoting.http.HttpServer)3 RpcException (com.alibaba.dubbo.rpc.RpcException)1 HessianSkeleton (com.caucho.hessian.server.HessianSkeleton)1 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ServletException (javax.servlet.ServletException)1 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)1 RemoteAccessException (org.springframework.remoting.RemoteAccessException)1 HttpInvokerServiceExporter (org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter)1