Example #1
0
  protected void initializeContainerComponent(XWikiContext context) throws ServletException {
    // Initialize the Container fields (request, response, session).
    // Note that this is a bridge between the old core and the component architecture.
    // In the new component architecture we use ThreadLocal to transport the request,
    // response and session to components which require them.
    // In the future this Servlet will be replaced by the XWikiPlexusServlet Servlet.
    ServletContainerInitializer containerInitializer =
        Utils.getComponent(ServletContainerInitializer.class);

    try {
      containerInitializer.initializeRequest(context.getRequest().getHttpServletRequest(), context);
      containerInitializer.initializeResponse(context.getResponse());
      containerInitializer.initializeSession(context.getRequest().getHttpServletRequest());
    } catch (ServletContainerException e) {
      throw new ServletException("Failed to initialize Request/Response or Session", e);
    }
  }
  /**
   * @param context the XWiki context
   * @throws ServletException if the container component initialization fails
   */
  protected void initializeContainerComponent(XWikiContext context) throws ServletException {
    // Initialize the Container fields (request, response, session). Note that this is a bridge
    // between the old core
    // and the component architecture. In the new component architecture we use ThreadLocal to
    // transport the
    // request, response and session to components which require them.
    @SuppressWarnings("deprecation")
    ServletContainerInitializer containerInitializer =
        Utils.getComponent((Type) ServletContainerInitializer.class);

    try {
      containerInitializer.initializeRequest(context.getRequest().getHttpServletRequest(), context);
      containerInitializer.initializeResponse(context.getResponse());
      containerInitializer.initializeSession(context.getRequest().getHttpServletRequest());
    } catch (ServletContainerException e) {
      throw new ServletException("Failed to initialize Request/Response or Session", e);
    }
  }