Source Code Cross Referenced for FacesContextImpl.java in  » Portal » Open-Portal » com » sun » faces » portlet » 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 » Open Portal » com.sun.faces.portlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: FacesContextImpl.java,v 1.2.16.1 2007/03/16 11:05:42 dg154973 Exp $
003:         */
004:
005:        /*
006:         * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
007:         * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
008:         */
009:
010:        package com.sun.faces.portlet;
011:
012:        import java.util.ArrayList;
013:        import java.util.HashMap;
014:        import java.util.Iterator;
015:        import java.util.List;
016:        import java.util.Map;
017:        import javax.faces.FactoryFinder;
018:        import javax.faces.application.Application;
019:        import javax.faces.application.ApplicationFactory;
020:        import javax.faces.application.FacesMessage;
021:        import javax.faces.application.FacesMessage.Severity;
022:        import javax.faces.component.UIViewRoot;
023:        import javax.faces.context.ExternalContext;
024:        import javax.faces.context.FacesContext;
025:        import javax.faces.context.ResponseWriter;
026:        import javax.faces.context.ResponseStream;
027:        import javax.faces.lifecycle.Lifecycle;
028:        import javax.faces.render.RenderKit;
029:        import javax.faces.render.RenderKitFactory;
030:
031:        import org.apache.commons.logging.Log;
032:        import org.apache.commons.logging.LogFactory;
033:
034:        /**
035:         * <p>Concrete implementation of <code>FacesContext</code> for use in
036:         * a portlet environment.</p>
037:         */
038:
039:        public final class FacesContextImpl extends FacesContext {
040:
041:            // ------------------------------------------------------------ Constructors
042:
043:            public FacesContextImpl(ExternalContext econtext,
044:                    Lifecycle lifecycle) {
045:                if ((econtext == null) || (lifecycle == null)) {
046:                    throw new NullPointerException();
047:                }
048:                this .econtext = econtext;
049:                this .lifecycle = lifecycle;
050:                setCurrentInstance(this );
051:                if (log.isTraceEnabled()) {
052:                    log.trace("Created FacesContext " + this );
053:                }
054:            }
055:
056:            // -------------------------------------------------------- Static Variables
057:
058:            // The Log instance for this class
059:            private static final Log log = LogFactory
060:                    .getLog(FacesContextFactoryImpl.class);
061:
062:            // ------------------------------------------------------ Instance Variables
063:
064:            private Application application;
065:            private ExternalContext econtext;
066:            private Lifecycle lifecycle;
067:            private Map messages = new HashMap();
068:            private boolean released = false;
069:            private boolean renderResponse = false;
070:            private boolean responseComplete = false;
071:            private ResponseStream responseStream;
072:            private ResponseWriter responseWriter;
073:            private UIViewRoot viewRoot;
074:
075:            // ------------------------------------------------- FacesContext Properties
076:
077:            public Application getApplication() {
078:                assertNotReleased();
079:                if (application == null) {
080:                    ApplicationFactory af = (ApplicationFactory) FactoryFinder
081:                            .getFactory(FactoryFinder.APPLICATION_FACTORY);
082:                    application = af.getApplication();
083:                }
084:                return (application);
085:            }
086:
087:            public Iterator getClientIdsWithMessages() {
088:                return (messages.keySet().iterator());
089:            }
090:
091:            public ExternalContext getExternalContext() {
092:                assertNotReleased();
093:                return (econtext);
094:            }
095:
096:            public Severity getMaximumSeverity() {
097:                assertNotReleased();
098:                Iterator messages = getMessages();
099:                Severity maximum = null;
100:                while (messages.hasNext()) {
101:                    Severity severity = ((FacesMessage) messages.next())
102:                            .getSeverity();
103:                    if (maximum == null) {
104:                        maximum = severity;
105:                    } else if (maximum.getOrdinal() < severity.getOrdinal()) {
106:                        maximum = severity;
107:                    }
108:                }
109:                return (maximum);
110:            }
111:
112:            public Iterator getMessages() {
113:                assertNotReleased();
114:                List results = new ArrayList();
115:                Iterator clientIds = messages.keySet().iterator();
116:                while (clientIds.hasNext()) {
117:                    String clientId = (String) clientIds.next();
118:                    results.addAll((List) messages.get(clientId));
119:                }
120:                return (results.iterator());
121:            }
122:
123:            public RenderKit getRenderKit() {
124:                assertNotReleased();
125:                UIViewRoot vr = getViewRoot();
126:                if (vr == null) {
127:                    return (null);
128:                }
129:                String renderKitId = vr.getRenderKitId();
130:                if (renderKitId == null) {
131:                    return (null);
132:                }
133:                RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
134:                        .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
135:                return (rkFactory.getRenderKit(this , renderKitId));
136:            }
137:
138:            public boolean getRenderResponse() {
139:                assertNotReleased();
140:                return (renderResponse);
141:            }
142:
143:            public boolean getResponseComplete() {
144:                assertNotReleased();
145:                return (responseComplete);
146:            }
147:
148:            public ResponseStream getResponseStream() {
149:                assertNotReleased();
150:                return (responseStream);
151:            }
152:
153:            public void setResponseStream(ResponseStream responseStream) {
154:                assertNotReleased();
155:                if (responseStream == null) {
156:                    throw new NullPointerException();
157:                }
158:                this .responseStream = responseStream;
159:            }
160:
161:            public ResponseWriter getResponseWriter() {
162:                assertNotReleased();
163:                return (responseWriter);
164:            }
165:
166:            public void setResponseWriter(ResponseWriter responseWriter) {
167:                assertNotReleased();
168:                if (responseWriter == null) {
169:                    throw new NullPointerException();
170:                }
171:                this .responseWriter = responseWriter;
172:            }
173:
174:            public UIViewRoot getViewRoot() {
175:                assertNotReleased();
176:                return (viewRoot);
177:            }
178:
179:            public void setViewRoot(UIViewRoot viewRoot) {
180:                assertNotReleased();
181:                if (viewRoot == null) {
182:                    throw new NullPointerException();
183:                }
184:                this .viewRoot = viewRoot;
185:            }
186:
187:            // ---------------------------------------------------- FacesContext Methods
188:
189:            public void addMessage(String clientId, FacesMessage message) {
190:                assertNotReleased();
191:                if (message == null) {
192:                    throw new NullPointerException();
193:                }
194:                List list = (List) messages.get(clientId);
195:                if (list == null) {
196:                    list = new ArrayList();
197:                    messages.put(clientId, list);
198:                }
199:                list.add(message);
200:            }
201:
202:            public Iterator getMessages(String clientId) {
203:                assertNotReleased();
204:                List list = (List) messages.get(clientId);
205:                if (list == null) {
206:                    list = new ArrayList();
207:                }
208:                return (list.iterator());
209:            }
210:
211:            public void release() {
212:                assertNotReleased();
213:                released = true;
214:                econtext = null;
215:                responseStream = null;
216:                responseWriter = null;
217:                messages = null;
218:                renderResponse = false;
219:                responseComplete = false;
220:                viewRoot = null;
221:                // Make sure to clear our ThreadLocal instance.
222:                setCurrentInstance(null);
223:            }
224:
225:            public void renderResponse() {
226:                assertNotReleased();
227:                renderResponse = true;
228:            }
229:
230:            public void responseComplete() {
231:                assertNotReleased();
232:                responseComplete = true;
233:            }
234:
235:            // --------------------------------------------------------- Private Methods
236:
237:            /**
238:             * <p>Throw an exception if this instance has been released.</p>
239:             */
240:            private void assertNotReleased() { // FIXME - i18n
241:                if (released) {
242:                    throw new IllegalStateException(
243:                            "This instance has been released");
244:                }
245:            }
246:
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.