Source Code Cross Referenced for PortletDispatcherImpl.java in  » Portal » gridsphere » org » gridsphere » portletcontainer » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » gridsphere » org.gridsphere.portletcontainer.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
003:         * @version $Id: PortletDispatcherImpl.java 6408 2008-01-25 13:38:39Z docentt $
004:         */package org.gridsphere.portletcontainer.impl;
005:
006:        import org.apache.commons.logging.Log;
007:        import org.apache.commons.logging.LogFactory;
008:        import org.gridsphere.layout.event.PortletWindowEvent;
009:        import org.gridsphere.portlet.impl.SportletProperties;
010:        import org.gridsphere.portletcontainer.DefaultPortletAction;
011:        import org.gridsphere.portletcontainer.DefaultPortletRender;
012:        import org.gridsphere.portletcontainer.PortletDispatcher;
013:        import org.gridsphere.portletcontainer.PortletDispatcherException;
014:
015:        import javax.servlet.RequestDispatcher;
016:        import javax.servlet.ServletException;
017:        import javax.servlet.http.HttpServletRequest;
018:        import javax.servlet.http.HttpServletResponse;
019:        import java.io.IOException;
020:
021:        /**
022:         * The <code>PortletDispatcher</code> provides a mechanism for invoking portlet lifecycle methods by using a
023:         * <code>RequestDispatcher</code> from the Servlet API to forward requests to other portlets (servlets).
024:         *
025:         * @see <code>PortletInvoker</code>
026:         */
027:        public class PortletDispatcherImpl implements  PortletDispatcher {
028:
029:            public static Log log = LogFactory
030:                    .getLog(PortletDispatcherImpl.class);
031:
032:            private RequestDispatcher rd;
033:
034:            /**
035:             * Default constructor is kept private
036:             */
037:            private PortletDispatcherImpl() {
038:            }
039:
040:            /**
041:             * Constructs a PortletDispatcher from a <code>RequestDispatcher</code> and an <code>ApplicationPortletConfig</code>
042:             *
043:             * @param rd the <code>RequestDispatcher</code>
044:             */
045:            public PortletDispatcherImpl(RequestDispatcher rd) {
046:                this .rd = rd;
047:            }
048:
049:            public void init(HttpServletRequest req, HttpServletResponse res)
050:                    throws PortletDispatcherException {
051:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
052:                        SportletProperties.INIT);
053:                try {
054:                    include(req, res);
055:                } catch (ServletException e) {
056:                    throw new PortletDispatcherException(
057:                            "Unable to initialize servlet", e.getRootCause());
058:                } catch (Exception e) {
059:                    throw new PortletDispatcherException(
060:                            "Unable to initialize portlet: ", e);
061:                } finally {
062:                    req
063:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
064:                }
065:            }
066:
067:            public void load(HttpServletRequest req, HttpServletResponse res)
068:                    throws PortletDispatcherException {
069:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
070:                        SportletProperties.LOAD);
071:                try {
072:                    include(req, res);
073:                } catch (ServletException e) {
074:                    throw new PortletDispatcherException(
075:                            "Unable to initialize servlet", e.getRootCause());
076:                } catch (Exception e) {
077:                    throw new PortletDispatcherException(
078:                            "Unable to load portlet: ", e);
079:                } finally {
080:                    req
081:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
082:                }
083:            }
084:
085:            public void destroy(HttpServletRequest req, HttpServletResponse res)
086:                    throws PortletDispatcherException {
087:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
088:                        SportletProperties.DESTROY);
089:                try {
090:                    include(req, res);
091:                } catch (ServletException e) {
092:                    throw new PortletDispatcherException(
093:                            "Unable to perform destroy", e.getRootCause());
094:                } catch (Exception e) {
095:                    throw new PortletDispatcherException(
096:                            "Unable to perform destroy: ", e);
097:                } finally {
098:                    req
099:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
100:                }
101:            }
102:
103:            public void service(DefaultPortletRender render,
104:                    HttpServletRequest req, HttpServletResponse res)
105:                    throws PortletDispatcherException {
106:                req.setAttribute(SportletProperties.RENDER_EVENT, render);
107:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
108:                        SportletProperties.SERVICE);
109:                try {
110:                    include(req, res);
111:                } catch (ServletException e) {
112:                    throw new PortletDispatcherException(
113:                            "Unable to perform service", e.getRootCause());
114:                } catch (Exception e) {
115:                    throw new PortletDispatcherException(
116:                            "Unable to perform service", e);
117:                } finally {
118:                    req
119:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
120:                }
121:            }
122:
123:            public void login(HttpServletRequest req, HttpServletResponse res)
124:                    throws PortletDispatcherException {
125:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
126:                        SportletProperties.LOGIN);
127:                try {
128:                    include(req, res);
129:                } catch (ServletException e) {
130:                    throw new PortletDispatcherException(
131:                            "Unable to perform login", e.getRootCause());
132:                } catch (Exception e) {
133:                    throw new PortletDispatcherException(
134:                            "Unable to perform login", e);
135:                } finally {
136:                    req
137:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
138:                }
139:            }
140:
141:            public void logout(HttpServletRequest req, HttpServletResponse res)
142:                    throws PortletDispatcherException {
143:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
144:                        SportletProperties.LOGOUT);
145:                try {
146:                    include(req, res);
147:                } catch (ServletException e) {
148:                    throw new PortletDispatcherException(
149:                            "Unable to perform logout", e.getRootCause());
150:                } catch (Exception e) {
151:                    throw new PortletDispatcherException(
152:                            "Unable to perform logout", e);
153:                } finally {
154:                    req
155:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
156:                }
157:            }
158:
159:            public void actionPerformed(DefaultPortletAction action,
160:                    HttpServletRequest req, HttpServletResponse res)
161:                    throws PortletDispatcherException {
162:                req.setAttribute(SportletProperties.ACTION_EVENT, action);
163:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
164:                        SportletProperties.SERVICE);
165:                req.setAttribute(SportletProperties.PORTLET_ACTION_METHOD,
166:                        SportletProperties.ACTION_PERFORMED);
167:                try {
168:                    include(req, res);
169:                } catch (ServletException e) {
170:                    throw new PortletDispatcherException(
171:                            "Unable to perform actionPerformed", e
172:                                    .getRootCause());
173:                } catch (Exception e) {
174:                    throw new PortletDispatcherException(
175:                            "Unable to perform actionPerformed", e);
176:                } finally {
177:                    req.removeAttribute(SportletProperties.ACTION_EVENT);
178:                    req
179:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
180:                    req
181:                            .removeAttribute(SportletProperties.PORTLET_ACTION_METHOD);
182:                }
183:            }
184:
185:            public void doTitle(HttpServletRequest req, HttpServletResponse res)
186:                    throws PortletDispatcherException {
187:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
188:                        SportletProperties.SERVICE);
189:                req.setAttribute(SportletProperties.PORTLET_ACTION_METHOD,
190:                        SportletProperties.DO_TITLE);
191:                try {
192:                    include(req, res);
193:                } catch (ServletException e) {
194:                    throw new PortletDispatcherException(
195:                            "Unable to perform doTitle", e.getRootCause());
196:                } catch (Exception e) {
197:                    throw new PortletDispatcherException(
198:                            "Unable to perform doTitle", e);
199:                } finally {
200:                    req
201:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
202:                    req
203:                            .removeAttribute(SportletProperties.PORTLET_ACTION_METHOD);
204:                }
205:            }
206:
207:            public void windowEvent(PortletWindowEvent event,
208:                    HttpServletRequest req, HttpServletResponse res)
209:                    throws PortletDispatcherException {
210:                req.setAttribute(SportletProperties.WINDOW_EVENT, event);
211:                req.setAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD,
212:                        SportletProperties.SERVICE);
213:                req.setAttribute(SportletProperties.PORTLET_ACTION_METHOD,
214:                        SportletProperties.WINDOW_EVENT);
215:                try {
216:                    include(req, res);
217:                } catch (ServletException e) {
218:                    throw new PortletDispatcherException(
219:                            "Unable to perform windowEvent", e.getRootCause());
220:                } catch (Exception e) {
221:                    throw new PortletDispatcherException(
222:                            "Unable to perform windowEvent", e);
223:                } finally {
224:                    req.removeAttribute(SportletProperties.WINDOW_EVENT);
225:                    req
226:                            .removeAttribute(SportletProperties.PORTLET_LIFECYCLE_METHOD);
227:                    req
228:                            .removeAttribute(SportletProperties.PORTLET_ACTION_METHOD);
229:                }
230:            }
231:
232:            /**
233:             * Underlying method used by all other dispatcher methods to invoke the appropriate portlet lifecycle method
234:             *
235:             * @param req a <code>HttpServletRequest</code>
236:             * @param res a <code>HttpServletResponse</code>
237:             * @throws IOException      if an I/O error occurs
238:             * @throws ServletException if a servlet exception occurs
239:             */
240:            protected synchronized void include(HttpServletRequest req,
241:                    HttpServletResponse res) throws IOException,
242:                    ServletException {
243:                rd.include(req, res);
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.