本文整理汇总了Java中org.eclipse.jetty.webapp.WebAppContext.setBaseResource方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.setBaseResource方法的具体用法?Java WebAppContext.setBaseResource怎么用?Java WebAppContext.setBaseResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.webapp.WebAppContext
的用法示例。
在下文中一共展示了WebAppContext.setBaseResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customize
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@Override
public void customize(Server server) {
Handler[] childHandlersByClass = server.getChildHandlersByClass(WebAppContext.class);
final WebAppContext webAppContext = (WebAppContext) childHandlersByClass[0];
try {
ClassPathResource classPathResource = new ClassPathResource(this.jettyProperties.getClassPathResource());
webAppContext.setBaseResource(new ResourceCollection(classPathResource.getURI().toString()));
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
webAppContext.setClassLoader(new URLClassLoader(new URL[0], this.getClass().getClassLoader()));
return null;
}
});
log.info("Setting Jetty classLoader to {} directory", this.jettyProperties.getClassPathResource());
}
catch (IOException exception) {
log.error("Unable to configure Jetty classLoader to {} directory {}", this.jettyProperties.getClassPathResource(), exception.getMessage());
throw new RuntimeException(exception);
}
}
示例2: configureDocumentRoot
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private void configureDocumentRoot(WebAppContext handler) {
File root = getValidDocumentRoot();
root = (root != null ? root : createTempDir("jetty-docbase"));
try {
if (!root.isDirectory()) {
Resource resource = JarResource
.newJarResource(Resource.newResource(root));
handler.setBaseResource(resource);
}
else {
handler.setBaseResource(Resource.newResource(root.getCanonicalFile()));
}
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:JettyEmbeddedServletContainerFactory.java
示例3: startWebSocketServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void startWebSocketServer(final Injector injector) {
httpServer = new Server();
List<Connector> connectors = getSelectChannelConnectors(httpAddresses);
if (connectors.isEmpty()) {
LOG.severe("No valid http end point address provided!");
}
for (Connector connector : connectors) {
httpServer.addConnector(connector);
}
final WebAppContext context = new WebAppContext();
context.setParentLoaderPriority(true);
if (jettySessionManager != null) {
// This disables JSessionIDs in URLs redirects
// see: http://stackoverflow.com/questions/7727534/how-do-you-disable-jsessionid-for-jetty-running-with-the-eclipse-jetty-maven-plu
// and: http://jira.codehaus.org/browse/JETTY-467?focusedCommentId=114884&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-114884
jettySessionManager.setSessionIdPathParameterName(null);
context.getSessionHandler().setSessionManager(jettySessionManager);
}
final ResourceCollection resources = new ResourceCollection(resourceBases);
context.setBaseResource(resources);
addWebSocketServlets();
try {
final Injector parentInjector = injector;
final ServletModule servletModule = getServletModule(parentInjector);
ServletContextListener contextListener = new GuiceServletContextListener() {
private final Injector childInjector = parentInjector.createChildInjector(servletModule);
@Override
protected Injector getInjector() {
return childInjector;
}
};
context.addEventListener(contextListener);
context.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
context.addFilter(GzipFilter.class, "/webclient/*", EnumSet.allOf(DispatcherType.class));
httpServer.setHandler(context);
httpServer.start();
restoreSessions();
} catch (Exception e) { // yes, .start() throws "Exception"
LOG.severe("Fatal error starting http server.", e);
return;
}
LOG.fine("WebSocket server running.");
}