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);
}
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);
}
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);
}
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);
}
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);
}
}
}
Aggregations