use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project zeppelin by apache.
the class ZeppelinServer method main.
public static void main(String[] args) throws InterruptedException {
ZeppelinConfiguration conf = ZeppelinConfiguration.create();
conf.setProperty("args", args);
jettyWebServer = setupJettyServer(conf);
ContextHandlerCollection contexts = new ContextHandlerCollection();
jettyWebServer.setHandler(contexts);
// Web UI
final WebAppContext webApp = setupWebAppContext(contexts, conf);
// Create `ZeppelinServer` using reflection and setup REST Api
setupRestApiContextHandler(webApp, conf);
// Notebook server
setupNotebookServer(webApp, conf);
//Below is commented since zeppelin-docs module is removed.
//final WebAppContext webAppSwagg = setupWebAppSwagger(conf);
LOG.info("Starting zeppelin server");
try {
//Instantiates ZeppelinServer
jettyWebServer.start();
} catch (Exception e) {
LOG.error("Error while running jettyServer", e);
System.exit(-1);
}
LOG.info("Done, zeppelin server started");
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
LOG.info("Shutting down Zeppelin Server ... ");
try {
jettyWebServer.stop();
notebook.getInterpreterSettingManager().shutdown();
notebook.close();
Thread.sleep(3000);
} catch (Exception e) {
LOG.error("Error while stopping servlet container", e);
}
LOG.info("Bye");
}
});
// for graceful shutdown, input any key in console window
if (System.getenv("ZEPPELIN_IDENT_STRING") == null) {
try {
System.in.read();
} catch (IOException e) {
LOG.error("Exception in ZeppelinServer while main ", e);
}
System.exit(0);
}
jettyWebServer.join();
ZeppelinServer.notebook.getInterpreterSettingManager().close();
}
use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.
the class DeploymentManagerTest method testReceiveApp.
@Test
public void testReceiveApp() 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");
// Test app tracking
Collection<App> apps = depman.getApps();
Assert.assertNotNull("Should never be null", apps);
Assert.assertEquals("Expected App Count", 1, apps.size());
// Test app get
App actual = depman.getAppByOriginId("mock-foo-webapp-1.war");
Assert.assertNotNull("Should have gotten app (by id)", actual);
Assert.assertEquals("Should have gotten app (by id)", "mock-foo-webapp-1.war", actual.getOriginId());
}
use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.
the class OverlayServer method main.
public static void main(String[] args) throws Exception {
// NamingUtil.__log.setDebugEnabled(true);
String jetty_home = System.getProperty("jetty.home", "target/test-classes/home");
System.setProperty("jetty.home", jetty_home);
Server server = new Server();
server.setAttribute("org.eclipse.jetty.webapp.configuration", new String[] { org.eclipse.jetty.webapp.WebInfConfiguration.class.getCanonicalName(), org.eclipse.jetty.webapp.WebXmlConfiguration.class.getCanonicalName(), org.eclipse.jetty.webapp.MetaInfConfiguration.class.getCanonicalName(), org.eclipse.jetty.webapp.FragmentConfiguration.class.getCanonicalName(), org.eclipse.jetty.plus.webapp.EnvConfiguration.class.getCanonicalName(), org.eclipse.jetty.plus.webapp.PlusConfiguration.class.getCanonicalName(), org.eclipse.jetty.webapp.JettyWebXmlConfiguration.class.getCanonicalName() });
// Setup Connectors
ServerConnector connector = new ServerConnector(server);
connector.setPort(8080);
server.addConnector(connector);
HandlerCollection handlers = new HandlerCollection();
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLogHandler requestLogHandler = new RequestLogHandler();
handlers.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(handlers);
server.setHandler(stats);
// Setup deployers
DeploymentManager deployer = new DeploymentManager();
deployer.setContexts(contexts);
server.addBean(deployer);
OverlayedAppProvider provider = new OverlayedAppProvider();
provider.setNodeName("nodeA");
provider.setScanDir(new File(jetty_home + "/overlays"));
provider.setScanInterval(2);
deployer.addAppProvider(provider);
server.setStopAtShutdown(true);
//server.setSendServerVersion(true);
// Uncomment to work with JNDI examples
// new org.eclipse.jetty.plus.jndi.Transaction(new com.atomikos.icatch.jta.UserTransactionImp());
server.start();
server.join();
}
use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.
the class ServletContextHandlerTest method testFindContainer.
@Test
public void testFindContainer() throws Exception {
ContextHandlerCollection contexts = new ContextHandlerCollection();
_server.setHandler(contexts);
ServletContextHandler root = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS);
SessionHandler session = root.getSessionHandler();
ServletHandler servlet = root.getServletHandler();
SecurityHandler security = new ConstraintSecurityHandler();
root.setSecurityHandler(security);
_server.start();
assertEquals(root, AbstractHandlerContainer.findContainerOf(_server, ContextHandler.class, session));
assertEquals(root, AbstractHandlerContainer.findContainerOf(_server, ContextHandler.class, security));
assertEquals(root, AbstractHandlerContainer.findContainerOf(_server, ContextHandler.class, servlet));
}
use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.
the class DispatcherTest method init.
@Before
public void init() throws Exception {
_server = new Server();
_connector = new LocalConnector(_server);
_connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendServerVersion(false);
_connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendDateHeader(false);
_contextCollection = new ContextHandlerCollection();
_contextHandler = new ServletContextHandler();
_contextHandler.setContextPath("/context");
_contextCollection.addHandler(_contextHandler);
_resourceHandler = new ResourceHandler();
_resourceHandler.setResourceBase(MavenTestingUtils.getTestResourceDir("dispatchResourceTest").getAbsolutePath());
_resourceHandler.setPathInfoOnly(true);
ContextHandler resourceContextHandler = new ContextHandler("/resource");
resourceContextHandler.setHandler(_resourceHandler);
_contextCollection.addHandler(resourceContextHandler);
_server.setHandler(_contextCollection);
_server.addConnector(_connector);
_server.start();
}
Aggregations