use of org.eclipse.jetty.webapp.WebAppContext in project Ebselen by Ardesco.
the class JettyServer method startJettyServer.
public void startJettyServer(int port) throws Exception {
String resourceBasePath = this.getClass().getResource("/web").toExternalForm();
jettyServer = new Server(port);
WebAppContext webapp = new WebAppContext();
webapp.setResourceBase(resourceBasePath);
jettyServer.setHandler(webapp);
jettyServer.start();
}
use of org.eclipse.jetty.webapp.WebAppContext in project jetty.project by eclipse.
the class Activator method start.
/**
*
* @param context
*/
public void start(BundleContext context) throws Exception {
//Create webappA as a Service and target it at the default server
WebAppContext webapp = new WebAppContext();
webapp.addServlet(new ServletHolder(new TestServlet()), "/mime");
Dictionary props = new Hashtable();
props.put("war", "webappA");
props.put("contextPath", "/acme");
props.put("managedServerName", "defaultJettyServer");
_srA = context.registerService(WebAppContext.class.getName(), webapp, props);
//Create a second webappB as a Service and target it at a custom Server
//deployed by another bundle
WebAppContext webappB = new WebAppContext();
Dictionary propsB = new Hashtable();
propsB.put("war", "webappB");
propsB.put("contextPath", "/acme");
propsB.put("managedServerName", "fooServer");
_srB = context.registerService(WebAppContext.class.getName(), webappB, propsB);
}
use of org.eclipse.jetty.webapp.WebAppContext in project apjp by jvansteirteghem.
the class Main method main.
public static void main(String[] args) throws Exception {
Server server = new Server(Integer.valueOf(System.getenv("PORT")));
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setDescriptor("src/main/webapp/WEB-INF/web.xml");
webAppContext.setResourceBase("src/main/webapp/");
webAppContext.setParentLoaderPriority(true);
server.setHandler(webAppContext);
server.start();
server.join();
}
use of org.eclipse.jetty.webapp.WebAppContext in project ats-framework by Axway.
the class ContainerStarter method startServer.
/**
* Method for starting the Jetty server with the ATS Agent webapp.
* @param port the port on which to start the server.
* @return the started server.
* @throws IOException
*/
private static Server startServer() throws IOException {
addAppender();
final int agentPort = getAgentDefaultPort();
log.info("Starting ATS agent at port: " + agentPort);
final String jettyHome = getJettyHome();
logSystemInformation(jettyHome);
// start the server
Connector connector = new SelectChannelConnector();
connector.setPort(agentPort);
Server server = new Server();
server.setConnectors(new Connector[] { connector });
WebAppContext webApp = new WebAppContext();
webApp.setContextPath("/agentapp");
webApp.setWar(jettyHome + "/webapp/agentapp.war");
server.setHandler(webApp);
server.setStopAtShutdown(true);
setExtraClasspath(webApp, jettyHome);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
log.info("ATS agent started");
return server;
}
use of org.eclipse.jetty.webapp.WebAppContext in project incubator-atlas by apache.
the class EmbeddedServer method getWebAppContext.
protected WebAppContext getWebAppContext(String path) {
WebAppContext application = new WebAppContext(path, "/");
application.setClassLoader(Thread.currentThread().getContextClassLoader());
// Disable directory listing
application.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
return application;
}
Aggregations