当前位置: 首页>>代码示例>>Java>>正文


Java WebAppContext.addEventListener方法代码示例

本文整理汇总了Java中org.eclipse.jetty.webapp.WebAppContext.addEventListener方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.addEventListener方法的具体用法?Java WebAppContext.addEventListener怎么用?Java WebAppContext.addEventListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.webapp.WebAppContext的用法示例。


在下文中一共展示了WebAppContext.addEventListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initWebApp

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private WebAppContext initWebApp() throws IOException {
    WebAppContext ctx = new WebAppContext();
    ctx.setContextPath(CONFIG.getContextPath());
    ctx.setResourceBase(new ClassPathResource("webapp").getURI().toString());

    // Disable directory listings if no index.html is found.
    ctx.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

    ServletHolder web = new ServletHolder("spring-dispatcher", new DispatcherServlet(springContext));
    ServletHolder cxf = new ServletHolder("cxf", new CXFServlet());

    ctx.addEventListener(new ContextLoaderListener(springContext));
    ctx.addServlet(web, CONFIG.getSpringMapping());
    ctx.addServlet(cxf, CONFIG.getCxfMapping());

    if (CONFIG.getProfile().isProd()) {
        addSecurityFilter(ctx);
    }

    initJSP(ctx);
    return ctx;
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:23,代码来源:SteveAppContext.java

示例2: 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.");
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:57,代码来源:ServerRpcProvider.java


注:本文中的org.eclipse.jetty.webapp.WebAppContext.addEventListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。