Example usage for org.apache.commons.chain.web.servlet ServletWebContext initialize

List of usage examples for org.apache.commons.chain.web.servlet ServletWebContext initialize

Introduction

In this page you can find the example usage for org.apache.commons.chain.web.servlet ServletWebContext initialize.

Prototype

public void initialize(ServletContext context, HttpServletRequest request, HttpServletResponse response) 

Source Link

Document

Initialize (or reinitialize) this ServletWebContext instance for the specified Servlet API objects.

Usage

From source file:org.apache.struts.chain.legacy.ComposableRequestProcessor.java

/**
 * <p>Process an <code>HttpServletRequest</code> and create the
 * corresponding <code>HttpServletResponse</code>.</p>
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a processing exception occurs
 *///from  w  w w .  j a  v  a2 s  . co  m
public void process(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    // Wrap the request in the case of a multipart request
    request = processMultipart(request);

    // Create and populate a Context for this request
    ServletWebContext context = new ServletWebContext();
    context.initialize(getServletContext(), request, response);
    context.put(Constants.ACTION_SERVLET_KEY, this.servlet);
    context.put(Constants.MODULE_CONFIG_KEY, this.moduleConfig);

    // Create and execute the command.
    try {
        if (log.isDebugEnabled()) {
            log.debug("Using processing chain for this request");
        }
        command.execute(context);
    } catch (Exception e) {
        // Execute the exception processing chain??
        throw new ServletException(e);
    }

    // Release the context.
    context.release();
}