You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/06/15 18:58:32 UTC
svn commit: r954965 - in /myfaces/tomahawk/trunk/core/src/main:
conf/META-INF/ java/org/apache/myfaces/component/html/util/
java/org/apache/myfaces/renderkit/html/util/
java/org/apache/myfaces/webapp/filter/
Author: lu4242
Date: Tue Jun 15 16:58:31 2010
New Revision: 954965
URL: http://svn.apache.org/viewvc?rev=954965&view=rev
Log:
TOMAHAWK-1443 StreamingAddResource introduces memory leak
Added:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingDestroyerListener.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingThreadManager.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource2.java
Modified:
myfaces/tomahawk/trunk/core/src/main/conf/META-INF/tomahawk-base.tld
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/component/html/util/StreamingResourceLoader.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java
Modified: myfaces/tomahawk/trunk/core/src/main/conf/META-INF/tomahawk-base.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/conf/META-INF/tomahawk-base.tld?rev=954965&r1=954964&r2=954965&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/conf/META-INF/tomahawk-base.tld (original)
+++ myfaces/tomahawk/trunk/core/src/main/conf/META-INF/tomahawk-base.tld Tue Jun 15 16:58:31 2010
@@ -19,5 +19,9 @@
-->
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib xmlns="http://java.sun.com/JSP/TagLibraryDescriptor">
+
+ <listener>
+ <listener-class>org.apache.myfaces.component.html.util.StreamingDestroyerListener</listener-class>
+ </listener>
</taglib>
\ No newline at end of file
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?rev=954965&r1=954964&r2=954965&view=diff
==============================================================================
--- 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 Jun 15 16:58:31 2010
@@ -22,16 +22,11 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import javax.faces.FacesException;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.servlet.ServletContext;
@@ -42,7 +37,9 @@ import org.apache.commons.lang.builder.E
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.html.util.StreamingThreadManager.HeaderInfoEntry;
import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResource2;
import org.apache.myfaces.renderkit.html.util.MyFacesResourceHandler;
import org.apache.myfaces.renderkit.html.util.ResourceHandler;
import org.apache.myfaces.renderkit.html.util.ResourceLoader;
@@ -50,6 +47,8 @@ import org.apache.myfaces.renderkit.html
import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
import org.apache.myfaces.shared_tomahawk.util.ClassUtils;
+import org.apache.myfaces.tomahawk.util.ExternalContextUtils;
+import org.apache.myfaces.webapp.filter.PortletUtils;
/**
* This is a utility class to render link to resources used by custom components.
@@ -123,12 +122,12 @@ import org.apache.myfaces.shared_tomahaw
* @author Mario Ivankovits (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class StreamingAddResource implements AddResource
+public class StreamingAddResource extends AddResource2
{
/**
* central place where all request store their "to be added" stylesheets
*/
- private final static Map headerInfos = new HashMap();
+ //private final static Map headerInfos = new HashMap();
/**
* request counter
@@ -161,7 +160,7 @@ public class StreamingAddResource implem
protected String _contextPath;
private String resourceVirtualPath;
-
+/*
public static class HeaderInfoEntry
{
private final long destroyTime = System.currentTimeMillis() + (1000 * 60); // one minute;
@@ -267,11 +266,12 @@ public class StreamingAddResource implem
cleanupThread.setDaemon(true);
cleanupThread.start();
}
+ */
public StreamingAddResource()
{
}
-
+ /*
public static HeaderInfoEntry getHeaderInfo(Long requestId)
{
synchronized (headerInfos)
@@ -286,7 +286,7 @@ public class StreamingAddResource implem
{
headerInfos.remove(requestId);
}
- }
+ }*/
// Methods to add resources
@@ -573,7 +573,7 @@ public class StreamingAddResource implem
{
uri = getAbsoluteUri(context, uri);
- addStyleSheet(getStyleInstance(context, uri));
+ addStyleSheet(context, getStyleInstance(context, uri));
}
protected String getAbsoluteUri(FacesContext context, String uri)
@@ -594,12 +594,13 @@ public class StreamingAddResource implem
return sb.toString();
}
- private void addStyleSheet(StreamablePositionedInfo styleInstance)
+ private void addStyleSheet(FacesContext context, StreamablePositionedInfo styleInstance)
{
if (checkAlreadyAdded(styleInstance))
{
return;
}
+ StreamingThreadManager manager = (StreamingThreadManager) context.getExternalContext().getApplicationMap().get(StreamingThreadManager.KEY);
getHeaderInfoEntry().addInfo(styleInstance);
}
@@ -611,7 +612,7 @@ public class StreamingAddResource implem
ResourceHandler resourceHandler)
{
validateResourceHandler(resourceHandler);
- addStyleSheet(getStyleInstance(context, resourceHandler));
+ addStyleSheet(context, getStyleInstance(context, resourceHandler));
}
/**
@@ -619,7 +620,7 @@ public class StreamingAddResource implem
*/
public void addInlineStyleAtPosition(FacesContext context, ResourcePosition position, String inlineStyle)
{
- addStyleSheet(getInlineStyleInstance(inlineStyle));
+ addStyleSheet(context, getInlineStyleInstance(inlineStyle));
}
/**
@@ -1187,7 +1188,7 @@ public class StreamingAddResource implem
return false;
}
- protected HeaderInfoEntry getHeaderInfoEntry()
+ protected StreamingThreadManager.HeaderInfoEntry getHeaderInfoEntry()
{
if (headerInfoEntry == null)
{
@@ -1199,6 +1200,7 @@ public class StreamingAddResource implem
public void responseStarted()
{
+ /*
synchronized(StreamingAddResource.class)
{
REQUEST_ID_COUNTER++;
@@ -1208,13 +1210,29 @@ public class StreamingAddResource implem
synchronized (headerInfos)
{
headerInfos.put(requestId, headerInfoEntry);
- }
+ }*/
}
public void responseFinished()
{
getHeaderInfoEntry().setRequestDone();
}
+
+ public void responseStarted(Object context, Object request)
+ {
+ if(ExternalContextUtils.getRequestType(context, request).isPortlet())
+ {
+ StreamingThreadManager manager = (StreamingThreadManager) PortletUtils.getAttribute(context, StreamingThreadManager.KEY);
+ requestId = manager.putNewHeaderInfoEntry();
+ headerInfoEntry = manager.getHeaderInfo(requestId);
+ }
+ else
+ {
+ StreamingThreadManager manager = (StreamingThreadManager) ((ServletContext)context).getAttribute(StreamingThreadManager.KEY);
+ requestId = manager.putNewHeaderInfoEntry();
+ headerInfoEntry = manager.getHeaderInfo(requestId);
+ }
+ }
public boolean hasHeaderBeginInfos()
{
Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingDestroyerListener.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingDestroyerListener.java?rev=954965&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingDestroyerListener.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingDestroyerListener.java Tue Jun 15 16:58:31 2010
@@ -0,0 +1,43 @@
+/*
+ * 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.component.html.util;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+public class StreamingDestroyerListener implements ServletContextListener
+{
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ StreamingThreadManager manager = new StreamingThreadManager();
+ event.getServletContext().setAttribute(StreamingThreadManager.KEY,
+ manager);
+ manager.init();
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ StreamingThreadManager manager = (StreamingThreadManager) event.getServletContext().getAttribute(StreamingThreadManager.KEY);
+ if (manager != null)
+ {
+ manager.destroy();
+ }
+ }
+}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingResourceLoader.java?rev=954965&r1=954964&r2=954965&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingResourceLoader.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingResourceLoader.java Tue Jun 15 16:58:31 2010
@@ -70,7 +70,9 @@ public class StreamingResourceLoader imp
int pos = resourceUri.indexOf("/");
Long requestId = new Long(Long.parseLong(resourceUri.substring(0, pos), 10));
- StreamingAddResource.HeaderInfoEntry headerInfoEntry = StreamingAddResource.getHeaderInfo(requestId);
+ StreamingThreadManager manager = (StreamingThreadManager) context.getAttribute(StreamingThreadManager.KEY);
+
+ StreamingThreadManager.HeaderInfoEntry headerInfoEntry = manager.getHeaderInfo(requestId);
if (headerInfoEntry == null)
{
log.warn("No streamable resources found for request: " + requestId + " resourceUri: " + resourceUri);
@@ -106,7 +108,7 @@ public class StreamingResourceLoader imp
}
finally
{
- StreamingAddResource.removeHeaderInfo(requestId);
+ manager.removeHeaderInfo(requestId);
}
}
Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingThreadManager.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingThreadManager.java?rev=954965&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingThreadManager.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingThreadManager.java Tue Jun 15 16:58:31 2010
@@ -0,0 +1,212 @@
+/*
+ * 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.component.html.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.myfaces.component.html.util.StreamingAddResource.StreamablePositionedInfo;
+
+public class StreamingThreadManager
+{
+ public final static String KEY = "org.apache.myfaces.component.html.util.StreamingThreadManager";
+
+ /**
+ * central place where all request store their "to be added" stylesheets
+ */
+ private final Map headerInfos = new HashMap();
+
+ private Thread cleanupThread = null;
+
+ private CleanupThread cleanupThreadObject = null;
+
+ /**
+ * request counter
+ */
+ private volatile long REQUEST_ID_COUNTER = 0;
+
+ public StreamingThreadManager()
+ {
+ }
+
+ public void init()
+ {
+ if (cleanupThread == null)
+ {
+ cleanupThreadObject = new CleanupThread();
+ cleanupThread = new Thread(cleanupThreadObject, "StreamingAddResource.CleanupThread");
+ cleanupThread.setDaemon(true);
+ cleanupThread.start();
+ }
+ }
+
+ public void destroy()
+ {
+ if (cleanupThread != null)
+ {
+ cleanupThreadObject.done();
+ cleanupThread.interrupt();
+ cleanupThread = null;
+ synchronized (headerInfos)
+ {
+ headerInfos.clear();
+ }
+ }
+ }
+
+ public HeaderInfoEntry getHeaderInfo(Long requestId)
+ {
+ synchronized (headerInfos)
+ {
+ return (HeaderInfoEntry) headerInfos.get(requestId);
+ }
+ }
+
+ public Long putNewHeaderInfoEntry()
+ {
+ Long requestId = null;
+ synchronized(this)
+ {
+ REQUEST_ID_COUNTER++;
+ requestId = new Long(REQUEST_ID_COUNTER);
+ }
+ HeaderInfoEntry headerInfoEntry = new HeaderInfoEntry();
+ synchronized (headerInfos)
+ {
+ headerInfos.put(requestId, headerInfoEntry);
+ }
+ return requestId;
+ }
+
+ public void removeHeaderInfo(Long requestId)
+ {
+ synchronized (headerInfos)
+ {
+ headerInfos.remove(requestId);
+ }
+ }
+
+ 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;
+ }
+ }
+
+ private class CleanupThread implements Runnable
+ {
+ // 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;
+
+ private boolean threadDone = false;
+
+ public void run()
+ {
+ while (!Thread.interrupted() && !threadDone)
+ {
+ checkMap();
+
+ try
+ {
+ Thread.sleep(1000 * 30); // check every 30 sek
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ }
+ }
+
+ public void done() {
+ threadDone = true;
+ }
+
+ 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();
+ }
+ }
+ }
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource2.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource2.java?rev=954965&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource2.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/AddResource2.java Tue Jun 15 16:58:31 2010
@@ -0,0 +1,37 @@
+/*
+ * 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.renderkit.html.util;
+
+/**
+ * This call work as a base class to implement instances of AddResource.
+ * It includes new methods that could be used, to prevent modifications
+ * on AddResource interface and break existing applications.
+ *
+ * @author Leonardo Uribe (latest modification by $Author: skitching $)
+ * @version $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (jue, 03 jul 2008) $
+ */
+public abstract class AddResource2 implements AddResource
+{
+
+ public void responseStarted(Object context, Object request)
+ {
+ //Use the old method by default
+ responseStarted();
+ }
+}
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?rev=954965&r1=954964&r2=954965&view=diff
==============================================================================
--- 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 Jun 15 16:58:31 2010
@@ -34,6 +34,7 @@ import org.apache.commons.fileupload.ser
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResource2;
import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
/**
@@ -325,7 +326,14 @@ public class ExtensionsFilter implements
try
{
- addResource.responseStarted();
+ if (addResource instanceof AddResource2)
+ {
+ ((AddResource2)addResource).responseStarted(_servletContext, extendedRequest);
+ }
+ else
+ {
+ addResource.responseStarted();
+ }
//This case is necessary when is used
//org.apache.myfaces.renderkit.html.util.DefaultAddResource
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java?rev=954965&r1=954964&r2=954965&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletUtils.java Tue Jun 15 16:58:31 2010
@@ -82,4 +82,16 @@ public class PortletUtils
PortletContext portletContext = (PortletContext) context;
return portletContext.getInitParameter(paramName);
}
+
+ public static Object getAttribute(Object context, String key)
+ {
+ PortletContext portletContext = (PortletContext) context;
+ return portletContext.getAttribute(key);
+ }
+
+ public static void setAttribute(Object context, String key, Object value)
+ {
+ PortletContext portletContext = (PortletContext) context;
+ portletContext.setAttribute(key, value);
+ }
}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java?rev=954965&r1=954964&r2=954965&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java Tue Jun 15 16:58:31 2010
@@ -31,11 +31,13 @@ import javax.faces.context.FacesContext;
import javax.faces.context.ResponseStream;
import javax.faces.context.ResponseWriter;
import javax.faces.render.RenderKit;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResource2;
import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
import org.apache.myfaces.tomahawk.util.ExternalContextUtils;
import org.apache.myfaces.webapp.filter.portlet.PortletExternalContextWrapper;
@@ -136,7 +138,15 @@ public class TomahawkFacesContextWrapper
}
AddResource addResource= AddResourceFactory.getInstance(this);
- addResource.responseStarted();
+
+ if (addResource instanceof AddResource2)
+ {
+ ((AddResource2)addResource).responseStarted(delegate.getExternalContext().getContext(), extendedRequest);
+ }
+ else
+ {
+ addResource.responseStarted();
+ }
if (addResource.requiresBuffer())
{
@@ -177,7 +187,15 @@ public class TomahawkFacesContextWrapper
}
AddResource addResource= AddResourceFactory.getInstance(this);
- addResource.responseStarted();
+
+ if (addResource instanceof AddResource2)
+ {
+ ((AddResource2)addResource).responseStarted(delegate.getExternalContext().getContext(), extendedRequest);
+ }
+ else
+ {
+ addResource.responseStarted();
+ }
if (addResource.requiresBuffer() && extensionsResponseWrapper != null)
{