Search in sources :

Example 1 with WebAppContext

use of org.mortbay.jetty.webapp.WebAppContext in project hudson-2.x by hudson.

the class HudsonTestCase method createWebServer.

/**
     * Prepares a webapp hosting environment to get {@link ServletContext} implementation
     * that we need for testing.
     */
protected ServletContext createWebServer() throws Exception {
    server = new Server();
    WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
    context.setClassLoader(getClass().getClassLoader());
    context.setConfigurations(new Configuration[] { new WebXmlConfiguration(), new NoListenerConfiguration() });
    server.setHandler(context);
    context.setMimeTypes(MIME_TYPES);
    SocketConnector connector = new SocketConnector();
    server.addConnector(connector);
    server.addUserRealm(configureUserRealm());
    server.start();
    localPort = connector.getLocalPort();
    return context.getServletContext();
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) WebXmlConfiguration(org.mortbay.jetty.webapp.WebXmlConfiguration) Server(org.mortbay.jetty.Server) SocketConnector(org.mortbay.jetty.bio.SocketConnector)

Example 2 with WebAppContext

use of org.mortbay.jetty.webapp.WebAppContext in project guice by google.

the class Main method main.

public static void main(String[] args) throws Exception {
    Server server = new Server();
    Connector connector = new SelectChannelConnector();
    connector.setPort(8080);
    server.setConnectors(new Connector[] { connector });
    WebAppContext webapp = new WebAppContext("./root", "/example");
    server.addHandler(webapp);
    server.start();
    server.join();
}
Also used : Connector(org.mortbay.jetty.Connector) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) WebAppContext(org.mortbay.jetty.webapp.WebAppContext) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) Server(org.mortbay.jetty.Server)

Example 3 with WebAppContext

use of org.mortbay.jetty.webapp.WebAppContext in project nhin-d by DirectProject.

the class ConfigServiceRunner method startConfigService.

public static synchronized void startConfigService() throws Exception {
    if (server == null) {
        /*
			 * Setup the configuration service server
			 */
        server = new Server();
        SocketConnector connector = new SocketConnector();
        HTTPPort = AvailablePortFinder.getNextAvailable(8081);
        connector.setPort(HTTPPort);
        // certificate service
        WebAppContext context = new WebAppContext("src/main/webapp", "/config-service");
        server.setSendServerVersion(false);
        server.addConnector(connector);
        server.addHandler(context);
        server.start();
        serviceURL = "http://localhost:" + HTTPPort + "/";
    }
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server) SocketConnector(org.mortbay.jetty.bio.SocketConnector)

Example 4 with WebAppContext

use of org.mortbay.jetty.webapp.WebAppContext in project nhin-d by DirectProject.

the class TxsServiceRunner method startTxsService.

public static synchronized void startTxsService() throws Exception {
    if (server == null) {
        /*
			 * Setup the configuration service server
			 */
        server = new Server();
        SocketConnector connector = new SocketConnector();
        HTTPPort = AvailablePortFinder.getNextAvailable(1024);
        connector.setPort(HTTPPort);
        WebAppContext context = new WebAppContext("src/test/resources/webapp", "/");
        server.setSendServerVersion(false);
        server.addConnector(connector);
        server.addHandler(context);
        server.start();
        txsServiceURL = "http://localhost:" + HTTPPort + "/";
    }
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server) SocketConnector(org.mortbay.jetty.bio.SocketConnector)

Example 5 with WebAppContext

use of org.mortbay.jetty.webapp.WebAppContext in project nhin-d by DirectProject.

the class ConfigServiceRunner method startConfigService.

public static synchronized void startConfigService() throws Exception {
    if (server == null) {
        /*
			 * Setup the configuration service server
			 */
        server = new Server();
        SocketConnector connector = new SocketConnector();
        HTTPPort = AvailablePortFinder.getNextAvailable(1024);
        connector.setPort(HTTPPort);
        WebAppContext context = new WebAppContext("src/test/resources/webapp", "/");
        server.setSendServerVersion(false);
        server.addConnector(connector);
        server.addHandler(context);
        server.start();
        configServiceURL = "http://localhost:" + HTTPPort + "/ConfigurationService";
        restAPIBaseURL = "http://localhost:" + HTTPPort + "/api";
    }
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server) SocketConnector(org.mortbay.jetty.bio.SocketConnector)

Aggregations

WebAppContext (org.mortbay.jetty.webapp.WebAppContext)17 Server (org.mortbay.jetty.Server)14 SocketConnector (org.mortbay.jetty.bio.SocketConnector)11 Connector (org.mortbay.jetty.Connector)5 SelectChannelConnector (org.mortbay.jetty.nio.SelectChannelConnector)4 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 Handler (org.mortbay.jetty.Handler)2 DefaultHandler (org.mortbay.jetty.handler.DefaultHandler)2 SecurityHandler (org.mortbay.jetty.security.SecurityHandler)2 WebXmlConfiguration (org.mortbay.jetty.webapp.WebXmlConfiguration)2 ThreadPoolExecutorAdapter (com.google.util.threads.ThreadPoolExecutorAdapter)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 BindException (java.net.BindException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1