KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > core > impl > PortletRequestDispatcherImpl


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17
18  */

19
20 package org.apache.pluto.core.impl;
21
22 import java.util.Map JavaDoc;
23
24 import javax.portlet.PortletException;
25 import javax.portlet.PortletRequestDispatcher;
26 import javax.portlet.RenderRequest;
27 import javax.portlet.RenderResponse;
28 import javax.servlet.RequestDispatcher JavaDoc;
29
30 import org.apache.pluto.core.CoreUtils;
31 import org.apache.pluto.core.InternalPortletRequest;
32 import org.apache.pluto.core.InternalPortletResponse;
33
34 public class PortletRequestDispatcherImpl implements PortletRequestDispatcher
35 {
36
37     private RequestDispatcher requestDispatcher;
38     private Map JavaDoc queryParams;
39
40     public PortletRequestDispatcherImpl(RequestDispatcher requestDispatcher)
41     {
42         this.requestDispatcher = requestDispatcher;
43     }
44
45     public PortletRequestDispatcherImpl(RequestDispatcher disp, Map JavaDoc queryParams) {
46         this(disp);
47         this.queryParams = queryParams;
48
49     }
50
51     // javax.portlet.PortletRequestDispatcher implementation --------------------------------------
52
public void include(RenderRequest request, RenderResponse response) throws PortletException, java.io.IOException JavaDoc
53     {
54         InternalPortletRequest internalRequest = CoreUtils.getInternalRequest(request);
55         InternalPortletResponse internalResponse = CoreUtils.getInternalResponse(response);
56
57         if(queryParams!=null) {
58             internalRequest = new IncludedRenderRequestImpl(internalRequest, queryParams);
59         }
60         try
61         {
62             internalRequest.setIncluded(true);
63             internalResponse.setIncluded(true);
64
65             this.requestDispatcher.include((javax.servlet.http.HttpServletRequest JavaDoc)request,
66                                            (javax.servlet.http.HttpServletResponse JavaDoc)response);
67         }
68         catch (java.io.IOException JavaDoc e)
69         {
70             throw e;
71         }
72         catch (javax.servlet.ServletException JavaDoc e)
73         {
74             if (e.getRootCause()!=null)
75             {
76                 throw new PortletException(e.getRootCause());
77             }
78             else
79             {
80                 throw new PortletException(e);
81             }
82         }
83         finally
84         {
85             internalRequest.setIncluded(false);
86             internalResponse.setIncluded(false);
87         }
88     }
89     // --------------------------------------------------------------------------------------------
90

91     // portlet-servlet implementation
92
/*
93         public void include(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
94         throws javax.servlet.ServletException, java.io.IOException
95         {
96         }
97     
98         public void forward(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
99         throws javax.servlet.ServletException, java.io.IOException
100         {
101         }
102     */

103 }
104
Popular Tags