View Javadoc

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