You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ms...@apache.org on 2010/03/04 17:31:23 UTC

svn commit: r919055 - in /myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src: main/conf/META-INF/ main/java/org/apache/myfaces/trinidadinternal/application/ main/java/org/apache/myfaces/trinidadinternal/context/ test/java/org/apache/myfaces/tri...

Author: mstarets
Date: Thu Mar  4 16:31:22 2010
New Revision: 919055

URL: http://svn.apache.org/viewvc?rev=919055&view=rev
Log:
TRINIDAD-1735 - Trinidad 2: Provide ViewDeclarationLanguageFactory wrapper instead of overriding ViewHandler.getViewDeclarationLanguage()

Moved the logic for loading InternalViews to ViewDeclarationLanguageFactoryImpl and provided an override for getViewDeclarationLanguage() that is called in all cases

Added:
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/InternalViewHandlingStrategy.java
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewDeclarationLanguageFactory.java
      - copied, changed from r917691, myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewHandler.java
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImplTest.java
      - copied, changed from r917691, myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImplTest.java
Removed:
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewHandler.java
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImplTest.java
Modified:
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImpl.java
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
    myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/TestInternalView.java

Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml?rev=919055&r1=919054&r2=919055&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml Thu Mar  4 16:31:22 2010
@@ -39,6 +39,9 @@
     <faces-context-factory>
       org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl
     </faces-context-factory>
+    <view-declaration-language-factory>
+      org.apache.myfaces.trinidadinternal.application.ViewDeclarationLanguageFactoryImpl
+    </view-declaration-language-factory>
   </factory>
 
   <lifecycle>

Added: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/InternalViewHandlingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/InternalViewHandlingStrategy.java?rev=919055&view=auto
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/InternalViewHandlingStrategy.java (added)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/InternalViewHandlingStrategy.java Thu Mar  4 16:31:22 2010
@@ -0,0 +1,168 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.myfaces.trinidadinternal.application;
+
+import java.beans.BeanInfo;
+
+import java.io.IOException;
+
+import java.util.Locale;
+
+import javax.faces.application.Resource;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.view.StateManagementStrategy;
+import javax.faces.view.ViewDeclarationLanguage;
+import javax.faces.view.ViewMetadata;
+
+import org.apache.myfaces.trinidad.render.InternalView;
+
+public class InternalViewHandlingStrategy
+  extends ViewDeclarationLanguage
+{
+  public InternalViewHandlingStrategy(ViewDeclarationLanguageFactoryImpl.InternalViewFinder finder)
+  {
+    super();
+    _finder = finder;
+  }
+  
+  @Override
+  public UIViewRoot createView(FacesContext context, String viewId)
+  {
+    UIViewRoot root = _finder.getInternalView(context, viewId).createView(context, viewId);
+    if (root != null)
+      return root;
+    
+    return _defaultCreateView(context, viewId);
+  }
+  
+  @Override
+  public UIViewRoot restoreView(FacesContext context, String viewId)
+  {
+    return _finder.getInternalView(context, viewId).restoreView(context, viewId);
+  }
+  
+  @Override
+  public void renderView(FacesContext context, UIViewRoot viewToRender)
+    throws IOException
+  {
+    _finder.getInternalView(context, viewToRender.getViewId()).renderView(context, viewToRender);
+  }
+  
+  @Override
+  public StateManagementStrategy getStateManagementStrategy(FacesContext context, String viewId)
+  {
+    InternalView internal = _finder.getInternalView(context, viewId);
+    
+    // Use default StateManager processing for the stateful InternalViews
+    if (!internal.isStateless(context, viewId))
+      return null;
+    
+    // Otherwise, return StateManagementStrategy that does nothing
+    return _STATELESS_STRATEGY;
+  }
+
+  public BeanInfo getComponentMetadata(FacesContext facesContext,
+                                       Resource resource)
+  {
+    return null;
+  }
+
+  public ViewMetadata getViewMetadata(FacesContext facesContext,
+                                      String string)
+  {
+    return null;
+  }
+
+  public Resource getScriptComponentResource(FacesContext facesContext,
+                                             Resource resource)
+  {
+    return null;
+  }
+
+  
+  public void buildView(FacesContext facesContext, UIViewRoot uIViewRoot)
+    throws IOException
+  {
+  }
+  
+  /**
+   * Package-private method for use by the ViewHandlerImpl
+   * @param context Faces context
+   * @param viewId Veiew Id
+   * @return true if the internal view is stateless, false otherwise
+   */
+  boolean __isStateless(FacesContext context, String viewId)
+  {
+    InternalView internal = _finder.getInternalView(context, viewId);
+    return internal.isStateless(context, viewId);
+  }
+
+  
+  private UIViewRoot _defaultCreateView(FacesContext context, String viewId)
+  {
+    UIViewRoot result = (UIViewRoot) context.getApplication()
+                            .createComponent(UIViewRoot.COMPONENT_TYPE);
+    
+    Locale locale = null;
+    String renderKitId = null;
+    
+    // use the locale from the previous view if is was one which will be
+    // the case if this is called from NavigationHandler. There wouldn't be
+    // one for the initial case.
+    if (context.getViewRoot() != null) 
+    {
+      locale = context.getViewRoot().getLocale();
+      renderKitId = context.getViewRoot().getRenderKitId();
+    }
+    
+    if (locale == null) 
+    {
+      locale = context.getApplication().getViewHandler().calculateLocale(context);
+    }
+    
+    if (renderKitId == null) 
+    {
+      renderKitId = context.getApplication().getViewHandler().calculateRenderKitId(context);
+    }
+    
+    result.setLocale(locale);
+    result.setRenderKitId(renderKitId);
+    result.setViewId(viewId);
+
+    return result;
+  }
+  
+  private final ViewDeclarationLanguageFactoryImpl.InternalViewFinder _finder;
+  
+  private static final StateManagementStrategy _STATELESS_STRATEGY = 
+    new StateManagementStrategy()
+    {
+      public UIViewRoot restoreView(FacesContext context, String viewId, 
+                                    String renderKitId)
+      {
+        return null;
+      }
+      
+      public Object saveView(FacesContext context)
+      {
+        return null;
+      }
+    };
+}

