use of org.eclipse.jetty.xml.XmlConfiguration in project otter by alibaba.
the class JettyEmbedIntegration method main.
public static void main(String[] args) throws Exception {
Resource jetty_xml = Resource.newSystemResource("jetty/jetty.xml");
XmlConfiguration configuration = new XmlConfiguration(jetty_xml.getInputStream());
Server server = (Server) configuration.configure();
int port = 8081;
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", "/tmp/");
}
server.start();
server.join();
}
use of org.eclipse.jetty.xml.XmlConfiguration in project gocd by gocd.
the class Jetty9Server method performCustomConfiguration.
private void performCustomConfiguration() throws Exception {
File jettyConfig = systemEnvironment.getJettyConfigFile();
if (jettyConfig.exists()) {
replaceJettyXmlIfItBelongsToADifferentVersion(jettyConfig);
LOG.info("Configuring Jetty using {}", jettyConfig.getAbsolutePath());
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(jettyConfig));
configuration.configure(server);
} else {
String message = String.format("No custom jetty configuration (%s) found, using defaults.", jettyConfig.getAbsolutePath());
LOG.info(message);
}
}
use of org.eclipse.jetty.xml.XmlConfiguration in project hive by apache.
the class Main method runServer.
public Server runServer(int port) throws Exception {
// Authenticate using keytab
if (UserGroupInformation.isSecurityEnabled()) {
String serverPrincipal = SecurityUtil.getServerPrincipal(conf.kerberosPrincipal(), "0.0.0.0");
UserGroupInformation.loginUserFromKeytab(serverPrincipal, conf.kerberosKeytab());
}
// Create the Jetty server. If jetty conf file exists, use that to create server
// to have more control.
Server server = null;
if (StringUtils.isEmpty(conf.jettyConfiguration())) {
server = new Server(port);
} else {
FileInputStream jettyConf = new FileInputStream(conf.jettyConfiguration());
XmlConfiguration configuration = new XmlConfiguration(jettyConf);
server = (Server) configuration.configure();
}
ServletContextHandler root = new ServletContextHandler(server, "/");
// Add the Auth filter
FilterHolder fHolder = makeAuthFilter();
EnumSet<DispatcherType> dispatches = EnumSet.of(DispatcherType.REQUEST);
/*
* We add filters for each of the URIs supported by templeton.
* If we added the entire sub-structure using '/*', the mapreduce
* notification cannot give the callback to templeton in secure mode.
* This is because mapreduce does not use secure credentials for
* callbacks. So jetty would fail the request as unauthorized.
*/
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/ddl/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/pig/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/hive/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/sqoop/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/queue/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/jobs/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/mapreduce/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/status/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/version/*", dispatches);
if (conf.getBoolean(AppConfig.XSRF_FILTER_ENABLED, false)) {
root.addFilter(makeXSRFFilter(), "/" + SERVLET_PATH + "/*", dispatches);
LOG.debug("XSRF filter enabled");
} else {
LOG.warn("XSRF filter disabled");
}
root.addFilter(makeFrameOptionFilter(), "/" + SERVLET_PATH + "/*", dispatches);
// Connect Jersey
ServletHolder h = new ServletHolder(new ServletContainer(makeJerseyConfig()));
root.addServlet(h, "/" + SERVLET_PATH + "/*");
// Add any redirects
addRedirects(server);
// Set handling for low resource conditions.
final LowResourceMonitor low = new LowResourceMonitor(server);
low.setLowResourcesIdleTimeout(10000);
server.addBean(low);
server.addConnector(createChannelConnector());
// Start the server
server.start();
this.server = server;
return server;
}
use of org.eclipse.jetty.xml.XmlConfiguration in project jetty.project by eclipse.
the class FileServerXml method main.
public static void main(String[] args) throws Exception {
Resource fileserverXml = Resource.newSystemResource("fileserver.xml");
XmlConfiguration configuration = new XmlConfiguration(fileserverXml.getInputStream());
Server server = (Server) configuration.configure();
server.start();
server.join();
}
use of org.eclipse.jetty.xml.XmlConfiguration in project jetty.project by eclipse.
the class ServerProxyImpl method applyJettyXml.
/**
* Applies jetty.xml configuration to the Jetty server instance.
*/
private void applyJettyXml() {
if (jettyXml != null && jettyXml.exists()) {
TaskLog.log("Configuring jetty from xml configuration file = " + jettyXml.getAbsolutePath());
XmlConfiguration configuration;
try {
configuration = new XmlConfiguration(Resource.toURL(jettyXml));
configuration.configure(server);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
} catch (SAXException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Aggregations