01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.portlet.context;
06:
07: import java.io.IOException;
08:
09: import javax.servlet.ServletContext;
10: import javax.servlet.ServletException;
11: import javax.servlet.http.HttpServlet;
12: import javax.servlet.http.HttpServletRequest;
13: import javax.servlet.http.HttpServletResponse;
14:
15: import org.apache.commons.logging.Log;
16: import org.apache.commons.logging.LogFactory;
17:
18: import com.opensymphony.webwork.WebWorkStatics;
19: import com.opensymphony.xwork.ActionContext;
20:
21: /**
22: * Since a portlet is not dispatched the same way as a servlet, the
23: * {@link com.opensymphony.webwork.ServletActionContext} is not immediately available, as it
24: * depends on objects from the servlet API. However, the WW2 view implementations require access
25: * to the objects in the {@link com.opensymphony.webwork.ServletActionContext}, and this servlet
26: * makes sure that these are available when the portlet actions are executing the render results.
27: *
28: * @author Nils-Helge Garli
29: */
30: public class PreparatorServlet extends HttpServlet implements
31: WebWorkStatics {
32:
33: private final static Log LOG = LogFactory
34: .getLog(PreparatorServlet.class);
35:
36: /**
37: * Prepares the {@link com.opensymphony.webwork.ServletActionContext} with the
38: * {@link ServletContext}, {@link HttpServletRequest} and {@link HttpServletResponse}.
39: */
40: public void service(HttpServletRequest servletRequest,
41: HttpServletResponse servletResponse)
42: throws ServletException, IOException {
43: LOG.debug("Preparing servlet objects for dispatch");
44: ServletContext ctx = getServletContext();
45: ActionContext.getContext().put(SERVLET_CONTEXT, ctx);
46: ActionContext.getContext().put(HTTP_REQUEST, servletRequest);
47: ActionContext.getContext().put(HTTP_RESPONSE, servletResponse);
48: LOG.debug("Preparation complete");
49: }
50:
51: }
|