Java Code Examples for org.mortbay.jetty.nio.SelectChannelConnector#setHost()
The following examples show how to use
org.mortbay.jetty.nio.SelectChannelConnector#setHost() .
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: HttpConnectorProvider.java From incubator-myriad with Apache License 2.0 | 5 votes |
@Override public Connector get() { SelectChannelConnector ret = new SelectChannelConnector(); ret.setName("Myriad"); ret.setHost("0.0.0.0"); ret.setPort(myriadConf.getRestApiPort()); return ret; }
Example 2
Source File: DevServer.java From yawp with MIT License | 5 votes |
private SelectChannelConnector createConnector() throws IOException { SelectChannelConnector connector = new SelectChannelConnector(); connector.setHost(mojo.getAddress()); connector.setPort(mojo.getPort()); connector.setSoLingerTime(0); connector.open(); return connector; }
Example 3
Source File: JettyServer.java From fiware-cygnus with GNU Affero General Public License v3.0 | 5 votes |
/** * Constructor. * @param mgmtIfPort * @param guiPort * @param handler * @param ipv6 */ public JettyServer(int mgmtIfPort, int guiPort, AbstractHandler handler, boolean ipv6) { // create the server server = new Server(); // add the Management Interface connector SelectChannelConnector conn1 = new SelectChannelConnector(); if (ipv6) { conn1.setHost("::0"); } else { conn1.setHost("0.0.0.0"); } // if else conn1.setPort(mgmtIfPort); server.addConnector(conn1); if (guiPort != 0) { // add the GUI connector SelectChannelConnector conn2 = new SelectChannelConnector(); if (ipv6) { conn2.setHost("::0"); } else { conn2.setHost("0.0.0.0"); } // if else conn2.setPort(guiPort); server.addConnector(conn2); } // if // set the handler server.setHandler(handler); }
Example 4
Source File: ProxyHttpServer.java From RDFS with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ protected Connector createBaseListener(Configuration conf) throws IOException { final String sAddr; if (null == (sAddr = conf.get("proxy.http.test.listener.addr"))) { SslSocketConnector sslListener = new SslSocketConnector(); sslListener.setKeystore(conf.get("ssl.server.keystore.location")); sslListener.setPassword(conf.get("ssl.server.keystore.password", "")); sslListener.setKeyPassword(conf.get("ssl.server.keystore.keypassword", "")); sslListener.setKeystoreType(conf.get("ssl.server.keystore.type", "jks")); sslListener.setNeedClientAuth(true); System.setProperty("javax.net.ssl.trustStore", conf.get("ssl.server.truststore.location", "")); System.setProperty("javax.net.ssl.trustStorePassword", conf.get("ssl.server.truststore.password", "")); System.setProperty("javax.net.ssl.trustStoreType", conf.get("ssl.server.truststore.type", "jks")); return sslListener; } // unit test InetSocketAddress proxyAddr = NetUtils.createSocketAddr(sAddr); SelectChannelConnector testlistener = new SelectChannelConnector(); testlistener.setUseDirectBuffers(false); testlistener.setHost(proxyAddr.getHostName()); testlistener.setPort(proxyAddr.getPort()); return testlistener; }
Example 5
Source File: ProxyHttpServer.java From hadoop-gpu with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ protected Connector createBaseListener(Configuration conf) throws IOException { final String sAddr; if (null == (sAddr = conf.get("proxy.http.test.listener.addr"))) { SslSocketConnector sslListener = new SslSocketConnector(); sslListener.setKeystore(conf.get("ssl.server.keystore.location")); sslListener.setPassword(conf.get("ssl.server.keystore.password", "")); sslListener.setKeyPassword(conf.get("ssl.server.keystore.keypassword", "")); sslListener.setKeystoreType(conf.get("ssl.server.keystore.type", "jks")); sslListener.setNeedClientAuth(true); System.setProperty("javax.net.ssl.trustStore", conf.get("ssl.server.truststore.location", "")); System.setProperty("javax.net.ssl.trustStorePassword", conf.get("ssl.server.truststore.password", "")); System.setProperty("javax.net.ssl.trustStoreType", conf.get("ssl.server.truststore.type", "jks")); return sslListener; } // unit test InetSocketAddress proxyAddr = NetUtils.createSocketAddr(sAddr); SelectChannelConnector testlistener = new SelectChannelConnector(); testlistener.setUseDirectBuffers(false); testlistener.setHost(proxyAddr.getHostName()); testlistener.setPort(proxyAddr.getPort()); return testlistener; }
Example 6
Source File: JettyHttpServer.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public JettyHttpServer(URL url, final HttpHandler handler) { super(url, handler); this.url = url; // TODO we should leave this setting to slf4j // we must disable the debug logging for production use Log.setLog(new StdErrLog()); Log.getLog().setDebugEnabled(false); DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), handler); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setDaemon(true); threadPool.setMaxThreads(threads); threadPool.setMinThreads(threads); SelectChannelConnector connector = new SelectChannelConnector(); String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost()); if (!url.isAnyHost() && NetUtils.isValidLocalHost(bindIp)) { connector.setHost(bindIp); } connector.setPort(url.getParameter(Constants.BIND_PORT_KEY, url.getPort())); server = new Server(); server.setThreadPool(threadPool); server.addConnector(connector); ServletHandler servletHandler = new ServletHandler(); ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*"); servletHolder.setInitOrder(2); // dubbo's original impl can't support the use of ServletContext // server.addHandler(servletHandler); // TODO Context.SESSIONS is the best option here? Context context = new Context(server, "/", Context.SESSIONS); context.setServletHandler(servletHandler); ServletManager.getInstance().addServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), context.getServletContext()); try { server.start(); } catch (Exception e) { throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(Constants.BIND_IP_KEY) + ":" + url.getParameter(Constants.BIND_PORT_KEY) + ", cause: " + e.getMessage(), e); } }
Example 7
Source File: JettyHttpServer.java From dubbox with Apache License 2.0 | 4 votes |
public JettyHttpServer(URL url, final HttpHandler handler){ super(url, handler); // modified by lishen this.url = url; // TODO we should leave this setting to slf4j Log.setLog(new StdErrLog()); Log.getLog().setDebugEnabled(false); DispatcherServlet.addHttpHandler(url.getPort(), handler); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setDaemon(true); threadPool.setMaxThreads(threads); threadPool.setMinThreads(threads); SelectChannelConnector connector = new SelectChannelConnector(); if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) { connector.setHost(url.getHost()); } connector.setPort(url.getPort()); server = new Server(); server.setThreadPool(threadPool); server.addConnector(connector); ServletHandler servletHandler = new ServletHandler(); ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*"); servletHolder.setInitOrder(2); // modified by lishen // dubbo's original impl can't support the use of ServletContext // server.addHandler(servletHandler); // TODO Context.SESSIONS is the best option here? Context context = new Context(server, "/", Context.SESSIONS); context.setServletHandler(servletHandler); ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext()); try { server.start(); } catch (Exception e) { throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: " + e.getMessage(), e); } }
Example 8
Source File: JettyHttpServer.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public JettyHttpServer(URL url, final HttpHandler handler){ super(url, handler); // modified by lishen this.url = url; // TODO we should leave this setting to slf4j Log.setLog(new StdErrLog()); Log.getLog().setDebugEnabled(false); DispatcherServlet.addHttpHandler(url.getPort(), handler); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setDaemon(true); threadPool.setMaxThreads(threads); threadPool.setMinThreads(threads); SelectChannelConnector connector = new SelectChannelConnector(); if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) { connector.setHost(url.getHost()); } connector.setPort(url.getPort()); server = new Server(); server.setThreadPool(threadPool); server.addConnector(connector); ServletHandler servletHandler = new ServletHandler(); ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*"); servletHolder.setInitOrder(2); // modified by lishen // dubbo's original impl can't support the use of ServletContext // server.addHandler(servletHandler); // TODO Context.SESSIONS is the best option here? Context context = new Context(server, "/", Context.SESSIONS); context.setServletHandler(servletHandler); ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext()); try { server.start(); } catch (Exception e) { throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: " + e.getMessage(), e); } }
Example 9
Source File: JettyHttpServer.java From dubbox with Apache License 2.0 | 4 votes |
public JettyHttpServer(URL url, final HttpHandler handler){ super(url, handler); // modified by lishen this.url = url; // TODO we should leave this setting to slf4j Log.setLog(new StdErrLog()); Log.getLog().setDebugEnabled(false); DispatcherServlet.addHttpHandler(url.getPort(), handler); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setDaemon(true); threadPool.setMaxThreads(threads); threadPool.setMinThreads(threads); SelectChannelConnector connector = new SelectChannelConnector(); if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) { connector.setHost(url.getHost()); } connector.setPort(url.getPort()); server = new Server(); server.setThreadPool(threadPool); server.addConnector(connector); ServletHandler servletHandler = new ServletHandler(); ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*"); servletHolder.setInitOrder(2); // modified by lishen // dubbo's original impl can't support the use of ServletContext // server.addHandler(servletHandler); // TODO Context.SESSIONS is the best option here? Context context = new Context(server, "/", Context.SESSIONS); context.setServletHandler(servletHandler); ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext()); try { server.start(); } catch (Exception e) { throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: " + e.getMessage(), e); } }
Example 10
Source File: SubsonicDeployer.java From subsonic with GNU General Public License v3.0 | 4 votes |
private void deployWebApp() { try { Server server = new Server(); SelectChannelConnector connector = new SelectChannelConnector(); connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS); connector.setHeaderBufferSize(HEADER_BUFFER_SIZE); connector.setHost(getHost()); connector.setPort(getPort()); if (isHttpsEnabled()) { connector.setConfidentialPort(getHttpsPort()); } server.addConnector(connector); if (isHttpsEnabled()) { SslSocketConnector sslConnector = new SslSocketConnector(); sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS); sslConnector.setHeaderBufferSize(HEADER_BUFFER_SIZE); sslConnector.setHost(getHost()); sslConnector.setPort(getHttpsPort()); sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm())); sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic")); server.addConnector(sslConnector); } WebAppContext context = new WebAppContext(); context.setTempDirectory(getJettyDirectory()); context.setContextPath(getContextPath()); context.setWar(getWar()); context.setOverrideDescriptor("/web-jetty.xml"); if (isHttpsEnabled()) { // Allow non-https for streaming and cover art (for Chromecast, UPnP, Sonos etc) context.getSecurityHandler().setConstraintMappings(new ConstraintMapping[]{ createConstraintMapping("/stream", Constraint.DC_NONE), createConstraintMapping("/coverArt.view", Constraint.DC_NONE), createConstraintMapping("/ws/*", Constraint.DC_NONE), createConstraintMapping("/sonos/*", Constraint.DC_NONE), createConstraintMapping("/", Constraint.DC_CONFIDENTIAL) }); } server.addHandler(context); server.start(); System.err.println("Subsonic running on: " + getUrl()); if (isHttpsEnabled()) { System.err.println(" and: " + getHttpsUrl()); } } catch (Throwable x) { x.printStackTrace(); exception = x; } }
Example 11
Source File: JettyHttpServer.java From dubbox with Apache License 2.0 | 4 votes |
public JettyHttpServer(URL url, final HttpHandler handler){ super(url, handler); // modified by lishen this.url = url; // TODO we should leave this setting to slf4j Log.setLog(new StdErrLog()); Log.getLog().setDebugEnabled(false); DispatcherServlet.addHttpHandler(url.getPort(), handler); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setDaemon(true); threadPool.setMaxThreads(threads); threadPool.setMinThreads(threads); SelectChannelConnector connector = new SelectChannelConnector(); if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) { connector.setHost(url.getHost()); } connector.setPort(url.getPort()); server = new Server(); server.setThreadPool(threadPool); server.addConnector(connector); ServletHandler servletHandler = new ServletHandler(); ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*"); servletHolder.setInitOrder(2); // modified by lishen // dubbo's original impl can't support the use of ServletContext // server.addHandler(servletHandler); // TODO Context.SESSIONS is the best option here? Context context = new Context(server, "/", Context.SESSIONS); context.setServletHandler(servletHandler); ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext()); try { server.start(); } catch (Exception e) { throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: " + e.getMessage(), e); } }