You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/09/19 21:25:23 UTC

svn commit: r447935 - in /myfaces: shared/trunk/core/src/main/java/org/apache/myfaces/shared/config/ tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/ tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ tom...

Author: mmarinschek
Date: Tue Sep 19 12:25:22 2006
New Revision: 447935

URL: http://svn.apache.org/viewvc?view=rev&rev=447935
Log:
Fix for: http://issues.apache.org/jira/browse/TOMAHAWK-384: AddResource, ExtensionsFilter and "sex". Thanks to Sascha Groß.

Modified:
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResourceFactory.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/web.xml

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java?view=diff&rev=447935&r1=447934&r2=447935
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java Tue Sep 19 12:25:22 2006
@@ -45,6 +45,9 @@
 
     private static final String APPLICATION_MAP_PARAM_NAME = MyfacesConfig.class.getName();
 
+    public static final String  INIT_PARAM_RESOURCE_VIRTUAL_PATH = "org.apache.myfaces.RESOURCE_VIRTUAL_PATH";
+    public static final String  INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT = "/faces/myFacesExtensionResource";
+
     private static final String  INIT_PARAM_PRETTY_HTML = "org.apache.myfaces.PRETTY_HTML";
     private static final boolean INIT_PARAM_PRETTY_HTML_DEFAULT = true;
 
@@ -68,6 +71,7 @@
     private boolean _allowJavascript;
     private boolean _autoScroll;
     private String _addResourceClass;
+    private String _resourceVirtualPath;
     private boolean _checkExtensionsFilter;
 
     private static final boolean TOMAHAWK_AVAILABLE;
@@ -109,7 +113,10 @@
 	                INIT_PARAM_AUTO_SCROLL_DEFAULT));
 	        myfacesConfig.setAddResourceClass(getStringInitParameter(extCtx, INIT_PARAM_ADD_RESOURCE_CLASS,
 	                                                                 INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT));
-	        myfacesConfig.setCheckExtensionsFilter(getBooleanInitParameter(extCtx, INIT_CHECK_EXTENSIONS_FILTER,
+            myfacesConfig.setResourceVirtualPath(getStringInitParameter(extCtx, INIT_PARAM_RESOURCE_VIRTUAL_PATH,
+                    INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT));
+
+            myfacesConfig.setCheckExtensionsFilter(getBooleanInitParameter(extCtx, INIT_CHECK_EXTENSIONS_FILTER,
 	        		INIT_CHECK_EXTENSIONS_FILTER_DEFAULT));
         }
         else
@@ -163,6 +170,16 @@
             return strValue;
         }
     }
