com.alibaba.dubbo.remoting.http.HttpServer Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.http.HttpServer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HessianProtocol.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    super.destroy();
    for (String key : new ArrayList<String>(serverMap.keySet())) {
        HttpServer server = serverMap.remove(key);
        if (server != null) {
            try {
                if (logger.isInfoEnabled()) {
                    logger.info("Close hessian server " + server.getUrl());
                }
                server.close();
            } catch (Throwable t) {
                logger.warn(t.getMessage(), t);
            }
        }
    }
}
 
Example #2
Source File: WebServiceProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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();
        }
    };
}
 
Example #3
Source File: HttpProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
        }
    };
}
 
Example #4
Source File: HessianProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    super.destroy();
    for (String key : new ArrayList<String>(serverMap.keySet())) {
        HttpServer server = serverMap.remove(key);
        if (server != null) {
            try {
                if (logger.isInfoEnabled()) {
                    logger.info("Close hessian server " + server.getUrl());
                }
                server.close();
            } catch (Throwable t) {
                logger.warn(t.getMessage(), t);
            }
        }
    }
}
 
Example #5
Source File: HessianProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
        }
    };
}
 
Example #6
Source File: RestfulProtocol.java    From dubbo-plus with Apache License 2.0 6 votes vote down vote up
@Override
protected <T> Runnable doExport(T impl, Class<T> type, final URL url) throws RpcException {
    String contextPath = ConfigUtils.getProperty("dubbo.protocol.restful.contextpath","/");
    String addr = url.getIp() + ":" + url.getPort();
    HttpServer server = SERVER_MAPPER.get(addr);
    if (server == null) {
        server = httpBinder.bind(url, new RestfulHandler(SERVICE_MAPPING_CONTAINER,contextPath));
        SERVER_MAPPER.put(addr, server);
    }
    SERVICE_MAPPING_CONTAINER.registerService(url,type,impl);
    return new Runnable() {
        @Override
        public void run() {
            SERVICE_MAPPING_CONTAINER.unregisterService(url);
        }
    };
}
 
Example #7
Source File: JsonRpcProtocol.java    From dubbo-rpc-jsonrpc with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    super.destroy();
    for (String key : new ArrayList<>(serverMap.keySet())) {
        HttpServer server = serverMap.remove(key);
        if (server != null) {
            try {
                if (logger.isInfoEnabled()) {
                    logger.info("Close jsonrpc server " + server.getUrl());
                }
                server.close();
            } catch (Throwable t) {
                logger.warn(t.getMessage(), t);
            }
        }
    }
}
 
Example #8
Source File: JsonRpcProtocol.java    From dubbo-rpc-jsonrpc with Apache License 2.0 6 votes vote down vote up
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 InternalHandler(url.getParameter("cors", false)));
        serverMap.put(addr, server);
    }
    final String path = url.getAbsolutePath();
    JsonRpcServer skeleton = new JsonRpcServer(impl, type);
    skeletonMap.put(path, skeleton);
    return new Runnable() {
        public void run() {
            skeletonMap.remove(path);
        }
    };
}
 
Example #9
Source File: WebServiceProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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(); //升级到cxf 3后编译失败,暂时注掉 - 杨俊明
            if (serverFactoryBean.getServer() != null) {
                serverFactoryBean.getServer().destroy();
            }
        }
    };
}
 
Example #10
Source File: HttpProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
        }
    };
}
 
Example #11
Source File: HessianProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    super.destroy();
    for (String key : new ArrayList<String>(serverMap.keySet())) {
        HttpServer server = serverMap.remove(key);
        if (server != null) {
            try {
                if (logger.isInfoEnabled()) {
                    logger.info("Close hessian server " + server.getUrl());
                }
                server.close();
            } catch (Throwable t) {
                logger.warn(t.getMessage(), t);
            }
        }
    }
}
 
Example #12
Source File: HessianProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
        }
    };
}
 
Example #13
Source File: WebServiceProtocol.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
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();
        }
    };
}
 
Example #14
Source File: HttpProtocol.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
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);
        }
    };
}
 
Example #15
Source File: HessianProtocol.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
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);
        }
    };
}
 
Example #16
Source File: WebServiceProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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();
        }
    };
}
 
