use of org.eclipse.jetty.xml.XmlConfiguration in project jena by apache.
the class SPARQLServer method configServer.
private static Server configServer(String jettyConfig) {
try {
serverLog.info("Jetty server config file = " + jettyConfig);
Server server = new Server();
XmlConfiguration configuration = new XmlConfiguration(new FileInputStream(jettyConfig));
configuration.configure(server);
return server;
} catch (Exception ex) {
serverLog.error("SPARQLServer: Failed to configure server: " + ex.getMessage(), ex);
throw new FusekiException("Failed to configure a server using configuration file '" + jettyConfig + "'");
}
}
use of org.eclipse.jetty.xml.XmlConfiguration in project cuba by cuba-platform.
the class CubaJettyServer method createServer.
protected Server createServer() throws Exception {
ClassLoader serverClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader sharedClassLoader = new URLClassLoader(pathsToURLs(serverClassLoader, SHARED_CLASS_PATH_IN_JAR), serverClassLoader);
Server server;
if (jettyConfUrl != null) {
XmlConfiguration xmlConfiguration = new XmlConfiguration(jettyConfUrl);
server = (Server) xmlConfiguration.configure();
} else {
server = new Server(port);
}
server.setStopAtShutdown(true);
List<Handler> handlers = new ArrayList<>();
if (CubaJettyUtils.hasCoreApp(serverClassLoader)) {
String coreContextPath = contextPath;
if (isSingleJar(serverClassLoader)) {
if (PATH_DELIMITER.equals(contextPath)) {
coreContextPath = PATH_DELIMITER + "app-core";
} else {
coreContextPath = contextPath + "-core";
}
}
handlers.add(createAppContext(serverClassLoader, sharedClassLoader, CORE_PATH_IN_JAR, coreContextPath));
}
if (hasWebApp(serverClassLoader)) {
handlers.add(createAppContext(serverClassLoader, sharedClassLoader, WEB_PATH_IN_JAR, contextPath));
}
if (hasPortalApp(serverClassLoader)) {
String portalContextPath = contextPath;
if (isSingleJar(serverClassLoader)) {
portalContextPath = this.portalContextPath;
}
handlers.add(createAppContext(serverClassLoader, sharedClassLoader, PORTAL_PATH_IN_JAR, portalContextPath));
}
if (hasFrontApp(serverClassLoader)) {
handlers.add(createFrontAppContext(serverClassLoader, sharedClassLoader));
}
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(handlers.toArray(new Handler[handlers.size()]));
server.setHandler(handlerCollection);
return server;
}
use of org.eclipse.jetty.xml.XmlConfiguration in project ignite by apache.
the class GridJettyRestProtocol method loadJettyConfiguration.
/**
* Loads jetty configuration from the given URL.
*
* @param cfgUrl URL to load configuration from.
* @throws IgniteCheckedException if load failed.
*/
private void loadJettyConfiguration(@Nullable URL cfgUrl) throws IgniteCheckedException {
if (cfgUrl == null) {
HttpConfiguration httpCfg = new HttpConfiguration();
httpCfg.setSecureScheme("https");
httpCfg.setSecurePort(8443);
httpCfg.setSendServerVersion(true);
httpCfg.setSendDateHeader(true);
String srvPortStr = System.getProperty(IGNITE_JETTY_PORT, "8080");
int srvPort;
try {
srvPort = Integer.parseInt(srvPortStr);
} catch (NumberFormatException ignore) {
throw new IgniteCheckedException("Failed to start Jetty server because IGNITE_JETTY_PORT system property " + "cannot be cast to integer: " + srvPortStr);
}
httpSrv = new Server(new QueuedThreadPool(200, 20));
ServerConnector srvConn = new ServerConnector(httpSrv, new HttpConnectionFactory(httpCfg));
srvConn.setHost(System.getProperty(IGNITE_JETTY_HOST, "localhost"));
srvConn.setPort(srvPort);
srvConn.setIdleTimeout(30000L);
srvConn.setReuseAddress(true);
httpSrv.addConnector(srvConn);
httpSrv.setStopAtShutdown(false);
} else {
XmlConfiguration cfg;
try {
cfg = new XmlConfiguration(cfgUrl);
} catch (FileNotFoundException e) {
throw new IgniteSpiException("Failed to find configuration file: " + cfgUrl, e);
} catch (SAXException e) {
throw new IgniteSpiException("Failed to parse configuration file: " + cfgUrl, e);
} catch (IOException e) {
throw new IgniteSpiException("Failed to load configuration file: " + cfgUrl, e);
} catch (Exception e) {
throw new IgniteSpiException("Failed to start HTTP server with configuration file: " + cfgUrl, e);
}
try {
httpSrv = (Server) cfg.configure();
} catch (Exception e) {
throw new IgniteCheckedException("Failed to start Jetty HTTP server.", e);
}
}
assert httpSrv != null;
httpSrv.setHandler(jettyHnd);
override(getJettyConnector());
}
use of org.eclipse.jetty.xml.XmlConfiguration in project jena by apache.
the class JettyFusekiWebapp method configServer.
private void configServer(String jettyConfig) {
try {
serverLog.info("Jetty server config file = " + jettyConfig);
server = new Server();
Resource configXml = Resource.newResource(jettyConfig);
XmlConfiguration configuration = new XmlConfiguration(configXml);
configuration.configure(server);
serverConnector = (ServerConnector) server.getConnectors()[0];
} catch (Exception ex) {
serverLog.error("SPARQLServer: Failed to configure server: " + ex.getMessage(), ex);
throw new FusekiException("Failed to configure a server using configuration file '" + jettyConfig + "'");
}
}
use of org.eclipse.jetty.xml.XmlConfiguration in project jena by apache.
the class JettyServer method jettyServer.
// Jetty Server
public static Server jettyServer(String jettyConfig) {
try {
Server server = new Server();
Resource configXml = Resource.newResource(jettyConfig);
XmlConfiguration configuration = new XmlConfiguration(configXml);
configuration.configure(server);
return server;
} catch (Exception ex) {
serverLog.error("JettyServer: Failed to configure server: " + ex.getMessage(), ex);
throw new JettyConfigException("Failed to configure a server using configuration file '" + jettyConfig + "'");
}
}
Aggregations