本文整理了Java中org.eclipse.jetty.server.handler.ContextHandler.
方法的一些代码示例,展示了ContextHandler.
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ContextHandler.
方法的具体详情如下:
包路径:org.eclipse.jetty.server.handler.ContextHandler
类名称:ContextHandler
方法名:
暂无
代码示例来源:origin: stackoverflow.com
Server server = new Server(8080);
WebSocketHandler wsHandler = new WebSocketHandler()
{
@Override
public void configure(WebSocketServletFactory factory)
{
factory.register(MyEchoSocket.class);
}
};
ContextHandler cOntext= new ContextHandler();
context.setContextPath("/echo");
context.setHandler(wsHandler);
server.addHandler(context);
server.start();
server.join();
代码示例来源:origin: jooby-project/jooby
ContextHandler sch = new ContextHandler();
sch.setAttribute(DecoratedObjectFactory.ATTR, new DecoratedObjectFactory());
代码示例来源:origin: jphp-group/jphp
@Signature
public void addWebSocket(Environment env, String path, ArrayMemory _handlers) {
WebSocketParam param = _handlers.toBean(env, WebSocketParam.class);
ContextHandler cOntextHandler= new ContextHandler(path);
contextHandler.setHandler(new WebSocketHandler() {
@Override
public void configure(WebSocketServletFactory factory) {
factory.setCreator(new WebSocketCreator() {
@Override
public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
return new WebSocket(env, param);
}
});
}
});
handlers.addHandler(contextHandler);
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void start() {
writeTimeToFile("startingAt");
ContextHandler cOntext= new ContextHandler();
context.setContextPath("/");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
server.setHandler(context);
context.setHandler(new AbstractHandler() {
@Override
public void handle(String target, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
if ("/ping".equals(target)) {
request.setHandled(true);
httpServletResponse.getWriter().print("ping");
} else if ("/restart".equals(target)) {
writeTimeToFile("restartAskedAt");
request.setHandled(true);
processCommands.askForRestart();
httpServletResponse.getWriter().print("ok");
} else if ("/kill".equals(target)) {
writeTimeToFile("killedAt");
System.exit(0);
}
}
});
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Fail to start Jetty", e);
}
}
代码示例来源:origin: stackoverflow.com
ContextHandler cOntext= new ContextHandler("/");
server.setHandler(context);
代码示例来源:origin: winder/Universal-G-Code-Sender
resourceHandler.setDirectoriesListed(true);
ContextHandler sendGcodeCOntext= new ContextHandler();
sendGcodeContext.setContextPath("/sendGcode");
sendGcodeContext.setBaseResource(getBaseResource());
sendGcodeContext.setHandler(new SendGcodeHandler());
ContextHandler adjustManualLocatiOnContext= new ContextHandler();
adjustManualLocationContext.setContextPath("/adjustManualLocation");
adjustManualLocationContext.setBaseResource(getBaseResource());
adjustManualLocationContext.setHandler(new AdjustManualLocationHandler());
ContextHandler getSystemStateCOntext= new ContextHandler();
getSystemStateContext.setContextPath("/getSystemState");
getSystemStateContext.setBaseResource(getBaseResource());
getSystemStateContext.setHandler(new GetSystemStateHandler());
ContextHandler cOnfigContext= new ContextHandler();
configContext.setContextPath("/config");
configContext.setBaseResource(getBaseResource());
代码示例来源:origin: jitsi/jitsi-videobridge
cOntextHandler= new ContextHandler();
contextHandler.setHandler(resourceHandler);
contextHandler.addAliasCheck(new ContextHandler.ApproveAliases());
代码示例来源:origin: biezhi/java-library-examples
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();
}
}
代码示例来源:origin: Valandur/Web-API
private ContextHandler newContext(String path, Handler handler) {
ContextHandler cOntext= new ContextHandler();
context.setContextPath(path);
context.setHandler(handler);
return context;
}
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-core
private void installSwagger(HandlerList handlers) {
LOGGER.debug("Adding Swagger documentation");
final ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true); //
resourceHandler.setResourceBase(getClass().getResource("/swagger").toExternalForm());
ContextHandler swaggerHandler = new ContextHandler("/swagger/*");
swaggerHandler.setHandler(resourceHandler);
handlers.addHandler(swaggerHandler);
}
代码示例来源:origin: stackoverflow.com
ServerConnector httpCOnnector= new ServerConnector(server);
httpConnector.setName("unsecured"); // named connector
httpConnector.setPort(80);
ContextHandler helloHandler = new ContextHandler();
helloHandler.setContextPath("/hello");
helloHandler.setHandler(new HelloHandler("Hello World"));
helloHandler.setVirtualHosts(new String[]{"@unsecured"});
代码示例来源:origin: ch.exense.step/core
protected void registerWebapp(GlobalContext context, String path) {
ResourceHandler bb = new ResourceHandler();
bb.setResourceBase(this.getClass().getResource("webapp").toExternalForm());
ContextHandler ctx = new ContextHandler(path);
ctx.setHandler(bb);
context.getServiceRegistrationCallback().registerHandler(ctx);
}
}
代码示例来源:origin: stackoverflow.com
ContextHandlerCollection cOntexts= new ContextHandlerCollection();
server.setHandler(contexts);
ContextHandler stock = new ContextHandler("/stock");
stock.setHandler(new Class2HTTPMessageHandler());
contexts.add(stock);
代码示例来源:origin: stackoverflow.com
ResourceHandler staticResource = new ResourceHandler();
staticResource.setDirectoriesListed(true);
staticResource.setWelcomeFiles(new String[] { "index.html" });
staticResource.setResourceBase("/path/to/your/files");
ContextHandler staticCOntextHandler= new ContextHandler();
staticContextHandler.setContextPath("/*");
staticContextHandler.setHandler(staticResource);
Server server = new Server(8080);
server.setHandler(staticContextHandler);
代码示例来源:origin: stackoverflow.com
ContextHandler capHandler = new ContextHandler();
capHandler.setContextPath("/clientaccesspolicy.xml");
ResourceHandler resHandler = new ResourceHandler();
resHandler.setBaseResource(Resource.newClassPathResource("clientaccesspolicy.xml"));
capHandler.setHandler(resHandler);
代码示例来源:origin: org.atteo.moonshine/jetty
public ContextHandler getHandler() {
ContextHandler cOntextHandler= new ContextHandler();
contextHandler.setContextPath(contextPath);
contextHandler.setHandler(wrappedHandler.getHandler());
contextHandler.setVirtualHosts(virtualHosts);
return contextHandler;
}
代码示例来源:origin: org.apache.pulsar/pulsar-broker
public void addStaticResources(String basePath, String resourcePath) {
ContextHandler capHandler = new ContextHandler();
capHandler.setContextPath(basePath);
ResourceHandler resHandler = new ResourceHandler();
resHandler.setBaseResource(Resource.newClassPathResource(resourcePath));
resHandler.setEtags(true);
resHandler.setCacheControl(WebService.HANDLER_CACHE_CONTROL);
capHandler.setHandler(resHandler);
handlers.add(capHandler);
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
public void addStaticResources(String basePath, String resourcePath) {
ContextHandler capHandler = new ContextHandler();
capHandler.setContextPath(basePath);
ResourceHandler resHandler = new ResourceHandler();
resHandler.setBaseResource(Resource.newClassPathResource(resourcePath));
resHandler.setEtags(true);
resHandler.setCacheControl(WebService.HANDLER_CACHE_CONTROL);
capHandler.setHandler(resHandler);
handlers.add(capHandler);
}
代码示例来源:origin: io.provis/provisio-webserver-jetty8
public void addResourceContext(String context, File directory) throws MalformedURLException, IOException {
ContextHandler cOntextHandler= new ContextHandler();
ResourceHandler cOntentResourceHandler= new ResourceHandler();
contextHandler.setBaseResource(Resource.newResource(directory));
contextHandler.setHandler(contentResourceHandler);
contextHandler.setContextPath(context);
addContextHandler(contextHandler);
}
代码示例来源:origin: codeine-cd/codeine
private ContextHandler createStaticContextHandler(String contextPath, String fsPath) {
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.htm", "index.html"});
resourceHandler.setResourceBase(fsPath);
ContextHandler ch = new ContextHandler();
ch.setContextPath(contextPath);
ch.setHandler(resourceHandler);
return ch;
}