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.factory;
21  
22  import javax.portlet.ActionRequest;
23  import javax.portlet.ActionResponse;
24  import javax.portlet.PortalContext;
25  import javax.portlet.PortletConfig;
26  import javax.portlet.PortletContext;
27  import javax.portlet.PortletPreferences;
28  import javax.portlet.PortletSession;
29  import javax.portlet.PortletURL;
30  import javax.portlet.RenderRequest;
31  import javax.portlet.RenderResponse;
32  
33  import org.apache.pluto.om.entity.PortletEntity;
34  import org.apache.pluto.om.portlet.PortletApplicationDefinition;
35  import org.apache.pluto.om.portlet.PortletDefinition;
36  import org.apache.pluto.om.window.PortletWindow;
37  import org.apache.pluto.services.factory.FactoryManager;
38  
39  public class PortletObjectAccess {
40  
41      public static RenderRequest getRenderRequest(PortletWindow portletWindow,
42                                                   javax.servlet.http.HttpServletRequest servletRequest,
43                                                   javax.servlet.http.HttpServletResponse servletResponse)
44      {
45          return getRequestFactory().getRenderRequest(portletWindow,
46                                                      servletRequest,
47                                                      servletResponse);
48      }
49  
50      public static RenderResponse getRenderResponse(PortletWindow portletWindow,
51                                                     javax.servlet.http.HttpServletRequest servletRequest,
52                                                     javax.servlet.http.HttpServletResponse servletResponse,
53                                                     boolean containerSupportsBuffering)
54      {
55          return getResponseFactory().getRenderResponse(portletWindow,
56                                                        servletRequest,
57                                                        servletResponse,
58                                                        containerSupportsBuffering);
59      }
60  
61      public static PortletSession getPortletSession(PortletWindow portletWindow,
62                                                     javax.servlet.http.HttpSession httpSession)
63      {
64          return getSessionFactory().getPortletSession(portletWindow,
65                                                       httpSession);
66      }
67  
68      public static PortletConfig getPortletConfig(javax.servlet.ServletConfig servletConfig,
69                                                   PortletContext portletContext,
70                                                   PortletDefinition portletDefinition)
71      {
72          return getConfigFactory().getPortletConfig(servletConfig,
73                                                     portletContext,
74                                                     portletDefinition);
75      }
76  
77      public static PortletContext getPortletContext(javax.servlet.ServletContext servletContext,
78                                                     PortletApplicationDefinition portletApplicationDefinition)
79      {
80          return getContextFactory().getPortletContext(servletContext, 
81                                                       portletApplicationDefinition);
82      }
83  
84      public static ActionRequest getActionRequest(PortletWindow portletWindow,
85                                                   javax.servlet.http.HttpServletRequest servletRequest,
86                                                   javax.servlet.http.HttpServletResponse servletResponse)
87      {
88          return getActionRequestFactory().getActionRequest(portletWindow,
89                                                            servletRequest,
90                                                            servletResponse);
91      }
92  
93      public static ActionResponse getActionResponse(PortletWindow portletWindow,
94                                                     javax.servlet.http.HttpServletRequest servletRequest,
95                                                     javax.servlet.http.HttpServletResponse servletResponse)
96      {
97          return getActionResponseFactory().getActionResponse(portletWindow,
98                                                              servletRequest,
99                                                              servletResponse);
100     } 
101 
102     public static PortletURL getPortletURL(PortletWindow portletWindow,
103                                            javax.servlet.http.HttpServletRequest servletRequest,
104                                            javax.servlet.http.HttpServletResponse servletResponse)
105     {
106         return getPortletURL(portletWindow, servletRequest, servletResponse, false);
107     }
108 
109     public static PortletURL getPortletURL(PortletWindow portletWindow,
110                                            javax.servlet.http.HttpServletRequest servletRequest,
111                                            javax.servlet.http.HttpServletResponse servletResponse,
112                                            boolean isAction)
113     {
114         return getPortletURLFactory().getPortletURL(portletWindow,
115                                                     servletRequest,
116                                                     servletResponse,
117                                                     isAction);
118     }
119 
120     public static PortalContext getPortalContext()
121     {
122         return getPortalContextFactory().getPortalContext();
123     }
124 
125     public static PortletPreferences getPortletPreferences(Integer methodId, PortletEntity portletEntity)
126     {
127         return getPortletPreferencesFactory().getPortletPreferences(methodId, portletEntity);
128     }
129 
130     public static PortletPreferences getPortletPreferences(Integer methodId, PortletDefinition portletDefinition)
131     {
132         return getPortletPreferencesFactory().getPortletPreferences(methodId, portletDefinition);
133     }
134 
135     private static RenderRequestFactory getRequestFactory()
136     {
137         return (RenderRequestFactory)FactoryManager.getFactory(javax.portlet.RenderRequest.class);
138     }
139 
140     private static RenderResponseFactory getResponseFactory()
141     {
142         return (RenderResponseFactory)FactoryManager.getFactory(javax.portlet.RenderResponse.class);
143     }
144 
145     private static PortletSessionFactory getSessionFactory()
146     {
147         return (PortletSessionFactory)FactoryManager.getFactory(javax.portlet.PortletSession.class);
148     }
149 
150     private static PortletConfigFactory getConfigFactory()
151     {
152         return (PortletConfigFactory)FactoryManager.getFactory(javax.portlet.PortletConfig.class);
153     }
154 
155     private static PortletContextFactory getContextFactory()
156     {
157         return (PortletContextFactory)FactoryManager.getFactory(javax.portlet.PortletContext.class);
158     }
159 
160     private static ActionRequestFactory getActionRequestFactory()
161     {
162         return (ActionRequestFactory)FactoryManager.getFactory(javax.portlet.ActionRequest.class);
163     }
164 
165     private static ActionResponseFactory getActionResponseFactory()
166     {
167         return (ActionResponseFactory)FactoryManager.getFactory(javax.portlet.ActionResponse.class);
168     }
169 
170     private static PortletURLFactory getPortletURLFactory()
171     {
172         return (PortletURLFactory)FactoryManager.getFactory(javax.portlet.PortletURL.class);
173     }
174 
175     private static PortalContextFactory getPortalContextFactory()
176     {
177         return (PortalContextFactory)FactoryManager.getFactory(javax.portlet.PortalContext.class);
178     }
179 
180     private static PortletPreferencesFactory getPortletPreferencesFactory()
181     { 
182         return (PortletPreferencesFactory)FactoryManager.getFactory(javax.portlet.PortletPreferences.class);
183     }
184 }