Ejemplo n.º 1
0
 public void attributeReplaced(ServletContextAttributeEvent evt) {
   final String name = evt.getName();
   if (!shallIgnore(name)) {
     final WebApp wapp = WebManager.getWebAppIfAny(evt.getServletContext());
     if (wapp instanceof SimpleWebApp)
       ((SimpleWebApp) wapp).getScopeListeners().notifyReplaced(name, evt.getValue());
   }
 }
Ejemplo n.º 2
0
 public void sessionDestroyed(HttpSessionEvent evt) {
   // Note: Session Fixation Protection (such as Spring Security)
   // might invalidate HTTP session and restore with a new one.
   // Thus, we use an attribute to denote this case and avoid the callback
   final HttpSession hsess = evt.getSession();
   if (hsess.getAttribute(Attributes.RENEW_NATIVE_SESSION) == null)
     WebManager.sessionDestroyed(hsess);
 }
Ejemplo n.º 3
0
 public void contextInitialized(ServletContextEvent event) {
   /*
    * From latest servlet specification:
    * All ServletContextListeners are notified of context initialization
    * before any filters or servlets in the web application are initialized.
    *
    * The servlet specification of Version 2.3 only provide the description
    * "Notification that the web application is ready to process requests.",
    * the order of initialization of listeners and servlets
    * may not guaranteed in older servlet version.
    *
    * @since 6.0.1
    */
   final ServletContext ctx = event.getServletContext();
   if (WebManager.getWebManagerIfAny(ctx) == null) {
     _webman = new WebManager(ctx, "/zkau");
     _webmanCreated = true;
   }
 }
Ejemplo n.º 4
0
  private boolean dispatch(Writer out, String page, Map params, int mode, boolean include)
      throws IOException, ServletException {
    // FUTURE: handle if ~./, PASS_THRU_ATTR and with query string
    // In other words, we convert query string to params if
    // PASS_THRU_ATTR and ~./ (to have a better performance)
    if ((mode != PASS_THRU_ATTR && params != null)
        || !page.startsWith("~./")
        || page.indexOf('?') >= 0) return false;

    // Bug 1801028: We cannot invoke ZumlExtendlet directly
    // The real reason is unknown yet -- it could be due to
    // the re-creation of ExecutionImpl
    // However, the performance is not a major issue, so just skip
    final ClassWebResource cwr = WebManager.getWebManager(_ctx).getClassWebResource();
    if (!isDirectInclude(cwr, page)) return false;

    Object old = null;
    if (mode == PASS_THRU_ATTR) {
      old = _request.getAttribute(Attributes.ARG);
      if (params != null) _request.setAttribute(Attributes.ARG, params);
      // If params=null, use the 'inherited' one (same as Servlets.include)
    }

    final String attrnm =
        include ? "org.zkoss.web.servlet.include" : "org.zkoss.web.servlet.forward";
    _request.setAttribute(attrnm, Boolean.TRUE);
    // so Servlets.isIncluded returns correctly
    try {
      cwr.service(_request, HttpBufferedResponse.getInstance(_response, out), page.substring(2));
    } finally {
      _request.removeAttribute(attrnm);
      if (mode == PASS_THRU_ATTR) _request.setAttribute(Attributes.ARG, old);
    }

    return true;
  }
Ejemplo n.º 5
0
 public void contextDestroyed(ServletContextEvent arg0) {
   if (_webman != null) {
     if (_webmanCreated) _webman.destroy();
     _webman = null;
   }
 }
Ejemplo n.º 6
0
 WebApp getWebApp() {
   return _webctx != null
       ? WebManager.getWebManager(_webctx.getServletContext()).getWebApp()
       : null;
 }