Added: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java?rev=919055&view=auto
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java (added)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java Thu Mar  4 16:31:22 2010
@@ -0,0 +1,254 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.myfaces.trinidadinternal.application;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.net.URL;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.view.ViewDeclarationLanguage;
+import javax.faces.view.ViewDeclarationLanguageFactory;
+
+import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.render.InternalView;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+
+public class ViewDeclarationLanguageFactoryImpl
+  extends ViewDeclarationLanguageFactory
+{
+  public ViewDeclarationLanguageFactoryImpl(ViewDeclarationLanguageFactory delegate)
+  {
+    super();
+    _wrapped = delegate;
+    
+    _loadInternalViews();
+    
+    InternalViewFinder finder = new InternalViewFinder()
+      {
+        public InternalView getInternalView(FacesContext context, String viewId)
+        {
+          return _getInternalView(context, viewId);
+        }
+      };
+    
+    _internalViewStrategy = new InternalViewHandlingStrategy(finder);
+    
+  }
+
+  @Override
+  public ViewDeclarationLanguage getViewDeclarationLanguage(String viewId)
+  {
+    if (_getInternalView(FacesContext.getCurrentInstance(), viewId) != null)
+      return _internalViewStrategy;
+    
+    // TRINIDAD-1703 - use physical URI (retrieved from the PageResolver) before calling the delegate's 
+    // implementation
+    viewId = _getPath(viewId);
+    
+    return getWrapped().getViewDeclarationLanguage(viewId);
+  }
+  
+  @Override
+  public ViewDeclarationLanguageFactory getWrapped()
+  {
+    return _wrapped;
+  }
+  
+  private InternalView _getInternalView(
+    FacesContext context, 
+    String       viewId)
+  {
+    Object cached = _internalViewCache.get(viewId);
+    if (cached != null)
+    {
+      return ((cached == _NOT_FOUND) ? null : (InternalView)cached);
+    }
+    
+    InternalView internal = _internalViews.get(viewId);
+    if (internal == null)
+    {
+      // If we're using suffix-mapping, then any internal viewId will
+      // get affixed with ".jsp" or ".jspx";  try trimming that off
+      // if present
+      ExternalContext external = context.getExternalContext();
+      
+      // Only bother when using suffix-mapping (path info will always
+      // be non-null for prefix-mapping)
+      if (external.getRequestPathInfo() == null)
+      {
+        String suffix = external.getInitParameter("javax.faces.DEFAULT_SUFFIX");
+        if (suffix == null)
+          suffix = ".jspx";
+        
+        if (viewId.endsWith(suffix))
+        {
+          String viewIdWithoutSuffix = viewId.substring(
+             0, viewId.length() - suffix.length());
+          internal = _internalViews.get(viewIdWithoutSuffix);
+        }
+      }
+    }
+    
+    _internalViewCache.put(viewId, (internal == null) ? _NOT_FOUND : internal);
+
+    return internal;
+  }
+  
+  //
+  // Load the META-INF/org.apache.myfaces.trinidad.render.InternalView.properties
+  // files.
+  //
+  private void _loadInternalViews()
+  {
+    _internalViews = new HashMap<String, InternalView>();
+    List<URL> list = new ArrayList<URL>();
+    ClassLoader loader = _getClassLoader();
+    try
+    {
+      Enumeration<URL> en = loader.getResources(
+               "META-INF/org.apache.myfaces.trinidad.render.InternalView.properties");
+      while (en.hasMoreElements())
+      {
+        list.add(en.nextElement());
+      }
+
+      // And, for some temporary backwards compatibility, also load
+      // the incorrect properties without "render"
+      en = loader.getResources(
+               "META-INF/org.apache.myfaces.trinidad.InternalView.properties");
+      while (en.hasMoreElements())
+      {
+        list.add(en.nextElement());
+      }
+
+
+      // Reverse the list so it is in the proper order (most local
+      // entry "wins")
+      Collections.reverse(list);
+    }
+    catch (IOException ioe)
+    {
+      _LOG.severe(ioe);
+    }
+
+    for (URL url : list)
+    {
+      try
+      {
+        Properties properties = new Properties();
+        _LOG.fine("Loading internal views from {0}",  url);
+        InputStream is = url.openStream();
+        try
+        {
+          properties.load(is);
+        }
+        finally
+        {
+          is.close();
+        }
+
+        for (Map.Entry<Object, Object> entry : properties.entrySet())
+        {
+          String name = (String) entry.getKey();
+          String className = (String) entry.getValue();
+          Class<?> clazz = loader.loadClass(className);
+          org.apache.myfaces.trinidad.render.InternalView view = (org.apache.myfaces.trinidad.render.InternalView) clazz.newInstance();
+          _internalViews.put(name, view);
+        }
+      }
+      catch (IllegalAccessException iae)
+      {
+        _LOG.severe("CANNOT_LOAD_URL", url);
+        _LOG.severe(iae);
+      }
+      catch (InstantiationException ie)
+      {
+        _LOG.severe("CANNOT_LOAD_URL", url);
+        _LOG.severe(ie);
+      }
+      catch (ClassNotFoundException cnfe)
+      {
+        _LOG.severe("CANNOT_LOAD_URL", url);
+        _LOG.severe(cnfe);
+      }
+      catch (IOException ioe)
+      {
+        _LOG.severe("CANNOT_LOAD_URL", url);
+        _LOG.severe(ioe);
+      }
+    }
+  }
+
+
+  static private ClassLoader _getClassLoader()
+  {
+    ClassLoader loader = Thread.currentThread().getContextClassLoader();
+    if (loader == null)
+      loader = ViewDeclarationLanguageFactoryImpl.class.getClassLoader();
+    return loader;
+  }
+  
+  /**
+   * Return the physical path of a particular URI
+   */
+  static private String _getPath(String uri)
+  {
+    RequestContext afc = RequestContext.getCurrentInstance();
+    if (afc != null)
+    {
+      return afc.getPageResolver().getPhysicalURI(uri);
+    }
+
+    // No RequestContext?  Just return the URI
+    return uri;
+  }
+  
+  private final ViewDeclarationLanguageFactory _wrapped;
+  private final InternalViewHandlingStrategy _internalViewStrategy;
+  private Map<String, InternalView> _internalViews;
+  
+  private final static Object _NOT_FOUND = new Object();
+  private final Map<String, Object> _internalViewCache = 
+                              new ConcurrentHashMap<String, Object>();
+  
+  private static final TrinidadLogger _LOG = 
+    TrinidadLogger.createTrinidadLogger(ViewDeclarationLanguageFactoryImpl.class);
+  
+  /**
+   * Package-private interface for use by InternalViewHandlingStrategy as a callback
+   * for getting InternalViews
+   */
+  interface InternalViewFinder
+  {
+    public InternalView getInternalView(FacesContext context, String viewId);
+  }
+}

Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImpl.java?rev=919055&r1=919054&r2=919055&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImpl.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImpl.java Thu Mar  4 16:31:22 2010
@@ -18,27 +18,17 @@
  */
 package org.apache.myfaces.trinidadinternal.application;
 
