001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.jsf.context;
031:
032: import javax.el.*;
033: import javax.faces.context.*;
034: import javax.servlet.*;
035: import javax.servlet.http.*;
036:
037: import java.lang.reflect.Method;
038:
039: import com.caucho.util.*;
040: import com.caucho.jsp.el.*;
041: import com.caucho.jsf.el.*;
042:
043: public class FacesELContext extends ServletELContext {
044: private static final javax.el.FunctionMapper NULL_FUNCTION_MAPPER = new NullFunctionMapper();
045:
046: private FacesContext _facesContext;
047: private ELResolver _elResolver;
048:
049: public FacesELContext(FacesContext facesContext,
050: ELResolver elResolver) {
051: _facesContext = facesContext;
052: _elResolver = elResolver;
053: }
054:
055: public ELResolver getELResolver() {
056: return _elResolver;
057: }
058:
059: public javax.el.FunctionMapper getFunctionMapper() {
060: return NULL_FUNCTION_MAPPER;
061: }
062:
063: public javax.el.VariableMapper getVariableMapper() {
064: return JsfImplicitVariableMapper.MAPPER;
065: }
066:
067: // ServletELContext
068:
069: @Override
070: public Object getRequestScope() {
071: return _facesContext.getExternalContext().getRequestMap();
072: }
073:
074: @Override
075: public Object getSessionScope() {
076: return _facesContext.getExternalContext().getSessionMap();
077: }
078:
079: @Override
080: public Object getApplicationScope() {
081: return _facesContext.getExternalContext().getApplicationMap();
082: }
083:
084: @Override
085: public ServletContext getApplication() {
086: return (ServletContext) _facesContext.getExternalContext()
087: .getContext();
088: }
089:
090: public HttpServletRequest getRequest() {
091: return (HttpServletRequest) _facesContext.getExternalContext()
092: .getRequest();
093: }
094:
095: static class NullFunctionMapper extends javax.el.FunctionMapper {
096: @Override
097: public Method resolveFunction(String prefix, String localName) {
098: return null;
099: }
100: }
101: }
|