+
+     private void setResourceVirtualPath( String resourceVirtualPath )
+     {
+         this._resourceVirtualPath = resourceVirtualPath;
+     }
+
+     public String getResourceVirtualPath()
+     {
+         return this._resourceVirtualPath;
+     }
 
     public boolean isPrettyHtml()
     {

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java?view=diff&rev=447935&r1=447934&r2=447935
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java Tue Sep 19 12:25:22 2006
@@ -45,6 +45,7 @@
 import org.apache.myfaces.renderkit.html.util.ResourceLoader;
 import org.apache.myfaces.renderkit.html.util.ResourcePosition;
 import org.apache.myfaces.shared_tomahawk.util.ClassUtils;
+import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
 
 /**
  * This is a utility class to render link to resources used by custom components.
@@ -74,25 +75,25 @@
  */
 public class StreamingAddResource implements AddResource
 {
-	/**
-	 * central place where all request store their "to be added" stylesheets
-	 */
-	private final static Map headerInfos = new HashMap();
-
-	/**
-	 * request counter
-	 */
-	private static long REQUEST_ID_COUNTER = 0;
-
-	/**
-	 * own request
-	 */
-	private Long requestId;
-
-	/**
-	 * own header infos - e.g holds the "to be added" stylesheets and a destroy time
-	 */
-	private HeaderInfoEntry headerInfoEntry;
+    /**
+     * central place where all request store their "to be added" stylesheets
+     */
+    private final static Map headerInfos = new HashMap();
+
+    /**
+     * request counter
+     */
+    private static long REQUEST_ID_COUNTER = 0;
+
+    /**
+     * own request
+     */
+    private Long requestId;
+
+    /**
+     * own header infos - e.g holds the "to be added" stylesheets and a destroy time
+     */
+    private HeaderInfoEntry headerInfoEntry;
 
     /**
      * helper to determines if the resource has already been added
@@ -108,104 +109,105 @@
     private static final String RESOURCES_CACHE_KEY = AddResource.class.getName() + ".CACHE_KEY";
 
     protected String _contextPath;
+    private String resourceVirtualPath;
+
+    public static class HeaderInfoEntry
+    {
+        private final long destroyTime = System.currentTimeMillis() + (1000 * 60); // one minute;
+        private final List addedInfos = new ArrayList(10);
+        private volatile boolean requestDone = false;
+
+        protected HeaderInfoEntry()
+        {
+        }
+
+        protected boolean isDestroyable(long now)
+        {
+            return destroyTime < now;
+        }
+
+        protected void addInfo(StreamablePositionedInfo positionedInfo)
+        {
+            synchronized (addedInfos)
+            {
+                addedInfos.add(positionedInfo);
+                addedInfos.notifyAll();
+            }
+        }
+
+        protected StreamablePositionedInfo fetchInfo() throws InterruptedException
+        {
+            synchronized (addedInfos)
+            {
+                while (addedInfos.size() < 1 && !requestDone)
+                {
+                    addedInfos.wait(100);
+                }
+                if (addedInfos.size() < 1)
+                {
+                    // request done
+                    return null;
+                }
 
-	public static class HeaderInfoEntry
-	{
-		private final long destroyTime = System.currentTimeMillis() + (1000 * 60); // one minute;
-		private final List addedInfos = new ArrayList(10);
-		private volatile boolean requestDone = false;
-
-		protected HeaderInfoEntry()
-		{
-		}
-
-		protected boolean isDestroyable(long now)
-		{
-			return destroyTime < now;
-		}
-
-		protected void addInfo(StreamablePositionedInfo positionedInfo)
-		{
-			synchronized (addedInfos)
-			{
-				addedInfos.add(positionedInfo);
-				addedInfos.notifyAll();
-			}
-		}
-
-		protected StreamablePositionedInfo fetchInfo() throws InterruptedException
-		{
-			synchronized (addedInfos)
-			{
-				while (addedInfos.size() < 1 && !requestDone)
-				{
-					addedInfos.wait(100);
-				}
-				if (addedInfos.size() < 1)
-				{
-					// request done
-					return null;
-				}
-
-				return (StreamablePositionedInfo) addedInfos.remove(0);
-			}
-		}
-
-		protected void setRequestDone()
-		{
-			requestDone = true;
-		}
-	}
+                return (StreamablePositionedInfo) addedInfos.remove(0);
+            }
+        }
+
+        protected void setRequestDone()
+        {
+            requestDone = true;
+        }
+    }
 
     private static class CleanupThread implements Runnable
     {
-    	// how many entries should be removed per run
-    	private final static int CHECKS_PER_RUN = 10;
+        // how many entries should be removed per run
+        private final static int CHECKS_PER_RUN = 10;
+
+        // but never reach this maximum
+        private final static int CACHE_LIMIT = 1000;
+
+        public void run()
+        {
+            while (!Thread.interrupted())
+            {
+                checkMap();
+
+                try
+                {
+                    Thread.sleep(1000 * 30); // check every 30 sek
+                }
+                catch (InterruptedException e)
+                {
+                    // ignore
+                }
+            }
+        }
 
-    	// but never reach this maximum
-    	private final static int CACHE_LIMIT = 1000;
+        private void checkMap()
+        {
+            synchronized (headerInfos)
+            {
+                long now = System.currentTimeMillis();
 
-		public void run()
-		{
-			while (!Thread.interrupted())
-			{
-				checkMap();
-
-				try
-				{
-					Thread.sleep(1000 * 30); // check every 30 sek
-				}
-				catch (InterruptedException e)
-				{
-					// ignore
-				}
-			}
-		}
-
-		private void checkMap()
-		{
-			synchronized (headerInfos)
-			{
-				long now = System.currentTimeMillis();
-
-				int checkNo = 0;
-				Iterator iterEntries = headerInfos.entrySet().iterator();
-				while (iterEntries.hasNext() && !Thread.currentThread().isInterrupted())
-				{
-					checkNo++;
-					if (headerInfos.size() < CACHE_LIMIT && checkNo > CHECKS_PER_RUN)
-					{
-						return;
-					}
-					Map.Entry entry = (Map.Entry) iterEntries.next();
-					HeaderInfoEntry headerInfoEntry = (HeaderInfoEntry) entry.getValue();
-					if (headerInfoEntry.isDestroyable(now))
-					{
-						iterEntries.remove();
-					}
-				}
-			}
-		}
+                int checkNo = 0;
+                Iterator iterEntries = headerInfos.entrySet().iterator();
+                while (iterEntries.hasNext() && !Thread.currentThread().isInterrupted())
+                {
+                    checkNo++;
+                    if (headerInfos.size() < CACHE_LIMIT && checkNo > CHECKS_PER_RUN)
+                    {
+                        return;
+                    }
+                    Map.Entry entry = (Map.Entry) iterEntries.next();
+                    HeaderInfoEntry headerInfoEntry = (HeaderInfoEntry) entry.getValue();
+                    if (headerInfoEntry.isDestroyable(now))
+                    {
+                        iterEntries.remove();
+                    }
+                }
+            }
+        }
     }
 
     static
@@ -214,7 +216,7 @@
         cleanupThread.setDaemon(true);
         cleanupThread.start();
     }
-    
+
     public StreamingAddResource()
     {
     }
@@ -222,18 +224,18 @@
     public static HeaderInfoEntry getHeaderInfo(Long requestId)
     {
         synchronized (headerInfos)
-		{
-        	return (HeaderInfoEntry) headerInfos.get(requestId);
-		}
+        {
+            return (HeaderInfoEntry) headerInfos.get(requestId);
+        }
     }
 
-	public static void removeHeaderInfo(Long requestId)
-	{
+    public static void removeHeaderInfo(Long requestId)
+    {
         synchronized (headerInfos)
-		{
-        	headerInfos.remove(requestId);
-		}
-	}
+        {
+            headerInfos.remove(requestId);
+        }
+    }
 
     // Methods to add resources
 
@@ -274,8 +276,8 @@
         writer.endElement(HTML.SCRIPT_ELEM);
     }
 
-	public void addJavaScriptHerePlain(FacesContext context, String uri) throws IOException
-	{
+    public void addJavaScriptHerePlain(FacesContext context, String uri) throws IOException
+    {
         ResponseWriter writer = context.getResponseWriter();
 
         writer.startElement(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_ELEM, null);
@@ -283,7 +285,7 @@
         String src = getResourceUri(context, uri);
         writer.writeURIAttribute(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SRC_ATTR, src, null);
         writer.endElement(HTML.SCRIPT_ELEM);
-	}
+    }
 
     /**
      * Insert a [script src="url"] entry at the current location in the response.
@@ -370,11 +372,11 @@
      * after the page is complete.
      */
     public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position,
-            ResourceHandler resourceHandler)
+                                        ResourceHandler resourceHandler)
     {
         addJavaScriptAtPosition(context, position, resourceHandler, false);
     }
