001: /*
002: * Copyright 2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package javax.faces.context;
017:
018: import javax.el.ELContext;
019: import javax.faces.application.FacesMessage;
020: import java.util.Iterator;
021:
022: /**
023: * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
024: *
025: * @author Manfred Geiler (latest modification by $Author: baranda $)
026: * @version $Revision: 544646 $ $Date: 2007-06-05 23:51:27 +0200 (Di, 05 Jun 2007) $
027: */
028: public abstract class FacesContext {
029: // The following concrete method was added for JSF 1.2. It supplies a default
030: // implementation that throws UnsupportedOperationException.
031: // This allows old FacesContext implementations to still work.
032: public ELContext getELContext() {
033:
034: FacesContext ctx = getCurrentInstance();
035:
036: if (ctx == null)
037: throw new NullPointerException(FacesContext.class.getName());
038:
039: ELContext elctx = ctx.getELContext();
040:
041: if (elctx == null)
042: throw new UnsupportedOperationException();
043:
044: return elctx;
045: }
046:
047: public abstract javax.faces.application.Application getApplication();
048:
049: public abstract Iterator<String> getClientIdsWithMessages();
050:
051: public abstract javax.faces.context.ExternalContext getExternalContext();
052:
053: public abstract FacesMessage.Severity getMaximumSeverity();
054:
055: public abstract Iterator<FacesMessage> getMessages();
056:
057: public abstract Iterator<FacesMessage> getMessages(String clientId);
058:
059: public abstract javax.faces.render.RenderKit getRenderKit();
060:
061: public abstract boolean getRenderResponse();
062:
063: public abstract boolean getResponseComplete();
064:
065: public abstract javax.faces.context.ResponseStream getResponseStream();
066:
067: public abstract void setResponseStream(
068: javax.faces.context.ResponseStream responseStream);
069:
070: public abstract javax.faces.context.ResponseWriter getResponseWriter();
071:
072: public abstract void setResponseWriter(
073: javax.faces.context.ResponseWriter responseWriter);
074:
075: public abstract javax.faces.component.UIViewRoot getViewRoot();
076:
077: public abstract void setViewRoot(
078: javax.faces.component.UIViewRoot root);
079:
080: public abstract void addMessage(String clientId,
081: javax.faces.application.FacesMessage message);
082:
083: public abstract void release();
084:
085: public abstract void renderResponse();
086:
087: public abstract void responseComplete();
088:
089: private static ThreadLocal<FacesContext> _currentInstance = new ThreadLocal() {
090: protected Object initialValue() {
091: return null;
092: }
093: };
094:
095: public static FacesContext getCurrentInstance() {
096: return _currentInstance.get();
097: }
098:
099: protected static void setCurrentInstance(
100: javax.faces.context.FacesContext context) {
101: _currentInstance.set(context);
102:
103: }
104: }
|