-import java.io.InputStream;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
-import java.util.Properties;
-
-import java.util.Set;
 
 import javax.faces.FacesException;
 import javax.faces.application.ProjectStage;
 import javax.faces.application.ViewHandler;
 import javax.faces.application.ViewHandlerWrapper;
 import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 
 import javax.faces.view.ViewDeclarationLanguage;
@@ -46,7 +36,6 @@
 import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
-import org.apache.myfaces.trinidad.render.InternalView;
 import org.apache.myfaces.trinidad.util.Service;
 import org.apache.myfaces.trinidad.util.URLUtils;
 import org.apache.myfaces.trinidadinternal.context.RequestContextImpl;
@@ -75,7 +64,6 @@
   {
     _delegate = delegate;
     _timestamps = new HashMap<String, Long>();
-    _loadInternalViews();
   }
 
   public ViewHandler getWrapped()
@@ -83,40 +71,13 @@
     return _delegate;
   }
   
-  public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context,
-                                                            String viewId)
-  {
-    // InternalViews will not use ViewDeclarationLanguage processors,
-    // since they do essentially the same job themselves.
-    InternalView internal = _getInternalView(context, viewId);
-    if (internal != null)
-    {
-      return null;
-    }
-    
-    // TRINIDAD-1703 - use physical URI (retrieved from the PageResolver) before calling the delegate's 
-    // implementation
-    viewId = _getPath(viewId);
-    
-    return _delegate.getViewDeclarationLanguage(context, viewId);
-  }
 
   @Override
   public UIViewRoot createView(FacesContext context, String viewId)
   {
     _initIfNeeded(context);
-    
-    _storeInternalViewIds(context);
 
-    InternalView internal = _getInternalView(context, viewId);
-    if (internal != null)
-    {
-      UIViewRoot root = internal.createView(context, viewId);
-      if (root != null)
-        return root;
-      // Otherwise, fall through to default processing
-    }
-    else if (_checkTimestamp(context))
+    if (_checkTimestamp(context, viewId))
     {
       try
       {
@@ -200,17 +161,8 @@
       {
         if (service != null)
           service.encodeBegin(context);
-
-        InternalView internal = _getInternalView(context,
-                                                 viewToRender.getViewId());
-        if (internal != null)
-        {
-          internal.renderView(context, viewToRender);
-        }
-        else
-        {
-          super.renderView(context, viewToRender);
-        }
+        
+        super.renderView(context, viewToRender);
 
         if (service != null)
           service.encodeEnd(context);
@@ -231,8 +183,6 @@
     FacesContext context,
     String       viewId)
   {    
-    _storeInternalViewIds(context);
-    
     //This code processes a "return" event.  Most of this logic was moved to 
     //StateManagerImpl because we ran into a problem with JSF where it didn't 
     //set up the JSF mapping properly if we didn't delegate to the default 
@@ -245,15 +195,9 @@
       return super.restoreView(context, viewId);
     }
     
-    InternalView internal = _getInternalView(context, viewId);
-    if (internal != null)
-    {
-      return internal.restoreView(context, viewId);
-    }
-
     boolean uptodate = true;
 
-    if (_checkTimestamp(context))
+    if (_checkTimestamp(context, viewId))
     {
       try
       {
@@ -310,15 +254,23 @@
   public void writeState(
     FacesContext context) throws IOException
   {
-    String viewId = context.getViewRoot().getViewId();
-    InternalView internal =
-       _getInternalView(context, viewId);
-
-    // As internal views whether they're stateless.  If they are, don't
-    // bother writing anything out.
-    if ((internal != null) && internal.isStateless(context, viewId))
-      return;
+    // After the move of InteralView loading code to the ViewDeclarationFactoryImpl,
+    // this class was not supposed to do anything with the InternalViews.
+    // Unfortunately, writeState() has not been exposed on ViewDeclarationLanguage,
+    // so we have to override this method here. Without an override, JSF save state
+    // marker gets written straight to the response
 
+    String viewId = context.getViewRoot().getViewId();
+    ViewDeclarationLanguage vdl = getViewDeclarationLanguage(context, viewId);
+    if (vdl instanceof InternalViewHandlingStrategy)
+    {
+      InternalViewHandlingStrategy strategy = (InternalViewHandlingStrategy)vdl;
+      if (strategy.__isStateless(context, viewId))
+      {
+        return;
+      }
+    }
+    
     ExtendedRenderKitService service = _getExtendedRenderKitService(context);
     if ((service != null) &&
         service.isStateless(context))
@@ -327,27 +279,6 @@
     super.writeState(context);
   }
   
-  public static boolean isInternalViewId(FacesContext context, String id)
-  {
-    if (id == null)
-      return false;
-    
-    Set<String> ids = 
-        (Set<String>)context.getExternalContext().getRequestMap().get(_INTERNAL_VIEW_ID_SET);
-    
-    if (ids == null)
-      return false;
-    
-    return ids.contains(id);
-  }
-  
-  private void _storeInternalViewIds(FacesContext context)
-  {
-    // Save internal view Ids on the request map, so that we can retrieve them later
-    // (see RequestContext.isInternalViewRequest())
-    Set<String> ids = new HashSet<String>(_internalViews.keySet());
-    context.getExternalContext().getRequestMap().put(_INTERNAL_VIEW_ID_SET, ids);
-  }
 
   synchronized private void _initIfNeeded(FacesContext context)
   {
@@ -394,7 +325,7 @@
                               ExtendedRenderKitService.class);
   }
 
-  private boolean _checkTimestamp(FacesContext context)
+  private boolean _checkTimestamp(FacesContext context, String viewId)
   {
     if (_checkTimestamp == null)
     {
@@ -439,7 +370,18 @@
       }
     }
 
-    return _checkTimestamp.booleanValue();
+    // Even if _checkTimestamp is TRUE, we do not want to perform the check for the InternalViews
+    boolean check = _checkTimestamp.booleanValue();
+    
+    if (check)
+    {
+      if (getViewDeclarationLanguage(context, viewId) 
+                              instanceof InternalViewHandlingStrategy)
+      {
+        return false;
+      }
+    }
+    return check;
   }
 
 
@@ -468,141 +410,13 @@
   }
 
 
-  private InternalView _getInternalView(
-    FacesContext context, 
-    String       viewId)
-  {
-    InternalView internal = _internalViews.get(viewId);
-    if (internal == null)
-    {
-      // If we're using suffix-mapping, then any internal viewId will
-      // get affixed with ".jsp" or ".jspx";  try trimming that off
-      // if present
-      ExternalContext external = context.getExternalContext();
-      
-      // Only bother when using suffix-mapping (path info will always
-      // be non-null for prefix-mapping)
-      if (external.getRequestPathInfo() == null)
-      {
-        String suffix = external.getInitParameter("javax.faces.DEFAULT_SUFFIX");
-        if (suffix == null)
-          suffix = ".jspx";
-        
-        if (viewId.endsWith(suffix))
-        {
-          String viewIdWithoutSuffix = viewId.substring(
-             0, viewId.length() - suffix.length());
-          internal = _internalViews.get(viewIdWithoutSuffix);
-        }
-      }
-    }
-
-    return internal;
-  }
-
-  //
-  // Load the META-INF/org.apache.myfaces.trinidad.render.InternalView.properties
-  // files.
-  //
-  private void _loadInternalViews()
-  {
-    _internalViews = new HashMap<String, InternalView>();
-    List<URL> list = new ArrayList<URL>();
-    ClassLoader loader = _getClassLoader();
-    try
-    {
-      Enumeration<URL> en = loader.getResources(
-               "META-INF/org.apache.myfaces.trinidad.render.InternalView.properties");
-      while (en.hasMoreElements())
-      {
-        list.add(en.nextElement());
-      }
-
-      // And, for some temporary backwards compatibility, also load
-      // the incorrect properties without "render"
-      en = loader.getResources(
-               "META-INF/org.apache.myfaces.trinidad.InternalView.properties");
-      while (en.hasMoreElements())
-      {
-        list.add(en.nextElement());
-      }
-
-
-      // Reverse the list so it is in the proper order (most local
-      // entry "wins")
-      Collections.reverse(list);
-    }
-    catch (IOException ioe)
-    {
-      _LOG.severe(ioe);
-    }
-
-    for (URL url : list)
-    {
-      try
-      {
-        Properties properties = new Properties();
-        _LOG.fine("Loading internal views from {0}",  url);
-        InputStream is = url.openStream();
-        try
-        {
-          properties.load(is);
-        }
-        finally
-        {
-          is.close();
-        }
-
-        for (Map.Entry<Object, Object> entry : properties.entrySet())
-        {
-          String name = (String) entry.getKey();
-          String className = (String) entry.getValue();
-          Class<?> clazz = loader.loadClass(className);
-          InternalView view = (InternalView) clazz.newInstance();
-          _internalViews.put(name, view);
-        }
-      }
-      catch (IllegalAccessException iae)
-      {
-        _LOG.severe("CANNOT_LOAD_URL", url);
-        _LOG.severe(iae);
-      }
-      catch (InstantiationException ie)
-      {
-        _LOG.severe("CANNOT_LOAD_URL", url);
-        _LOG.severe(ie);
-      }
-      catch (ClassNotFoundException cnfe)
-      {
-        _LOG.severe("CANNOT_LOAD_URL", url);
-        _LOG.severe(cnfe);
-      }
-      catch (IOException ioe)
-      {
-        _LOG.severe("CANNOT_LOAD_URL", url);
-        _LOG.severe(ioe);
-      }
-    }
-  }
-
-
-  static private ClassLoader _getClassLoader()
-  {
-    ClassLoader loader = Thread.currentThread().getContextClassLoader();
-    if (loader == null)
-      loader = ViewHandlerImpl.class.getClassLoader();
-    return loader;
-  }
-
   private Boolean           _checkTimestamp;
   // Mostly final, but see _initIfNeeded()
   private ViewHandler       _delegate;
   private final Map<String, Long> _timestamps;
   private boolean           _inited;
-  private Map<String, InternalView> _internalViews;
 
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(ViewHandlerImpl.class);
   private static final Long   _NOT_FOUND = Long.valueOf(0);
   private static final String _RENDER_VIEW_MARKER = "__trRenderViewEntry";
-  private static final String _INTERNAL_VIEW_ID_SET = "org.apache.myfaces.trinidadinternal.application._INTERNAL_IDS";
 }

Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=919055&r1=919054&r2=919055&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Thu Mar  4 16:31:22 2010
@@ -45,6 +45,8 @@
 import org.apache.myfaces.trinidad.change.SessionChangeManager;
 import org.apache.myfaces.trinidad.component.UIXComponent;
 import javax.faces.component.visit.VisitContext;
+import javax.faces.view.ViewDeclarationLanguage;
+
 import org.apache.myfaces.trinidad.config.RegionManager;
 import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.context.Agent;
@@ -64,6 +66,7 @@
 import org.apache.myfaces.trinidadinternal.agent.AgentFactory;
 import org.apache.myfaces.trinidadinternal.agent.AgentFactoryImpl;
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgentImpl;
+import org.apache.myfaces.trinidadinternal.application.InternalViewHandlingStrategy;
 import org.apache.myfaces.trinidadinternal.application.StateManagerImpl;
 import org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl;
 import org.apache.myfaces.trinidadinternal.el.FormatterMap;
@@ -723,7 +726,10 @@
     if (root == null)
       return false;
 
-    return ViewHandlerImpl.isInternalViewId(context, root.getViewId());
+    ViewDeclarationLanguage strategy = context.getApplication().
+                          getViewHandler().getViewDeclarationLanguage(context, root.getViewId()); 
+    
+    return (strategy instanceof InternalViewHandlingStrategy);
   }
 
   @Override