-    
+
     /**
      * Insert a [script src="url"] entry into the document header at the
      * specified document position. If the script has already been
@@ -388,18 +390,18 @@
      * "example/Widget/resource/script.js" in the classpath.
      */
     public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position,
-            Class myfacesCustomComponent, String resourceName)
+                                        Class myfacesCustomComponent, String resourceName)
     {
         addJavaScriptAtPosition(context, position, new MyFacesResourceHandler(
                 myfacesCustomComponent, resourceName));
     }
 
-	public void addJavaScriptAtPositionPlain(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName)
-	{
+    public void addJavaScriptAtPositionPlain(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName)
+    {
         addJavaScriptAtPosition(context, position,
-        		new MyFacesResourceHandler(myfacesCustomComponent, resourceName),
-        		false, false);
-	}
+                new MyFacesResourceHandler(myfacesCustomComponent, resourceName),
+                false, false);
+    }
 
     /**
      * Insert a [script src="url"] entry into the document header at the
@@ -412,7 +414,7 @@
      * load and be run.
      */
     public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position,
-            Class myfacesCustomComponent, String resourceName, boolean defer)
+                                        Class myfacesCustomComponent, String resourceName, boolean defer)
     {
         addJavaScriptAtPosition(context, position, new MyFacesResourceHandler(
                 myfacesCustomComponent, resourceName), defer);
@@ -436,77 +438,77 @@
      * If the script has already been referenced, it's added only once.
      */
     public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, String uri,
-            boolean defer)
+                                        boolean defer)
     {
-    	WritablePositionedInfo info = (WritablePositionedInfo) getScriptInstance(context, uri, defer);
-    	if (checkAlreadyAdded(info))
-    	{
-    		return;
-    	}
-    	HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
-    	try
-		{
-			info.writePositionedInfo(response, context.getResponseWriter());
-		}
-		catch (IOException e)
-		{
-			throw new RuntimeException(e);
-		}
+        WritablePositionedInfo info = (WritablePositionedInfo) getScriptInstance(context, uri, defer);
+        if (checkAlreadyAdded(info))
+        {
+            return;
+        }
+        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
+        try
+        {
+            info.writePositionedInfo(response, context.getResponseWriter());
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException(e);
+        }
     }
 
     public void addJavaScriptToBodyTag(FacesContext context, String javascriptEventName,
-            String addedJavaScript)
+                                       String addedJavaScript)
     {
-    	throw new UnsupportedOperationException();
+        throw new UnsupportedOperationException();
     }
 
     /**
      * Adds the given Javascript resource at the specified document position.
      * If the script has already been referenced, it's added only once.
      */
