本文整理匯總了Java中org.eclipse.jetty.server.handler.ContextHandler.setResourceBase方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextHandler.setResourceBase方法的具體用法?Java ContextHandler.setResourceBase怎麽用?Java ContextHandler.setResourceBase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.server.handler.ContextHandler
的用法示例。
在下文中一共展示了ContextHandler.setResourceBase方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: systemRestart
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
private ContextHandler systemRestart() {
AbstractHandler system = new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
restartContexts();
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
response.getWriter().println("<h1>Done</h1>");
}
};
ContextHandler context = new ContextHandler();
context.setContextPath("/vraptor/restart");
context.setResourceBase(".");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
context.setHandler(system);
return context;
}
示例2: listen
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
@Override
public HttpServer listen(int port) throws Exception {
SessionHandler sessionHandler = new SessionHandler(app.configuration(SessionManager.class));
sessionHandler.setHandler(new MiddlewareHandler(app));
ContextHandler context = new ContextHandler();
context.setContextPath("/");
context.setResourceBase(".");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
context.setHandler(sessionHandler);
Server server = new Server(port);
server.setSessionIdManager(new HashSessionIdManager());
server.setHandler(context);
server.start();
server.join();
return this;
}
示例3: configServer
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
@Override
protected void configServer(Server server, int port) {
ServerConnector connector = new ServerConnector(server);
connector.setPort(port);
server.setConnectors(new Connector[]{connector});
ResourceHandler handler = new ResourceHandler();
ContextHandler context = new ContextHandler();
context.setContextPath("/dbus/");
context.setResourceBase(SystemUtils.USER_DIR + File.separator + "html");
context.setHandler(handler);
server.setHandler(context);
}
示例4: start
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public void start() throws Exception {
server = new Server(port);
ContextHandlerCollection contexts = new ContextHandlerCollection();
server.setHandler(contexts);
ContextHandler context = new ContextHandler();
context.setContextPath("/");
context.setResourceBase(".");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
server.setHandler(context);
server.start();
}
示例5: start
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public void start() throws Exception {
server = new Server(port);
ContextHandlerCollection contexts = new ContextHandlerCollection();
server.setHandler(contexts);
ContextHandler context = new ContextHandler();
context.setContextPath("/");
context.setResourceBase(".");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
context.setHandler(new JettyIndexHandler(index));
server.setHandler(context);
server.start();
}
示例6: start
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public void start() throws Exception {
server = new Server(port);
ContextHandler context = new ContextHandler();
context.setContextPath("/");
context.setResourceBase(".");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
context.setHandler(new JettyObjectHandler(object));
server.setHandler(context);
server.start();
}
示例7: initMainWebHandler
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public void initMainWebHandler(final Server server)
{
String webDir = System.class.getResource(WEB_ROOT).toExternalForm();
ContextHandler rootContext = new ContextHandler(server, WEB_ROOT_DIR);
rootContext.setResourceBase(webDir);
rootContext.setHandler(new DefaultHandler(rootContext));
handlerCollection.addHandler(rootContext);
}
示例8: main
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Server server = new Server();
// the ssl context to use
SslContextFactory sslFactory = new SslContextFactory();
//NOTE: keystore.jks should not end up in the repo on a real application since it is private
sslFactory.setKeyStorePath("src/main/resources/keystore.jks");
sslFactory.setKeyStorePassword("password");
sslFactory.setProtocol("TLSv1");
Connector connector = new HTTPSPDYServerConnector(sslFactory);
connector.setPort(8443);
// add connector to the server
server.addConnector(connector);
// add a handler to serve content
ContextHandler handler = new ContextHandler();
handler.setContextPath("/mysite");
handler.setResourceBase("src/main/webapp/");
handler.setHandler(new ResourceHandler());
server.setHandler(handler);
server.start();
server.join();
}
示例9: enableWebServer
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
private void enableWebServer() {
if (server.isRunning())
throw new IllegalStateException("Webserver can not be enabled while running");
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[] { "index.html" });
resourceHandler.setResourceBase(webPath);
resourceHandler.setCacheControl("max-age=600,public"); //cache 10 minutes
ContextHandler contentHandler = new ContextHandler();
contentHandler.setContextPath("/");
contentHandler.setResourceBase(".");
contentHandler.setClassLoader(Thread.currentThread().getContextClassLoader());
contentHandler.setHandler(resourceHandler);
handlers.add(contentHandler);
}
示例10: installJavadocs
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
private void installJavadocs(HandlerList handlers) {
// Does JavaDoc exist?
File javadocJar = null;
try {
File currentJar = Paths.get(BaleenWebApi.class.getProtectionDomain().getCodeSource().getLocation().toURI())
.toFile();
String name = currentJar.getName();
if (name.endsWith(".jar")) {
name = name.substring(0, name.length() - 4) + "-javadoc.jar";
javadocJar = new File(currentJar.getParent(), name);
if (!javadocJar.exists()) {
LOGGER.debug("Unable to locate Javadoc JAR '" + name + "' - Javadoc will not be available");
javadocJar = null;
}
} else {
LOGGER.debug("Couldn't determine name of Javadoc file - Javadoc will not be available");
}
} catch (NullPointerException npe) {
LOGGER.debug(
"Couldn't get name of current JAR - Javadoc will not be available",
npe);
} catch (URISyntaxException use) {
LOGGER.debug(
"Couldn't get name of current JAR - Javadoc will not be available",
use);
}
// If Javadoc exists, serve it
if (javadocJar != null) {
LOGGER.debug("Adding JavaDoc documentation: {}!/",
javadocJar.toURI());
ContextHandler chJavadoc = new ContextHandler("/javadoc");
chJavadoc.setResourceBase("jar:" + javadocJar.toURI() + "!/");
ResourceHandler rhJavadoc = new ResourceHandler();
chJavadoc.setHandler(rhJavadoc);
handlers.addHandler(chJavadoc);
} else {
LOGGER.info("Javadoc will not be available");
}
}
示例11: configure
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
@Override
public void configure(ComponentDTO config, String artemisInstance, String artemisHome) throws Exception {
webServerConfig = (WebServerDTO) config;
uri = new URI(webServerConfig.bind);
server = new Server();
String scheme = uri.getScheme();
if ("https".equals(scheme)) {
SslContextFactory sslFactory = new SslContextFactory();
sslFactory.setKeyStorePath(webServerConfig.keyStorePath == null ? artemisInstance + "/etc/keystore.jks" : webServerConfig.keyStorePath);
sslFactory.setKeyStorePassword(webServerConfig.keyStorePassword == null ? "password" : webServerConfig.keyStorePassword);
if (webServerConfig.clientAuth != null) {
sslFactory.setNeedClientAuth(webServerConfig.clientAuth);
if (webServerConfig.clientAuth) {
sslFactory.setTrustStorePath(webServerConfig.trustStorePath);
sslFactory.setTrustStorePassword(webServerConfig.trustStorePassword);
}
}
SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslFactory, "HTTP/1.1");
HttpConfiguration https = new HttpConfiguration();
https.addCustomizer(new SecureRequestCustomizer());
HttpConnectionFactory httpFactory = new HttpConnectionFactory(https);
connector = new ServerConnector(server, sslConnectionFactory, httpFactory);
} else {
connector = new ServerConnector(server);
}
connector.setPort(uri.getPort());
connector.setHost(uri.getHost());
server.setConnectors(new Connector[]{connector});
handlers = new HandlerList();
Path warDir = Paths.get(artemisHome != null ? artemisHome : ".").resolve(webServerConfig.path).toAbsolutePath();
if (webServerConfig.apps != null && webServerConfig.apps.size() > 0) {
webContexts = new ArrayList<>();
for (AppDTO app : webServerConfig.apps) {
WebAppContext webContext = deployWar(app.url, app.war, warDir);
webContexts.add(webContext);
if (app.war.startsWith("console")) {
consoleUrl = webServerConfig.bind + "/" + app.url;
}
}
}
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(warDir.toString());
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
DefaultHandler defaultHandler = new DefaultHandler();
defaultHandler.setServeIcon(false);
ContextHandler context = new ContextHandler();
context.setContextPath("/");
context.setResourceBase(warDir.toString());
context.setHandler(resourceHandler);
handlers.addHandler(context);
handlers.addHandler(defaultHandler);
server.setHandler(handlers);
}
示例12: initialiseStaticJettyConfig
import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public void initialiseStaticJettyConfig() throws Exception {
server.initialiseConnectors();
ErrorHandler errorHandler = new CougarErrorHandler();
wsdlStaticHandler = new StaticContentServiceHandler(
wsdlContextPath,
wsdlRegex,
wsdlMediaType,
uuidHeader,
uuidParentsHeader,
deserializer,
geoIPLocator,
requestLogger,
true);
wsdlStaticHandler.setUnknownCipherKeyLength(unknownCipherKeyLength);
htmlStaticHandler = new StaticContentServiceHandler(
htmlContextPath,
htmlRegex,
htmlMediaType,
uuidHeader,
uuidParentsHeader,
deserializer,
geoIPLocator,
requestLogger,
suppressCommasInAccessLogForStaticHtml);
htmlStaticHandler.setUnknownCipherKeyLength(unknownCipherKeyLength);
StatisticsHandler statisticsHandler = new StatisticsHandler();
statisticsHandler.setServer(server.getJettyServer());
handlerCollection.setServer(server.getJettyServer());
JettyHandler defaultJettyServiceHandler = new AliasHandler(defaultCommandProcessor, suppressCommasInAccessLogForCalls, pathAliases);
ContextHandler context = new ContextHandler();
context.setContextPath("");
context.setResourceBase(".");
context.setHandler(defaultJettyServiceHandler);
handlerCollection.addHandler(context);
handlerCollection.addHandler(wsdlStaticHandler);
handlerCollection.addHandler(htmlStaticHandler);
// handlerCollection.addHandler(aliasHandler);
statisticsHandler.setHandler(handlerCollection);
// Register the errorhandler with the server itself
server.addBean(errorHandler);
server.setHandler(statisticsHandler);
}