01: /* ServletPortletDispatcher.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Jan 17 00:44:46 2006, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2006 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.web.portlet;
20:
21: import javax.portlet.PortletRequestDispatcher;
22: import javax.portlet.RenderRequest;
23: import javax.portlet.RenderResponse;
24: import javax.portlet.PortletException;
25:
26: import javax.servlet.RequestDispatcher;
27: import javax.servlet.ServletException;
28:
29: /**
30: * A facade of a RequestDispatch for implementing PortletRequestDispatcher.
31: *
32: * @author tomyeh
33: */
34: public class ServletPortletDispatcher implements
35: PortletRequestDispatcher {
36: private final RequestDispatcher _rd;
37:
38: /** Returns a facade instance for the specified dispatcher. */
39: public static final PortletRequestDispatcher getInstance(
40: RequestDispatcher rd) {
41: if (rd instanceof PortletRequestDispatcher)
42: return (PortletRequestDispatcher) rd;
43: return new ServletPortletDispatcher(rd);
44: }
45:
46: private ServletPortletDispatcher(RequestDispatcher rd) {
47: if (rd == null)
48: throw new IllegalArgumentException("null");
49: _rd = rd;
50: }
51:
52: public void include(RenderRequest request, RenderResponse response)
53: throws PortletException, java.io.IOException {
54: try {
55: _rd.include(RenderHttpServletRequest.getInstance(request),
56: RenderHttpServletResponse.getInstance(response));
57: } catch (ServletException ex) {
58: if (ex.getRootCause() != null) {
59: throw new PortletException(ex.getRootCause());
60: } else {
61: throw new PortletException(ex);
62: }
63: }
64: }
65: }
|