Search in sources :

Example 46 with ContextHandlerCollection

use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.

the class DeploymentManagerLifeCyclePathTest method testStateTransition_DeployedToUndeployed.

@Test
public void testStateTransition_DeployedToUndeployed() throws Exception {
    DeploymentManager depman = new DeploymentManager();
    // no default
    depman.setDefaultLifeCycleGoal(null);
    AppLifeCyclePathCollector pathtracker = new AppLifeCyclePathCollector();
    MockAppProvider mockProvider = new MockAppProvider();
    // Setup JMX
    MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    depman.addBean(mbContainer);
    depman.addLifeCycleBinding(pathtracker);
    depman.addAppProvider(mockProvider);
    depman.setContexts(new ContextHandlerCollection());
    // Start DepMan
    depman.start();
    // Trigger new App
    mockProvider.findWebapp("foo-webapp-1.war");
    App app = depman.getAppByOriginId("mock-foo-webapp-1.war");
    // Request Deploy of App
    depman.requestAppGoal(app, "deployed");
    JmxServiceConnection jmxConnection = new JmxServiceConnection();
    jmxConnection.connect();
    MBeanServerConnection mbsConnection = jmxConnection.getConnection();
    ObjectName dmObjName = new ObjectName("org.eclipse.jetty.deploy:type=deploymentmanager,id=0");
    String[] params = new String[] { "mock-foo-webapp-1.war", "undeployed" };
    String[] signature = new String[] { "java.lang.String", "java.lang.String" };
    mbsConnection.invoke(dmObjName, "requestAppGoal", params, signature);
    // Setup Expectations.
    List<String> expected = new ArrayList<String>();
    // SHOULD NOT SEE THIS NODE VISITED - expected.add("undeployed");
    expected.add("deploying");
    expected.add("deployed");
    expected.add("undeploying");
    expected.add("undeployed");
    pathtracker.assertExpected("Test JMX StateTransition / Deployed -> Undeployed", expected);
}
Also used : ArrayList(java.util.ArrayList) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) ObjectName(javax.management.ObjectName) MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) MBeanServerConnection(javax.management.MBeanServerConnection) Test(org.junit.Test)

Example 47 with ContextHandlerCollection

use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.

the class StandardUndeployer method processBinding.

@Override
public void processBinding(Node node, App app) throws Exception {
    ContextHandler handler = app.getContextHandler();
    ContextHandlerCollection chcoll = app.getDeploymentManager().getContexts();
    recursiveRemoveContext(chcoll, handler);
}
Also used : ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection)

Example 48 with ContextHandlerCollection

use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.

the class DeploymentManagerLifeCyclePathTest method testStateTransition_NewToDeployed.

@Test
public void testStateTransition_NewToDeployed() throws Exception {
    DeploymentManager depman = new DeploymentManager();
    depman.setContexts(new ContextHandlerCollection());
    // no default
    depman.setDefaultLifeCycleGoal(null);
    AppLifeCyclePathCollector pathtracker = new AppLifeCyclePathCollector();
    MockAppProvider mockProvider = new MockAppProvider();
    depman.addLifeCycleBinding(pathtracker);
    depman.addAppProvider(mockProvider);
    depman.setContexts(new ContextHandlerCollection());
    // Start DepMan
    depman.start();
    // Trigger new App
    mockProvider.findWebapp("foo-webapp-1.war");
    App app = depman.getAppByOriginId("mock-foo-webapp-1.war");
    // Request Deploy of App
    depman.requestAppGoal(app, "deployed");
    // Setup Expectations.
    List<String> expected = new ArrayList<String>();
    // SHOULD NOT SEE THIS NODE VISITED - expected.add("undeployed");
    expected.add("deploying");
    expected.add("deployed");
    pathtracker.assertExpected("Test StateTransition / New -> Deployed", expected);
}
Also used : ArrayList(java.util.ArrayList) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) Test(org.junit.Test)

Example 49 with ContextHandlerCollection

use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.

the class DeploymentManagerLifeCyclePathTest method testStateTransition_Receive.

@Test
public void testStateTransition_Receive() throws Exception {
    DeploymentManager depman = new DeploymentManager();
    depman.setContexts(new ContextHandlerCollection());
    // no default
    depman.setDefaultLifeCycleGoal(null);
    AppLifeCyclePathCollector pathtracker = new AppLifeCyclePathCollector();
    MockAppProvider mockProvider = new MockAppProvider();
    depman.addLifeCycleBinding(pathtracker);
    depman.addAppProvider(mockProvider);
    // Start DepMan
    depman.start();
    // Trigger new App
    mockProvider.findWebapp("foo-webapp-1.war");
    // Perform no goal request.
    // Setup Expectations.
    List<String> expected = new ArrayList<String>();
    pathtracker.assertExpected("Test StateTransition / New only", expected);
}
Also used : ArrayList(java.util.ArrayList) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) Test(org.junit.Test)

Example 50 with ContextHandlerCollection

use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project hbase by apache.

the class HttpServer method initializeWebServer.

private void initializeWebServer(String name, String hostName, Configuration conf, String[] pathSpecs) throws FileNotFoundException, IOException {
    Preconditions.checkNotNull(webAppContext);
    HandlerCollection handlerCollection = new HandlerCollection();
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    RequestLog requestLog = HttpRequestLog.getRequestLog(name);
    if (requestLog != null) {
        RequestLogHandler requestLogHandler = new RequestLogHandler();
        requestLogHandler.setRequestLog(requestLog);
        handlerCollection.addHandler(requestLogHandler);
    }
    final String appDir = getWebAppsPath(name);
    handlerCollection.addHandler(contexts);
    handlerCollection.addHandler(webAppContext);
    webServer.setHandler(handlerCollection);
    addDefaultApps(contexts, appDir, conf);
    addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
    Map<String, String> params = new HashMap<>();
    params.put("xframeoptions", conf.get("hbase.http.filter.xframeoptions.mode", "DENY"));
    addGlobalFilter("clickjackingprevention", ClickjackingPreventionFilter.class.getName(), params);
    final FilterInitializer[] initializers = getFilterInitializers(conf);
    if (initializers != null) {
        conf = new Configuration(conf);
        conf.set(BIND_ADDRESS, hostName);
        for (FilterInitializer c : initializers) {
            c.initFilter(this, conf);
        }
    }
    addDefaultServlets();
    if (pathSpecs != null) {
        for (String path : pathSpecs) {
            LOG.info("adding path spec: " + path);
            addFilterPathMapping(path, webAppContext);
        }
    }
}
Also used : RequestLog(org.eclipse.jetty.server.RequestLog) Configuration(org.apache.hadoop.conf.Configuration) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) HashMap(java.util.HashMap) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection)

Aggregations

ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)57 Server (org.eclipse.jetty.server.Server)27 HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)21 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)17 RequestLogHandler (org.eclipse.jetty.server.handler.RequestLogHandler)16 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)16 ServerConnector (org.eclipse.jetty.server.ServerConnector)15 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)15 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)10 Test (org.junit.Test)10 Handler (org.eclipse.jetty.server.Handler)9 URI (java.net.URI)7 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)7 ResourceHandler (org.eclipse.jetty.server.handler.ResourceHandler)7 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)6 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 MBeanContainer (org.eclipse.jetty.jmx.MBeanContainer)5 HttpURLConnection (java.net.HttpURLConnection)4