-	public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, ResourceHandler resourceHandler, boolean defer)
-	{
-		addJavaScriptAtPosition(context, position, resourceHandler, defer, false);
-	}
+    public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, ResourceHandler resourceHandler, boolean defer)
+    {
+        addJavaScriptAtPosition(context, position, resourceHandler, defer, false);
+    }
 
     private void addJavaScriptAtPosition(FacesContext context, ResourcePosition position,
-            ResourceHandler resourceHandler, boolean defer, boolean encodeURL)
+                                         ResourceHandler resourceHandler, boolean defer, boolean encodeURL)
     {
         validateResourceHandler(resourceHandler);
-    	WritablePositionedInfo info = (WritablePositionedInfo) getScriptInstance(context, resourceHandler, defer, encodeURL);
-    	if (checkAlreadyAdded(info))
-    	{
-    		return;
-    	}
-    	HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
-    	try
-		{
-			info.writePositionedInfo(response, context.getResponseWriter());
-		}
-		catch (IOException e)
-		{
-			throw new RuntimeException(e);
-		}
+        WritablePositionedInfo info = (WritablePositionedInfo) getScriptInstance(context, resourceHandler, defer, encodeURL);
+        if (checkAlreadyAdded(info))
+        {
+            return;
+        }
+        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
+        try
+        {
+            info.writePositionedInfo(response, context.getResponseWriter());
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException(e);
+        }
     }
 
     private boolean checkAlreadyAdded(PositionedInfo info)
