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