Author: awiner
Date: Fri Jun 30 15:32:00 2006
New Revision: 418400

URL: http://svn.apache.org/viewvc?rev=418400&view=rev
Log:
Fix access exceptions when resolving EL expressions like 
#{facesContext.externalContext} or #{facesContext.externalContext.request}

Modified:
    
incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/ExternalContextDecorator.java
    
incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/FacesContextFactoryImpl.java

Modified: 
incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/ExternalContextDecorator.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/ExternalContextDecorator.java?rev=418400&r1=418399&r2=418400&view=diff
==============================================================================
--- 
incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/ExternalContextDecorator.java
 (original)
+++ 
incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/ExternalContextDecorator.java
 Fri Jun 30 15:32:00 2006
@@ -13,201 +13,201 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.context;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.Principal;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Set;
-import java.util.Map;
-
-import javax.faces.context.ExternalContext;
-
-
-/**
- * Base class for decorating ExternalContexts.
- *
- * @author The Oracle ADF Faces Team
- */
-abstract class ExternalContextDecorator extends ExternalContext
-{
-  public void dispatch(String path) throws IOException
-  {
-    getExternalContext().dispatch(path);
-  }
-
-
-  public Object getContext()
-  { 
-    return getExternalContext().getContext();
-  }
-  
-  public Object getRequest()
-  {
-    return getExternalContext().getRequest(); 
-  }
-  
-  public Object getResponse()
-  {
-    return getExternalContext().getResponse();
-  }
-  
-  public Object getSession(boolean create)
-  {
-    return getExternalContext().getSession(create);
-  }
-  
-  public String getRequestContextPath()
-  {
-    return getExternalContext().getRequestContextPath();
-  }
-
-  public String getRequestPathInfo()
-  {
-    return getExternalContext().getRequestPathInfo();
-  }
-
-  public String getRequestServletPath()
-  {
-    return getExternalContext().getRequestServletPath();
-  }
-
-  public String getInitParameter(String name)
-  {
-    return getExternalContext().getInitParameter(name);
-  }
-  
-  public String encodeResourceURL(String url)
-  {
-    return getExternalContext().encodeResourceURL(url);
-  }
-
-  public String encodeActionURL(String url)
-  {
-    return getExternalContext().encodeActionURL(url);
-  }
-
-  public String encodeNamespace(String ns)
-  {
-    return getExternalContext().encodeNamespace(ns);
-  }
-
-  public String getAuthType()
-  {
-    return getExternalContext().getAuthType();
-  }
-
-  public String getRemoteUser()
-  {
-    return getExternalContext().getRemoteUser();
-  }
-
-  public Principal getUserPrincipal()
-  {
-    return getExternalContext().getUserPrincipal();
-  }
-
-  public boolean isUserInRole(String role)
-  {
-    return getExternalContext().isUserInRole(role);
-  }
-
-  public URL getResource(String path) throws MalformedURLException
-  {
-    return getExternalContext().getResource(path);
-  }
-
-  public InputStream getResourceAsStream(String path)
-  {
-    return getExternalContext().getResourceAsStream(path);
-  }
-
-  public Set getResourcePaths(String path)
-  {
-    return getExternalContext().getResourcePaths(path);
-  }
-
-  public Map getRequestParameterMap()
-  {
-    return getExternalContext().getRequestParameterMap();
-  }
-
-  public Map getRequestParameterValuesMap()
-  {
-    return getExternalContext().getRequestParameterValuesMap();
-  }
-
-  public Iterator getRequestParameterNames()
-  {
-    return getExternalContext().getRequestParameterNames();
-  }
-
-  public Map getRequestCookieMap()
-  {
-    return getExternalContext().getRequestCookieMap();
-  }
-
-  public Map getRequestHeaderMap()
-  {
-    return getExternalContext().getRequestHeaderMap();
-  }
-
-  public Map getRequestHeaderValuesMap()
-  {
-    return getExternalContext().getRequestHeaderValuesMap();
-  }
-
-
-  public Map getInitParameterMap()
-  {
-    return getExternalContext().getInitParameterMap();
-  }
-
-  public Map getApplicationMap()
-  {
-    return getExternalContext().getApplicationMap();
-  }
-
-  public Map getSessionMap()
-  {
-    return getExternalContext().getSessionMap();
-  }
-
-  public Map getRequestMap()
-  {
-    return getExternalContext().getRequestMap();
-  }
-
-
-  public Locale getRequestLocale()
-  {
-    return getExternalContext().getRequestLocale();
-  }
-
-  public Iterator getRequestLocales()
-  {
-    return getExternalContext().getRequestLocales();
-  }
-
-
-  public void log(String message)
-  {
-    getExternalContext().log(message);
-  }
-
-  public void log(String message, Throwable t)
-  {
-    getExternalContext().log(message, t);
-  }
-
-  public void redirect(String url) throws IOException
-  {
-    getExternalContext().redirect(url);
-  }
-
-  abstract protected ExternalContext getExternalContext();
-}
+package org.apache.myfaces.adfinternal.context;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.Principal;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+
+
+/**
+ * Base class for decorating ExternalContexts.
+ *
+ * @author The Oracle ADF Faces Team
+ */
+abstract public class ExternalContextDecorator extends ExternalContext
+{
+  public void dispatch(String path) throws IOException
+  {
+    getExternalContext().dispatch(path);
+  }
+
+
+  public Object getContext()
+  { 
+    return getExternalContext().getContext();
+  }
+  
+  public Object getRequest()
+  {
+    return getExternalContext().getRequest(); 
+  }
+  
+  public Object getResponse()
+  {
+    return getExternalContext().getResponse();
+  }
+  
+  public Object getSession(boolean create)
+  {
+    return getExternalContext().getSession(create);
+  }
+  
+  public String getRequestContextPath()
+  {
+    return getExternalContext().getRequestContextPath();
+  }
+
+  public String getRequestPathInfo()
+  {
+    return getExternalContext().getRequestPathInfo();
+  }
+
+  public String getRequestServletPath()
+  {
+    return getExternalContext().getRequestServletPath();
+  }
+
+  public String getInitParameter(String name)
+  {
+    return getExternalContext().getInitParameter(name);
+  }
+  
+  public String encodeResourceURL(String url)
+  {
+    return getExternalContext().encodeResourceURL(url);
+  }
+
+  public String encodeActionURL(String url)
+  {
+    return getExternalContext().encodeActionURL(url);
+  }
+
+  public String encodeNamespace(String ns)
+  {
+    return getExternalContext().encodeNamespace(ns);
+  }
+
+  public String getAuthType()
+  {
+    return getExternalContext().getAuthType();
+  }
+
+  public String getRemoteUser()
+  {
+    return getExternalContext().getRemoteUser();
+  }
+
+  public Principal getUserPrincipal()
+  {
+    return getExternalContext().getUserPrincipal();
+  }
+
+  public boolean isUserInRole(String role)
+  {
+    return getExternalContext().isUserInRole(role);
+  }
+
+  public URL getResource(String path) throws MalformedURLException
+  {
+    return getExternalContext().getResource(path);
+  }
+
+  public InputStream getResourceAsStream(String path)
+  {
+    return getExternalContext().getResourceAsStream(path);
+  }
+
+  public Set getResourcePaths(String path)
+  {
+    return getExternalContext().getResourcePaths(path);
+  }
+
+  public Map getRequestParameterMap()
+  {
+    return getExternalContext().getRequestParameterMap();
+  }
+
+  public Map getRequestParameterValuesMap()
+  {
+    return getExternalContext().getRequestParameterValuesMap();
+  }
+
+  public Iterator getRequestParameterNames()
+  {
+    return getExternalContext().getRequestParameterNames();
+  }
+
+  public Map getRequestCookieMap()
+  {
+    return getExternalContext().getRequestCookieMap();
+  }
+
+  public Map getRequestHeaderMap()
+  {
+    return getExternalContext().getRequestHeaderMap();
+  }
+
+  public Map getRequestHeaderValuesMap()
+  {
+    return getExternalContext().getRequestHeaderValuesMap();
+  }
+
+
+  public Map getInitParameterMap()
+  {
+    return getExternalContext().getInitParameterMap();
+  }
+
+  public Map getApplicationMap()
+  {
+    return getExternalContext().getApplicationMap();
+  }
+
+  public Map getSessionMap()
+  {
+    return getExternalContext().getSessionMap();
+  }
+
+  public Map getRequestMap()
+  {
+    return getExternalContext().getRequestMap();
+  }
+
+
+  public Locale getRequestLocale()
+  {
+    return getExternalContext().getRequestLocale();
+  }
+
+  public Iterator getRequestLocales()
+  {
+    return getExternalContext().getRequestLocales();
+  }
+
+
+  public void log(String message)
+  {
+    getExternalContext().log(message);
+  }
+
+  public void log(String message, Throwable t)
+  {
+    getExternalContext().log(message, t);
+  }
+
+  public void redirect(String url) throws IOException
+  {
+    getExternalContext().redirect(url);
+  }
+
+  abstract protected ExternalContext getExternalContext();
+}