-	{
-    	Long key = new Long(info.hashCode());
-    	if (alreadySeenResources.contains(key))
-    	{
-    		return true;
-    	}
-
-    	alreadySeenResources.add(key);
-		return false;
-	}
+    {
+        Long key = new Long(info.hashCode());
+        if (alreadySeenResources.contains(key))
+        {
+            return true;
+        }
 
-	/**
+        alreadySeenResources.add(key);
+        return false;
+    }
+
+    /**
      * Adds the given Style Sheet at the specified document position.
      * If the style sheet has already been referenced, it's added only once.
      */
     public void addStyleSheet(FacesContext context, ResourcePosition position,
-            Class myfacesCustomComponent, String resourceName)
+                              Class myfacesCustomComponent, String resourceName)
     {
         addStyleSheet(context, position, new MyFacesResourceHandler(myfacesCustomComponent,
                 resourceName));
@@ -518,44 +520,44 @@
      */
     public void addStyleSheet(FacesContext context, ResourcePosition position, String uri)
     {
-		uri = getAbsoluteUri(context, uri);
+        uri = getAbsoluteUri(context, uri);
 
         addStyleSheet(getStyleInstance(context, uri));
     }
 
     protected String getAbsoluteUri(FacesContext context, String uri)
-	{
-    	if (uri.startsWith("/"))
-    	{
-    		return uri;
-    	}
-
-    	StringBuffer sb = new StringBuffer(80);
-    	if (context.getExternalContext().getRequestPathInfo() != null)
-    	{
-    		sb.append(context.getExternalContext().getRequestPathInfo());
-    	}
-    	sb.append("/");
-    	sb.append(uri);
-
-    	return sb.toString();
-	}
-
-	private void addStyleSheet(StreamablePositionedInfo styleInstance)
-	{
-    	if (checkAlreadyAdded(styleInstance))
-    	{
-    		return;
-    	}
-    	getHeaderInfoEntry().addInfo(styleInstance);
-	}
+    {
+        if (uri.startsWith("/"))
+        {
+            return uri;
+        }
+
+        StringBuffer sb = new StringBuffer(80);
+        if (context.getExternalContext().getRequestPathInfo() != null)
+        {
+            sb.append(context.getExternalContext().getRequestPathInfo());
+        }
+        sb.append("/");
+        sb.append(uri);
+
+        return sb.toString();
+    }
+
+    private void addStyleSheet(StreamablePositionedInfo styleInstance)
+    {
+        if (checkAlreadyAdded(styleInstance))
+        {
+            return;
+        }
+        getHeaderInfoEntry().addInfo(styleInstance);
+    }
 
-	/**
+    /**
      * Adds the given Style Sheet at the specified document position.
      * If the style sheet has already been referenced, it's added only once.
      */
     public void addStyleSheet(FacesContext context, ResourcePosition position,
-            ResourceHandler resourceHandler)
+                              ResourceHandler resourceHandler)
     {
         validateResourceHandler(resourceHandler);
         addStyleSheet(getStyleInstance(context, resourceHandler));
@@ -573,26 +575,26 @@
      * Adds the given Inline Script at the specified document position.
      */
     public void addInlineScriptAtPosition(FacesContext context, ResourcePosition position,
-            String inlineScript)
+                                          String inlineScript)
     {
-    	WritablePositionedInfo info = (WritablePositionedInfo) getInlineScriptInstance(inlineScript);
-    	if (checkAlreadyAdded(info))
-    	{
-    		return;
-    	}
-    	HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
-    	try
-		{
-			info.writePositionedInfo(response, context.getResponseWriter());
-		}
-		catch (IOException e)
-		{
-			throw new RuntimeException(e);
-		}
+        WritablePositionedInfo info = (WritablePositionedInfo) getInlineScriptInstance(inlineScript);
+        if (checkAlreadyAdded(info))
+        {
+            return;
+        }
+        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
+        try
+        {
+            info.writePositionedInfo(response, context.getResponseWriter());
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException(e);
+        }
     }
 
     public String getResourceUri(FacesContext context, Class myfacesCustomComponent,
-            String resource, boolean withContextPath)
+                                 String resource, boolean withContextPath)
     {
         return getResourceUri(context,
                 new MyFacesResourceHandler(myfacesCustomComponent, resource), withContextPath);
@@ -620,7 +622,7 @@
      * Get the Path used to retrieve an resource.
      */
     public String getResourceUri(FacesContext context, ResourceHandler resourceHandler,
-            boolean withContextPath)
+                                 boolean withContextPath)
     {
         String uri = resourceHandler.getResourceUri(context);
         if (uri == null)
@@ -656,7 +658,7 @@
      * Get the Path used to retrieve an resource.
      */
     protected String getResourceUri(FacesContext context, Class resourceLoader,
-            boolean withContextPath)
+                                    boolean withContextPath)
     {
         StringBuffer sb = new StringBuffer(200);
         sb.append(RESOURCE_VIRTUAL_PATH);
@@ -712,16 +714,16 @@
         return cacheKey.longValue();
     }
 
-    public boolean isResourceUri(HttpServletRequest request)
+    public boolean isResourceUri(ServletContext servletContext, HttpServletRequest request)
     {
         String path;
         if (_contextPath != null)
         {
-            path = _contextPath + RESOURCE_VIRTUAL_PATH;
+            path = _contextPath + getResourceVirtualPath(servletContext);
         }
         else
         {
-            path = RESOURCE_VIRTUAL_PATH;
+            path = getResourceVirtualPath(servletContext);
         }
 
         //fix for TOMAHAWK-660; to be sure this fix is backwards compatible, the
@@ -750,7 +752,7 @@
     }
 
     public void serveResource(ServletContext context, HttpServletRequest request,
-            HttpServletResponse response) throws IOException
+                              HttpServletResponse response) throws IOException
     {
         String pathInfo = request.getPathInfo();
         String uri = request.getContextPath() + request.getServletPath()
@@ -801,26 +803,26 @@
 
     public boolean hasHeaderBeginInfos(HttpServletRequest request)
     {
-    	throw new UnsupportedOperationException();
+        throw new UnsupportedOperationException();
     }
 
     /**
      * Parses the response to mark the positions where code will be inserted
      */
     public void parseResponse(HttpServletRequest request, String bufferedResponse,
-            HttpServletResponse response)
+                              HttpServletResponse response)
     {
-    	throw new UnsupportedOperationException();
+        throw new UnsupportedOperationException();
     }
 
     /**
      * Writes the javascript code necessary for myfaces in every page, just befode the closing &lt;/body&gt; tag
      */
     public void writeMyFacesJavascriptBeforeBodyEnd(HttpServletRequest request,
-            HttpServletResponse response) throws IOException
+                                                    HttpServletResponse response) throws IOException
     {
-    	throw new UnsupportedOperationException();
-    	/*
+        throw new UnsupportedOperationException();
+        /*
         if (beforeBodyEndPosition >= 0)
         {
             String myFacesJavascript = (String) request.getAttribute("org.apache.myfaces.myFacesJavascript");
@@ -844,18 +846,18 @@
      * The ordering is such that the user header CSS & JS override the MyFaces' ones.
      */
     public void writeWithFullHeader(HttpServletRequest request,
-            HttpServletResponse response) throws IOException
+                                    HttpServletResponse response) throws IOException
     {
-    	throw new UnsupportedOperationException();
+        throw new UnsupportedOperationException();
     }
 
     /**
      * Writes the response
      */
     public void writeResponse(HttpServletRequest request,
-            HttpServletResponse response) throws IOException
+                              HttpServletResponse response) throws IOException
     {
-    	throw new UnsupportedOperationException();
+        throw new UnsupportedOperationException();
     }
 
     private StylePositionedInfo getStyleInstance(FacesContext context, ResourceHandler resourceHandler)