Copied: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewDeclarationLanguageFactory.java (from r917691, myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewHandler.java)
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewDeclarationLanguageFactory.java?p2=myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewDeclarationLanguageFactory.java&p1=myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewHandler.java&r1=917691&r2=919055&rev=919055&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewHandler.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/NullViewDeclarationLanguageFactory.java Thu Mar  4 16:31:22 2010
@@ -18,59 +18,13 @@
  */
 package org.apache.myfaces.trinidadinternal.application;
 
-import java.io.IOException;
-import java.util.Locale;
-import javax.faces.FacesException;
-import javax.faces.application.ViewHandler;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
+import javax.faces.view.ViewDeclarationLanguage;
+import javax.faces.view.ViewDeclarationLanguageFactory;
 
-public class NullViewHandler extends ViewHandler
+public class NullViewDeclarationLanguageFactory extends ViewDeclarationLanguageFactory
 {
-  @Override
-  public Locale calculateLocale(FacesContext context)
+  public ViewDeclarationLanguage getViewDeclarationLanguage(String viewId)
   {
     return null;
   }
-
-  @Override
-  public String calculateRenderKitId(FacesContext context)
-  {
-    return null;
-  }
-  
-  @Override
-  public UIViewRoot createView(FacesContext context, String viewId)
-  {
-    return null;
-  }
-
-  @Override
-  public String getActionURL(FacesContext context, String viewId)
-  {
-    return viewId;
-  }
-
-  @Override
-  public String getResourceURL(FacesContext context, String path)
-  {
-    return path;
-  }
-
-  @Override
-  public void renderView(FacesContext context, UIViewRoot viewToRender)
-        throws IOException, FacesException
-  {
-  }
-
-  @Override
-  public UIViewRoot restoreView(FacesContext context, String viewId)
-  {
-    return null;
-  }
-
-  @Override
-  public void writeState(FacesContext context) throws IOException
-  {
-  }
 }

Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/TestInternalView.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/TestInternalView.java?rev=919055&r1=919054&r2=919055&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/TestInternalView.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/TestInternalView.java Thu Mar  4 16:31:22 2010
@@ -36,8 +36,8 @@
   @Override
   public UIViewRoot createView(FacesContext context, String viewId)
   {
-    ViewHandlerImplTest.__internalViewCalled = "create";
-    return null;
+    ViewDeclarationLanguageFactoryImplTest.__internalViewCalled = "create";
+    return new UIViewRoot();
   }
 
   /**
@@ -46,7 +46,7 @@
   @Override
   public UIViewRoot restoreView(FacesContext context, String viewId)
   {
-    ViewHandlerImplTest.__internalViewCalled = "restore";
+    ViewDeclarationLanguageFactoryImplTest.__internalViewCalled = "restore";
     return null;
   }
   
@@ -58,6 +58,6 @@
     FacesContext context, 
     UIViewRoot   viewToRender) throws IOException, FacesException
   {
-    ViewHandlerImplTest.__internalViewCalled = "render";
+    ViewDeclarationLanguageFactoryImplTest.__internalViewCalled = "render";
   }
 }

Copied: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImplTest.java (from r917691, myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImplTest.java)
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImplTest.java?p2=myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImplTest.java&p1=myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImplTest.java&r1=917691&r2=919055&rev=919055&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewHandlerImplTest.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImplTest.java Thu Mar  4 16:31:22 2010
@@ -27,9 +27,9 @@
 import org.apache.myfaces.trinidadbuild.test.FacesTestCase;
 import org.apache.myfaces.trinidadinternal.renderkit.RenderKitBootstrap;
 
-public class ViewHandlerImplTest extends FacesTestCase
+public class ViewDeclarationLanguageFactoryImplTest extends FacesTestCase
 {
-  public ViewHandlerImplTest(
+  public ViewDeclarationLanguageFactoryImplTest(
     String testName)
   {
     super(testName);
@@ -49,26 +49,28 @@
   
   public static Test suite()
   {
-    return new TestSuite(ViewHandlerImplTest.class);
+    return new TestSuite(ViewDeclarationLanguageFactoryImplTest.class);
   }
 
   public void testInternalView() throws Throwable
   {
-    ViewHandlerImpl vh = new ViewHandlerImpl(new NullViewHandler());
+    ViewDeclarationLanguageFactoryImpl vdlf = 
+        new ViewDeclarationLanguageFactoryImpl(new NullViewDeclarationLanguageFactory());
     RenderKitBootstrap.setFactories(null);
     try
     {
       UIViewRoot viewRoot = new UIViewRoot();
-      viewRoot.setViewId("/testURL");
+      String viewId = "/testURL";
+      viewRoot.setViewId(viewId);
       viewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
       facesContext.setViewRoot(viewRoot);
-      vh.renderView(facesContext, viewRoot);
+      vdlf.getViewDeclarationLanguage(viewId).renderView(facesContext, viewRoot);
       assertEquals("render", __internalViewCalled);
 
-      vh.restoreView(facesContext, "/testURL");
+      vdlf.getViewDeclarationLanguage(viewId).restoreView(facesContext, viewId);
       assertEquals("restore", __internalViewCalled);
 
-      vh.createView(facesContext, "/testURL");
+      vdlf.getViewDeclarationLanguage(viewId).createView(facesContext, viewId);
       assertEquals("create", __internalViewCalled);
     }
     finally