org.eclipse.jetty.server.AbstractNetworkConnector Java Examples
The following examples show how to use
org.eclipse.jetty.server.AbstractNetworkConnector.
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: KaramelServiceApplication.java From karamel with Apache License 2.0 | 6 votes |
public int getPort(Environment environment) { int defaultPort = 9090; MutableServletContextHandler h = environment.getApplicationContext(); if (h == null) { return defaultPort; } Server s = h.getServer(); if (s == null) { return defaultPort; } Connector[] c = s.getConnectors(); if (c != null && c.length > 0) { AbstractNetworkConnector anc = (AbstractNetworkConnector) c[0]; if (anc != null) { return anc.getLocalPort(); } } return defaultPort; }
Example #2
Source File: GridJettyRestProtocol.java From ignite with Apache License 2.0 | 6 votes |
/** * Checks {@link org.apache.ignite.IgniteSystemProperties#IGNITE_JETTY_PORT} system property * and overrides default connector port if it present. * Then initializes {@code port} with the found value. * * @param con Jetty connector. */ private void override(AbstractNetworkConnector con) { String host = System.getProperty(IGNITE_JETTY_HOST); if (!F.isEmpty(host)) con.setHost(host); int currPort = con.getPort(); Integer overridePort = Integer.getInteger(IGNITE_JETTY_PORT); if (overridePort != null && overridePort != 0) currPort = overridePort; con.setPort(currPort); port = currPort; }
Example #3
Source File: JettyServer.java From DataLink with Apache License 2.0 | 5 votes |
public void startup() throws Exception { Resource configXml = Resource.newSystemResource(DEFAULT_JETTY_CONFIG); XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream()); server = (Server) configuration.configure(); Integer port = config.getHttpPort(); if (port != null && port > 0) { Connector[] connectors = server.getConnectors(); for (Connector connector : connectors) { if (connector instanceof AbstractNetworkConnector) { ((AbstractNetworkConnector) connector).setPort(port); } } } Handler handler = server.getHandler(); if (handler != null && handler instanceof WebAppContext) { WebAppContext webAppContext = (WebAppContext) handler; String webAppPath = System.getProperty("webapp.conf"); logger.info("Web App Path is " + webAppPath); if (StringUtils.isBlank(webAppPath)) { webAppContext.setResourceBase(JettyServer.class.getResource("/webapp").toString()); } else { webAppContext.setResourceBase(webAppPath); } } server.start(); if (logger.isInfoEnabled()) { logger.info("##Jetty Embed Server is started."); } }
Example #4
Source File: GridJettyRestProtocol.java From ignite with Apache License 2.0 | 5 votes |
/** * Checks that the only connector configured for the current jetty instance * and returns it. * * @return Connector instance. * @throws IgniteCheckedException If no or more than one connectors found. */ private AbstractNetworkConnector getJettyConnector() throws IgniteCheckedException { if (httpSrv.getConnectors().length == 1) { Connector connector = httpSrv.getConnectors()[0]; if (!(connector instanceof AbstractNetworkConnector)) throw new IgniteCheckedException("Error in jetty configuration. Jetty connector should extend " + "AbstractNetworkConnector class." ); return (AbstractNetworkConnector)connector; } else throw new IgniteCheckedException("Error in jetty configuration [connectorsFound=" + httpSrv.getConnectors().length + "connectorsExpected=1]"); }