use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class EndpointEchoTest method startServer.
@BeforeClass
public static void startServer() throws Exception {
server = new Server();
ServerConnector connector = new ServerConnector(server);
server.addConnector(connector);
handler = new EchoHandler();
ContextHandler context = new ContextHandler();
context.setContextPath("/");
context.setHandler(handler);
server.setHandler(context);
// Start Server
server.start();
String host = connector.getHost();
if (host == null) {
host = "localhost";
}
int port = connector.getLocalPort();
serverUri = new URI(String.format("ws://%s:%d/", host, port));
}
use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class OneContext method main.
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
// Add a single handler on context "/hello"
ContextHandler context = new ContextHandler();
context.setContextPath("/hello");
context.setHandler(new HelloHandler());
// Can be accessed using http://localhost:8080/hello
server.setHandler(context);
// Start the server
server.start();
server.join();
}
use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class GlobalWebappConfigBinding method processBinding.
public void processBinding(Node node, App app) throws Exception {
ContextHandler handler = app.getContextHandler();
if (handler == null) {
throw new NullPointerException("No Handler created for App: " + app);
}
if (handler instanceof WebAppContext) {
WebAppContext context = (WebAppContext) handler;
if (LOG.isDebugEnabled()) {
LOG.debug("Binding: Configuring webapp context with global settings from: " + _jettyXml);
}
if (_jettyXml == null) {
LOG.warn("Binding: global context binding is enabled but no jetty-web.xml file has been registered");
}
Resource globalContextSettings = Resource.newResource(_jettyXml);
if (globalContextSettings.exists()) {
XmlConfiguration jettyXmlConfig = new XmlConfiguration(globalContextSettings.getInputStream());
Resource resource = Resource.newResource(app.getOriginId());
File file = resource.getFile();
jettyXmlConfig.getIdMap().put("Server", app.getDeploymentManager().getServer());
jettyXmlConfig.getProperties().put("jetty.home", System.getProperty("jetty.home", "."));
jettyXmlConfig.getProperties().put("jetty.base", System.getProperty("jetty.base", "."));
jettyXmlConfig.getProperties().put("jetty.webapp", file.getCanonicalPath());
jettyXmlConfig.getProperties().put("jetty.webapps", file.getParentFile().getCanonicalPath());
jettyXmlConfig.configure(context);
} else {
LOG.info("Binding: Unable to locate global webapp context settings: " + _jettyXml);
}
}
}
use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class StandardDeployer method processBinding.
public void processBinding(Node node, App app) throws Exception {
ContextHandler handler = app.getContextHandler();
if (handler == null) {
throw new NullPointerException("No Handler created for App: " + app);
}
app.getDeploymentManager().getContexts().addHandler(handler);
}
use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class StandardStarter method processBinding.
@Override
public void processBinding(Node node, App app) throws Exception {
ContextHandler handler = app.getContextHandler();
// start the handler
handler.start();
// After starting let the context manage state
app.getDeploymentManager().getContexts().manage(handler);
}
Aggregations