Example #17
Source File: HessianProtocol.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
    String addr = getAddr(url);
    HttpServer server = serverMap.get(addr);
    if (server == null) {
        server = httpBinder.bind(url, new HessianHandler());
        serverMap.put(addr, server);
    }
    final String path = url.getAbsolutePath();
    final HessianSkeleton skeleton = new HessianSkeleton(impl, type);
    skeletonMap.put(path, skeleton);

    final String genericPath = path + "/" + Constants.GENERIC_KEY;
    skeletonMap.put(genericPath, new HessianSkeleton(impl, GenericService.class));

    return new Runnable() {
        @Override
        public void run() {
            skeletonMap.remove(path);
            skeletonMap.remove(genericPath);
        }
    };
}
 
Example #18
Source File: HessianProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    super.destroy();
    for (String key : new ArrayList<String>(serverMap.keySet())) {
        HttpServer server = serverMap.remove(key);
        if (server != null) {
            try {
                if (logger.isInfoEnabled()) {
                    logger.info("Close hessian server " + server.getUrl());
                }
                server.close();
            } catch (Throwable t) {
                logger.warn(t.getMessage(), t);
            }
        }
    }
}
 
Example #19
Source File: HessianProtocol.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public void destroy() {
    super.destroy();
    for (String key : new ArrayList<String>(serverMap.keySet())) {
        HttpServer server = serverMap.remove(key);
        if (server != null) {
            try {
                if (logger.isInfoEnabled()) {
                    logger.info("Close hessian server " + server.getUrl());
                }
                server.close();
            } catch (Throwable t) {
                logger.warn(t.getMessage(), t);
            }
        }
    }
}
 
Example #20
Source File: HessianProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
        }
    };
}
 
Example #21
Source File: HttpProtocol.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
protected <T> Runnable doExport(final T impl, Class<T> type, URL url) throws RpcException {
    String addr = getAddr(url);
    HttpServer server = serverMap.get(addr);
    if (server == null) {
        server = httpBinder.bind(url, new InternalHandler());
        serverMap.put(addr, server);
    }
    final String path = url.getAbsolutePath();
    skeletonMap.put(path, createExporter(impl, type));

    final String genericPath = path + "/" + Constants.GENERIC_KEY;

    skeletonMap.put(genericPath, createExporter(impl, GenericService.class));
    return new Runnable() {
        @Override
        public void run() {
            skeletonMap.remove(path);
            skeletonMap.remove(genericPath);
        }
    };
}
 
Example #22
Source File: JsonRpcProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    super.destroy();
    for (String key : new ArrayList<>(serverMap.keySet())) {
        HttpServer server = serverMap.remove(key);
        if (server != null) {
            try {
                if (logger.isInfoEnabled()) {
                    logger.info("Close jsonrpc server " + server.getUrl());
                }
                server.close();
            } catch (Throwable t) {
                logger.warn(t.getMessage(), t);
            }
        }
    }
}
 
Example #23
Source File: JsonRpcProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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 InternalHandler(url.getParameter("cors", false)));
        serverMap.put(addr, server);
    }
    final String path = url.getAbsolutePath();
    JsonRpcServer skeleton = new JsonRpcServer(impl, type);
    skeletonMap.put(path, skeleton);
    return new Runnable() {
        public void run() {
            skeletonMap.remove(path);
        }
    };
}
 
Example #24
Source File: HttpProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
        }
    };
}
 
Example #25
Source File: WebServiceProtocol.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
    String addr = getAddr(url);
    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() {
        @Override
        public void run() {
            if(serverFactoryBean.getServer()!= null) {
                serverFactoryBean.getServer().destroy();
            }
            if(serverFactoryBean.getBus()!=null) {
                serverFactoryBean.getBus().shutdown(true);
            }
        }
    };
}
 
Example #26
Source File: JettyHttpBinder.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public HttpServer bind(URL url, HttpHandler handler) {
    return new JettyHttpServer(url, handler);
}
 
Example #27
Source File: TomcatHttpBinder.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Override
public HttpServer bind(URL url, HttpHandler handler) {
    return new TomcatHttpServer(url, handler);
}
 
Example #28
Source File: JettyHttpBinder.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Override
public HttpServer bind(URL url, HttpHandler handler) {
    return new JettyHttpServer(url, handler);
}
 
Example #29
Source File: JettyHttpBinder.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public HttpServer bind(URL url, HttpHandler handler) {
    return new JettyHttpServer(url, handler);
}
 
Example #30
Source File: TomcatHttpBinder.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public HttpServer bind(URL url, HttpHandler handler) {
    return new TomcatHttpServer(url, handler);
}