@@ -864,7 +866,7 @@
     }
 
     private PositionedInfo getScriptInstance(FacesContext context, ResourceHandler resourceHandler,
-            boolean defer, boolean encodeUrl)
+                                             boolean defer, boolean encodeUrl)
     {
         return new ScriptPositionedInfo(getResourceUri(context, resourceHandler), defer, encodeUrl);
     }
@@ -904,7 +906,7 @@
         public abstract void writePositionedInfo(HttpServletResponse response, PrintWriter writer)
                 throws IOException;
     }
-    
+
     private abstract class AbstractResourceUri
     {
         protected final String _resourceUri;
@@ -960,14 +962,14 @@
             writer.endElement(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.LINK_ELEM);
         }
 
-		public void writePositionedInfo(HttpServletResponse response, PrintWriter writer) throws IOException
-		{
-			writer.println();
-			writer.write("@import url(\"");
-			writer.write(response.encodeURL(this.getResourceUri()));
-			writer.write("\");");
-			writer.println();
-		}
+        public void writePositionedInfo(HttpServletResponse response, PrintWriter writer) throws IOException
+        {
+            writer.println();
+            writer.write("@import url(\"");
+            writer.write(response.encodeURL(this.getResourceUri()));
+            writer.write("\");");
+            writer.println();
+        }
     }
 
     private class ScriptPositionedInfo extends AbstractResourceUri implements
@@ -980,7 +982,7 @@
         {
             this(resourceUri, defer, true);
         }
-        
+
         public ScriptPositionedInfo(String resourceUri, boolean defer, boolean encodeUrl)
         {
             super(resourceUri);
@@ -991,10 +993,10 @@
         public int hashCode()
         {
             return new HashCodeBuilder()
-            	.append(this.getResourceUri())
-            	.append(_defer)
-            	.append(_encodeUrl)
-            	.toHashCode();
+                .append(this.getResourceUri())
+                .append(_defer)
+                .append(_encodeUrl)
+                .toHashCode();
         }
 
         public boolean equals(Object obj)
@@ -1005,9 +1007,9 @@
                 {
                     ScriptPositionedInfo other = (ScriptPositionedInfo) obj;
                     return new EqualsBuilder()
-                    	.append(_defer, other._defer)
-                    	.append(_encodeUrl, other._encodeUrl)
-                    	.isEquals();
+                        .append(_defer, other._defer)
+                        .append(_encodeUrl, other._encodeUrl)
+                        .isEquals();
                 }
             }
             return false;
@@ -1020,11 +1022,11 @@
             writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
             if (_encodeUrl)
             {
-            	writer.writeAttribute(HTML.SRC_ATTR, response.encodeURL(this.getResourceUri()), null);
+                writer.writeAttribute(HTML.SRC_ATTR, response.encodeURL(this.getResourceUri()), null);
             }
             else
             {
-            	writer.writeAttribute(HTML.SRC_ATTR, this.getResourceUri(), null);
+                writer.writeAttribute(HTML.SRC_ATTR, this.getResourceUri(), null);
             }
 
             if (_defer)
@@ -1107,49 +1109,49 @@
             writer.endElement(HTML.STYLE_ELEM);
         }
 
-		public void writePositionedInfo(HttpServletResponse response, PrintWriter writer) throws IOException
-		{
-			writer.println();
-			writer.write(getInlineValue());
-			writer.println();
-		}
+        public void writePositionedInfo(HttpServletResponse response, PrintWriter writer) throws IOException
+        {
+            writer.println();
+            writer.write(getInlineValue());
+            writer.println();
+        }
+    }
+
+    public boolean requiresBuffer()
+    {
+        return false;
     }
 