Modified: 
incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/FacesContextFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/FacesContextFactoryImpl.java?rev=418400&r1=418399&r2=418400&view=diff
==============================================================================
--- 
incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/FacesContextFactoryImpl.java
 (original)
+++ 
incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/context/FacesContextFactoryImpl.java
 Fri Jun 30 15:32:00 2006
@@ -13,212 +13,212 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.context;
-
-import java.io.IOException;
-
-import java.util.Iterator;
-
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.FacesContextFactory;
-import javax.faces.context.ResponseStream;
-import javax.faces.context.ResponseWriter;
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.render.RenderKit;
-
-import org.apache.myfaces.adf.logging.ADFLogger;
-import org.apache.myfaces.adf.context.AdfFacesContext;
-
-/**
- * Internal class that optimizes retrieval of the RenderKit by caching it
- * on the FacesContext, and hooks ExternalContext.dispatch()
- * to use the PageResolver.
- * <p>
- * @author The Oracle ADF Faces Team
- */
-public class FacesContextFactoryImpl
-  extends FacesContextFactory
-{
-  public FacesContextFactoryImpl(FacesContextFactory factory)
-  {
-    _factory = factory;
-  }
-
-  public FacesContext getFacesContext(Object context, Object request,
-                                      Object response, Lifecycle lifecycle)
-  {
-    return new CacheRenderKit(_factory.getFacesContext(context,
-                                                       request,
-                                                       response,
-                                                       lifecycle));
-  }
-
-  static private class CacheRenderKit extends FacesContext
-  {
-    public CacheRenderKit(FacesContext base)
-    {
-      _base = base;
-      _external = new OverrideDispatch(base.getExternalContext());
-      setCurrentInstance(this);
-    }
-
-    public Application getApplication()
-    {
-      return _base.getApplication();
-    }
-
-    public Iterator getClientIdsWithMessages()
-    {
-      return _base.getClientIdsWithMessages();
-    }
-
-    public ExternalContext getExternalContext()
-    {
-      return _external;
-    }
-
-    public FacesMessage.Severity getMaximumSeverity()
-    {
-      return _base.getMaximumSeverity();
-    }
-
-    public Iterator getMessages()
-    {
-      return _base.getMessages();
-    }
-
-    public Iterator getMessages(String clientId)
-    {
-      return _base.getMessages(clientId);
-    }
-
-    public RenderKit getRenderKit()
-    {
-      if (_kit == null)
-      {
-        _kit = _base.getRenderKit();
-      }
-      else
-      {
-        UIViewRoot root = getViewRoot();
-        if (root != null)
-        {
-          String renderKitId = root.getRenderKitId();
-          // Yes, instance equality, not .equals();  within a single
-          // request and single thread, instance equality should always
-          // be sufficient, and behavior will still be correct even
-          // if it was somehow not (we'll just spend more time re-getting the
-          // RenderKit)
-          if (renderKitId != _renderKitId)
-          {
-            _renderKitId = renderKitId;
-            _kit = _base.getRenderKit();
-          }
-        }
-      }
-
-      return _kit;
-    }
-
-    public boolean getRenderResponse()
-    {
-      return _base.getRenderResponse();
-    }
-
-    public boolean getResponseComplete()
-    {
-      return _base.getResponseComplete();
-    }
-
-    public ResponseStream getResponseStream()
-    {
-      return _base.getResponseStream();
-    }
-
-    public void setResponseStream(ResponseStream responseStream)
-    {
-      _base.setResponseStream(responseStream);
-    }
-
-    public ResponseWriter getResponseWriter()
-    {
-      return _base.getResponseWriter();
-    }
-
-    public void setResponseWriter(ResponseWriter responseWriter)
-    {
-      _base.setResponseWriter(responseWriter);
-    }
-
-    public UIViewRoot getViewRoot()
-    {
-      return _base.getViewRoot();
-    }
-
-    public void setViewRoot(UIViewRoot viewRoot)
-    {
-      _base.setViewRoot(viewRoot);
-    }
-
-    public void addMessage(String clientId, FacesMessage facesMessage)
-    {
-      _base.addMessage(clientId, facesMessage);
-    }
-
-    public void release()
-    {
-      _base.release();
-    }
-
-    public void renderResponse()
-    {
-      _base.renderResponse();
-    }
-
-    public void responseComplete()
-    {
-      _base.responseComplete();
-    }
-
-    private final FacesContext    _base;
-    private final ExternalContext _external;
-    private String    _renderKitId;
-    private RenderKit _kit;
-  }
-
-  static private class OverrideDispatch extends ExternalContextDecorator
-  {
-    public OverrideDispatch(ExternalContext decorated)
-    {
-      _decorated = decorated;
-    }
-
-    public void dispatch(String path) throws IOException
-    {
-      AdfFacesContext afc = AdfFacesContext.getCurrentInstance();
-      if (afc != null)
-      {
-        path = afc.getPageResolver().getPhysicalURI(path);
-      }
-
-      super.dispatch(path);
-    }
-
-
-    protected ExternalContext getExternalContext()
-    {
-      return _decorated;
-    }
-
-    private final ExternalContext _decorated;
-  }
-
-  private final FacesContextFactory _factory;
-
-  static private final ADFLogger _LOG =
-    ADFLogger.createADFLogger(FacesContextFactoryImpl.class);
-}
+package org.apache.myfaces.adfinternal.context;
+
+import java.io.IOException;
+
+import java.util.Iterator;
+
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.render.RenderKit;
+
+import org.apache.myfaces.adf.logging.ADFLogger;
+import org.apache.myfaces.adf.context.AdfFacesContext;
+
+/**
+ * Internal class that optimizes retrieval of the RenderKit by caching it
+ * on the FacesContext, and hooks ExternalContext.dispatch()
+ * to use the PageResolver.
+ * <p>
+ * @author The Oracle ADF Faces Team
+ */
+public class FacesContextFactoryImpl
+  extends FacesContextFactory
+{
+  public FacesContextFactoryImpl(FacesContextFactory factory)
+  {
+    _factory = factory;
+  }
+
+  public FacesContext getFacesContext(Object context, Object request,
+                                      Object response, Lifecycle lifecycle)
+  {
+    return new CacheRenderKit(_factory.getFacesContext(context,
+                                                       request,
+                                                       response,
+                                                       lifecycle));
+  }
+
+  static public class CacheRenderKit extends FacesContext
+  {
+    public CacheRenderKit(FacesContext base)
+    {
+      _base = base;
+      _external = new OverrideDispatch(base.getExternalContext());
+      setCurrentInstance(this);
+    }
+
+    public Application getApplication()
+    {
+      return _base.getApplication();
+    }
+
+    public Iterator getClientIdsWithMessages()
+    {
+      return _base.getClientIdsWithMessages();
+    }
+
+    public ExternalContext getExternalContext()
+    {
+      return _external;
+    }
+
+    public FacesMessage.Severity getMaximumSeverity()
+    {
+      return _base.getMaximumSeverity();
+    }
+
+    public Iterator getMessages()
+    {
+      return _base.getMessages();
+    }
+
+    public Iterator getMessages(String clientId)
+    {
+      return _base.getMessages(clientId);
+    }
+
+    public RenderKit getRenderKit()
+    {
+      if (_kit == null)
+      {
+        _kit = _base.getRenderKit();
+      }
+      else
+      {
+        UIViewRoot root = getViewRoot();
+        if (root != null)
+        {
+          String renderKitId = root.getRenderKitId();
+          // Yes, instance equality, not .equals();  within a single
+          // request and single thread, instance equality should always
+          // be sufficient, and behavior will still be correct even
+          // if it was somehow not (we'll just spend more time re-getting the
+          // RenderKit)
+          if (renderKitId != _renderKitId)
+          {
+            _renderKitId = renderKitId;
+            _kit = _base.getRenderKit();
+          }
+        }
+      }
+
+      return _kit;
+    }
+
+    public boolean getRenderResponse()
+    {
+      return _base.getRenderResponse();
+    }
+
+    public boolean getResponseComplete()
+    {
+      return _base.getResponseComplete();
+    }
+
+    public ResponseStream getResponseStream()
+    {
+      return _base.getResponseStream();
+    }
+
+    public void setResponseStream(ResponseStream responseStream)
+    {
+      _base.setResponseStream(responseStream);
+    }
+
+    public ResponseWriter getResponseWriter()
+    {
+      return _base.getResponseWriter();
+    }
+
+    public void setResponseWriter(ResponseWriter responseWriter)
+    {
+      _base.setResponseWriter(responseWriter);
+    }
+
+    public UIViewRoot getViewRoot()
+    {
+      return _base.getViewRoot();
+    }
+
+    public void setViewRoot(UIViewRoot viewRoot)
+    {
+      _base.setViewRoot(viewRoot);
+    }
+
+    public void addMessage(String clientId, FacesMessage facesMessage)
+    {
+      _base.addMessage(clientId, facesMessage);
+    }
+
+    public void release()
+    {
+      _base.release();
+    }
+
+    public void renderResponse()
+    {
+      _base.renderResponse();
+    }
+
+    public void responseComplete()
+    {
+      _base.responseComplete();
+    }
+
+    private final FacesContext    _base;
+    private final ExternalContext _external;
+    private String    _renderKitId;
+    private RenderKit _kit;
+  }
+
+  static public class OverrideDispatch extends ExternalContextDecorator
+  {
+    public OverrideDispatch(ExternalContext decorated)
+    {
+      _decorated = decorated;
+    }
+
+    public void dispatch(String path) throws IOException
+    {
+      AdfFacesContext afc = AdfFacesContext.getCurrentInstance();
+      if (afc != null)
+      {
+        path = afc.getPageResolver().getPhysicalURI(path);
+      }
+
+      super.dispatch(path);
+    }
+
+
+    protected ExternalContext getExternalContext()
+    {
+      return _decorated;
+    }
+
+    private final ExternalContext _decorated;
+  }
+
+  private final FacesContextFactory _factory;
+
+  static private final ADFLogger _LOG =
+    ADFLogger.createADFLogger(FacesContextFactoryImpl.class);
+}


Reply via email to