-	public boolean requiresBuffer()
-	{
-		return false;
-	}
-	
     protected HeaderInfoEntry getHeaderInfoEntry()
-	{
-    	if (headerInfoEntry == null)
-    	{
-    		throw new IllegalStateException("responseStarted() needs to be called first");
-    	}
-    	
-    	return headerInfoEntry;
-	}
-    
-	public void responseStarted()
-	{
+    {
+        if (headerInfoEntry == null)
+        {
+            throw new IllegalStateException("responseStarted() needs to be called first");
+        }
+
+        return headerInfoEntry;
+    }
+
+    public void responseStarted()
+    {
         synchronized(StreamingAddResource.class)
         {
-        	REQUEST_ID_COUNTER++;
-        	requestId = new Long(REQUEST_ID_COUNTER);
+            REQUEST_ID_COUNTER++;
+            requestId = new Long(REQUEST_ID_COUNTER);
         }
         headerInfoEntry = new HeaderInfoEntry();
         synchronized (headerInfos)
-		{
-        	headerInfos.put(requestId, headerInfoEntry);
-		}
-	}
-	
-	public void responseFinished()
-	{
-		getHeaderInfoEntry().setRequestDone();
-	}
+        {
+            headerInfos.put(requestId, headerInfoEntry);
+        }
+    }
 
-	public boolean hasHeaderBeginInfos()
+    public void responseFinished()
+    {
+        getHeaderInfoEntry().setRequestDone();
+    }
+
+    public boolean hasHeaderBeginInfos()
     {
         return false;
     }
@@ -1166,5 +1168,20 @@
                         true), null);
         writer.writeAttribute(HTML.TYPE_ATTR, HTML.STYLE_TYPE_TEXT_CSS, null);
         writer.endElement(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.LINK_ELEM);
+    }
+
+    private String getResourceVirtualPath(ServletContext servletContext)
+    {
+        if(resourceVirtualPath == null)
+        {
+            resourceVirtualPath = servletContext.getInitParameter(MyfacesConfig.INIT_PARAM_RESOURCE_VIRTUAL_PATH);
+
+            if(resourceVirtualPath == null)
+            {
+                resourceVirtualPath = MyfacesConfig.INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT;
+            }
+        }
+
+        return resourceVirtualPath;
     }
 }

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource.java?view=diff&rev=447935&r1=447934&r2=447935
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource.java Tue Sep 19 12:25:22 2006
@@ -236,7 +236,7 @@
     public String getResourceUri(FacesContext context, String uri, boolean withContextPath);
 
 
-    public boolean isResourceUri(HttpServletRequest request);
+    public boolean isResourceUri(ServletContext servletContext, HttpServletRequest request);
 
     public void serveResource(ServletContext context, HttpServletRequest request,
             HttpServletResponse response) throws IOException;

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResourceFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResourceFactory.java?view=diff&rev=447935&r1=447934&r2=447935
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResourceFactory.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResourceFactory.java Tue Sep 19 12:25:22 2006
@@ -55,12 +55,6 @@
  */
 public class AddResourceFactory
 {
-	private final static Set VALID_EXTFLT_PATH = Collections
-		.unmodifiableSet(new TreeSet(Arrays.asList(new String[]
-		{
-				"/faces/*", "/faces/myFacesExtensionResource/*"
-		})));
-
 	public static class RequestMapWrapper implements Map
 	{
 		private final HttpServletRequest request;
@@ -331,7 +325,7 @@
 	    	for (Iterator iterServletMappings = facesServletMappings.iterator(); iterServletMappings.hasNext();)
 	    	{
 	    		FilterMapping filterMapping = (FilterMapping) iterServletMappings.next();
-	    		if (checkFilterPattern(filterMapping))
+	    		if (checkFilterPattern(extctx, filterMapping))
 	    		{
 	    			foundMapping = true;
 	    			break;
@@ -347,9 +341,11 @@
 		}
 	}
 
-	protected static boolean checkFilterPattern(FilterMapping filterMapping)
+    protected static boolean checkFilterPattern(ExternalContext extCtxt, FilterMapping filterMapping)
 	{
-		if (filterMapping.getUrlPattern() != null && VALID_EXTFLT_PATH.contains(filterMapping.getUrlPattern()))
+		if (filterMapping.getUrlPattern() != null &&
+                ("/faces/*".equals(filterMapping.getUrlPattern()) ||
+                        (MyfacesConfig.getCurrentInstance(extCtxt).getResourceVirtualPath()+"/*").equals(filterMapping.getUrlPattern())))
 		{
 			return true;
 		}

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java?view=diff&rev=447935&r1=447934&r2=447935
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java Tue Sep 19 12:25:22 2006
@@ -22,6 +22,7 @@
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlResponseWriterImpl;
 import org.apache.myfaces.shared_tomahawk.util.ClassUtils;
+import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
 
 import javax.faces.FacesException;
 import javax.faces.context.FacesContext;
@@ -100,6 +101,8 @@
     protected int afterBodyContentInsertPosition = -1;
     protected int beforeBodyEndPosition = -1;
 
+    private String resourceVirtualPath;
+
     protected DefaultAddResource()
     {
     }
@@ -462,7 +465,7 @@
                                     boolean withContextPath)
     {
         StringBuffer sb = new StringBuffer(200);
-        sb.append(RESOURCE_VIRTUAL_PATH);
+        sb.append(MyfacesConfig.getCurrentInstance(context.getExternalContext()).getResourceVirtualPath());
         sb.append(PATH_SEPARATOR);
         sb.append(resourceLoader.getName());
         sb.append(PATH_SEPARATOR);
@@ -515,16 +518,17 @@
         return cacheKey.longValue();
     }
 
-    public boolean isResourceUri(HttpServletRequest request)
+    public boolean isResourceUri(ServletContext servletContext, HttpServletRequest request)
     {
+
         String path;
         if (_contextPath != null)
         {
-            path = _contextPath + RESOURCE_VIRTUAL_PATH;
+            path = _contextPath + getResourceVirtualPath(servletContext);
         }
         else
         {
-            path = RESOURCE_VIRTUAL_PATH;
+            path = getResourceVirtualPath(servletContext);
         }
 
         //fix for TOMAHAWK-660; to be sure this fix is backwards compatible, the
@@ -545,6 +549,21 @@
         return request.getRequestURI().startsWith(path);
     }
 
+    private String getResourceVirtualPath(ServletContext servletContext)
+    {
+        if(resourceVirtualPath == null)
+        {
+            resourceVirtualPath = servletContext.getInitParameter(MyfacesConfig.INIT_PARAM_RESOURCE_VIRTUAL_PATH);
+
+            if(resourceVirtualPath == null)
+            {
+                resourceVirtualPath = MyfacesConfig.INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT;
+            }
+        }
+
+        return resourceVirtualPath;
+    }
+
     private Class getClass(String className) throws ClassNotFoundException
     {
         Class clazz = ClassUtils.classForName(className);
@@ -558,7 +577,7 @@
         String pathInfo = request.getPathInfo();
         String uri = request.getContextPath() + request.getServletPath()
                 + (pathInfo == null ? "" : pathInfo);
-        String classNameStartsAfter = RESOURCE_VIRTUAL_PATH + '/';
+        String classNameStartsAfter = getResourceVirtualPath(context) + '/';
 
         int posStartClassName = uri.indexOf(classNameStartsAfter) + classNameStartsAfter.length();
         int posEndClassName = uri.indexOf(PATH_SEPARATOR, posStartClassName);

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java?view=diff&rev=447935&r1=447934&r2=447935
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java Tue Sep 19 12:25:22 2006
@@ -121,7 +121,7 @@
         try
         {
             addResource=AddResourceFactory.getInstance(httpRequest);
-            if( addResource.isResourceUri( httpRequest ) ){
+            if( addResource.isResourceUri(_servletContext, httpRequest ) ){
                 addResource.serveResource(_servletContext, httpRequest, httpResponse);
                 return;
             }

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/web.xml?view=diff&rev=447935&r1=447934&r2=447935
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/web.xml Tue Sep 19 12:25:22 2006
@@ -108,6 +108,17 @@
     <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
     <param-value>true</param-value>
   </context-param>
+
+  <context-param>
+    <description>
+        Change the url-pattern from the ExtensionsFilter
+        Default is "/faces/myFacesExtensionResource"
+        Note: The filter-mapping for ExtensionsFilter, the url-pattern is
+        this value + "/*", else there comes a exception
+    </description>
+    <param-name>org.apache.myfaces.RESOURCE_VIRTUAL_PATH</param-name>
+    <param-value>/faces/extensionResource</param-value>
+</context-param>
   
   <filter>
     <filter-name>extensionsFilter</filter-name>