Author: jcompagner
Date: Mon Nov 5 07:26:02 2007
New Revision: 592045
URL: http://svn.apache.org/viewvc?rev=592045&view=rev
Log:
call unset of the RequestContext on all the places where it should be cleared
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java?rev=592045&r1=592044&r2=592045&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
Mon Nov 5 07:26:02 2007
@@ -165,7 +165,7 @@
if (application == null)
{
throw new WicketRuntimeException("There is no
application attached to current thread " +
- Thread.currentThread().getName());
+ Thread.currentThread().getName());
}
return application;
}
@@ -275,12 +275,12 @@
{
// If component instantiation is not authorized
if
(!Session.get().getAuthorizationStrategy().isInstantiationAuthorized(
- component.getClass()))
+ component.getClass()))
{
// then call any unauthorized component
instantiation
// listener
getSecuritySettings().getUnauthorizedComponentInstantiationListener()
-
.onUnauthorizedInstantiation(component);
+
.onUnauthorizedInstantiation(component);
}
}
});
@@ -296,7 +296,7 @@
* the listener to add
*/
public final void addComponentInstantiationListener(
- final IComponentInstantiationListener listener)
+ final IComponentInstantiationListener listener)
{
if (listener == null)
{
@@ -314,7 +314,7 @@
final IComponentInstantiationListener[] newListeners = new
IComponentInstantiationListener[componentInstantiationListeners.length + 1];
System.arraycopy(componentInstantiationListeners, 0,
newListeners, 0,
- componentInstantiationListeners.length);
+ componentInstantiationListeners.length);
newListeners[componentInstantiationListeners.length] = listener;
componentInstantiationListeners = newListeners;
}
@@ -334,7 +334,7 @@
getDebugSettings().setComponentUseCheck(true);
getMarkupSettings().setStripWicketTags(false);
getExceptionSettings().setUnexpectedExceptionDisplay(
- IExceptionSettings.SHOW_EXCEPTION_PAGE);
+ IExceptionSettings.SHOW_EXCEPTION_PAGE);
getDebugSettings().setAjaxDebugModeEnabled(true);
getResourceSettings().setStripJavascriptCommentsAndWhitespace(false);
}
@@ -344,14 +344,14 @@
getDebugSettings().setComponentUseCheck(false);
getMarkupSettings().setStripWicketTags(true);
getExceptionSettings().setUnexpectedExceptionDisplay(
-
IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
+ IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
getDebugSettings().setAjaxDebugModeEnabled(false);
getResourceSettings().setStripJavascriptCommentsAndWhitespace(true);
}
else
{
throw new IllegalArgumentException("Invalid
configuration type: '" + configurationType +
- "'. Must be \"development\" or
\"deployment\".");
+ "'. Must be \"development\" or
\"deployment\".");
}
}
@@ -594,8 +594,9 @@
try
{
// Load properties files used by all libraries
- final Enumeration resources =
Thread.currentThread().getContextClassLoader()
- .getResources("wicket.properties");
+ final Enumeration resources = Thread.currentThread()
+ .getContextClassLoader()
+ .getResources("wicket.properties");
while (resources.hasMoreElements())
{
InputStream in = null;
@@ -670,7 +671,7 @@
* [EMAIL PROTECTED] #newRequestCycle(Request, Response)}
*/
public final RequestCycle newRequestCycle(Application application,
Request request,
- Response response)
+ Response response)
{
throw new UnsupportedOperationException();
}
@@ -699,7 +700,7 @@
* the listener to remove
*/
public final void removeComponentInstantiationListener(
- final IComponentInstantiationListener listener)
+ final IComponentInstantiationListener listener)
{
final IComponentInstantiationListener[] listeners =
componentInstantiationListeners;
final int len = listeners.length;
@@ -809,7 +810,7 @@
if (!settingsAccessible)
{
throw new WicketRuntimeException(
- "Use Application.init() method for
configuring your application object");
+ "Use Application.init() method for configuring
your application object");
}
if (settings == null)
@@ -890,6 +891,7 @@
callDestroyers();
applicationKeyToApplication.remove(getApplicationKey());
Session.unset();
+ RequestContext.unset();
RequestCycle.set(null);
}
@@ -920,7 +922,7 @@
// Install button image resource factory
getResourceSettings().addResourceFactory("buttonFactory",
- new DefaultButtonImageResourceFactory());
+ new DefaultButtonImageResourceFactory());
String applicationKey = getApplicationKey();
applicationKeyToApplication.put(applicationKey, this);
@@ -1001,7 +1003,7 @@
* @param listener
*/
final public void removeComponentOnBeforeRenderListener(
- IComponentOnBeforeRenderListener listener)
+ IComponentOnBeforeRenderListener listener)
{
if (componentOnBeforeRenderListeners != null)
{
@@ -1024,8 +1026,7 @@
{
for (Iterator i =
componentOnBeforeRenderListeners.iterator(); i.hasNext();)
{
- IComponentOnBeforeRenderListener listener =
(IComponentOnBeforeRenderListener)i
- .next();
+ IComponentOnBeforeRenderListener listener =
(IComponentOnBeforeRenderListener)i.next();
listener.onBeforeRender(component);
}
}
@@ -1080,8 +1081,7 @@
{
for (Iterator i =
componentOnAfterRenderListeners.iterator(); i.hasNext();)
{
- IComponentOnAfterRenderListener listener =
(IComponentOnAfterRenderListener)i
- .next();
+ IComponentOnAfterRenderListener listener =
(IComponentOnAfterRenderListener)i.next();
listener.onAfterRender(component);
}
}
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java?rev=592045&r1=592044&r2=592045&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java
Mon Nov 5 07:26:02 2007
@@ -26,11 +26,17 @@
/** Thread-local that holds the current request context. */
private static final ThreadLocal current = new ThreadLocal();
+ /**
+ * Construct.
+ */
public RequestContext()
{
set(this);
}
+ /**
+ * @return The current threads request context, will make one if there
wasn't one.
+ */
public static final RequestContext get()
{
RequestContext context = (RequestContext)current.get();
@@ -41,46 +47,83 @@
return context;
}
+ /**
+ *
+ */
+ public static final void unset()
+ {
+ current.set(null);
+ }
+
protected static final void set(RequestContext context)
{
current.set(context);
}
+ /**
+ * @return CharSequence
+ */
public CharSequence getNamespace()
{
return "";
}
+ /**
+ * @param markupId
+ * @return The encoded markup
+ */
public String encodeMarkupId(String markupId)
{
return markupId;
}
+ /**
+ * @param path
+ * @return The encoded url
+ */
public CharSequence encodeActionURL(CharSequence path)
{
return path;
}
+ /**
+ * @param path
+ * @return The encoded url
+ */
public CharSequence encodeRenderURL(CharSequence path)
{
return path;
}
+ /**
+ * @param path
+ * @return The encoded url
+ */
public CharSequence encodeResourceURL(CharSequence path)
{
return path;
}
+ /**
+ * @param path
+ * @return The encoded url
+ */
public CharSequence encodeSharedResourceURL(CharSequence path)
{
return path;
}
+ /**
+ * @return The IHeaderResponse
+ */
public IHeaderResponse getHeaderResponse()
{
return null;
}
+ /**
+ * @return boolean if this is a portlet request
+ */
public boolean isPortletRequest()
{
return false;
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java?rev=592045&r1=592044&r2=592045&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
Mon Nov 5 07:26:02 2007
@@ -100,24 +100,25 @@
* a Portlet context. Value should be true
*/
private final String PORTLET_ONLY_FILTER = "portletOnlyFilter";
-
+
/**
- * The name of the optional filter parameter indicating a
javax.portlet.PortletContext class should be looked up
- * to determine if portlet support should be provided.
+ * The name of the optional filter parameter indicating a
javax.portlet.PortletContext class
+ * should be looked up to determine if portlet support should be
provided.
*/
private final String DETECT_PORTLET_CONTEXT = "detectPortletContext";
-
+
/**
- * The name of the optional web.xml context parameter indicating if a
portlet context is to be determined
- * by looking up the javax.portlet.PortletContext class. Default value
is false.
- * This context parameter is only queried if the filter parameter
DETECT_PORTLET_CONTEXT isn't provided.
- * If additionally the context parameter is not specified, a
WicketPortlet.properties resource will be looked up
- * through the classpath which, if found, is queried for a property
with the same name.
+ * The name of the optional web.xml context parameter indicating if a
portlet context is to be
+ * determined by looking up the javax.portlet.PortletContext class.
Default value is false. This
+ * context parameter is only queried if the filter parameter
DETECT_PORTLET_CONTEXT isn't
+ * provided. If additionally the context parameter is not specified, a
WicketPortlet.properties
+ * resource will be looked up through the classpath which, if found, is
queried for a property
+ * with the same name.
*/
private final String DETECT_PORTLET_CONTEXT_FULL_NAME =
"org.apache.wicket.detectPortletContext";
-
+
/**
- * The classpath resource name of an optional WicketPortlet.properties
file.
+ * The classpath resource name of an optional WicketPortlet.properties
file.
*/
private final String WICKET_PORTLET_PROPERTIES =
"org/apache/wicket/protocol/http/portlet/WicketPortlet.properties";
@@ -149,7 +150,7 @@
* javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
- throws IOException, ServletException
+ throws IOException, ServletException
{
HttpServletRequest httpServletRequest;
HttpServletResponse httpServletResponse;
@@ -158,9 +159,9 @@
if (filterPortletContext != null)
{
FilterRequestContext filterRequestContext = new
FilterRequestContext(
- (HttpServletRequest)request,
(HttpServletResponse)response);
+ (HttpServletRequest)request,
(HttpServletResponse)response);
inPortletContext =
filterPortletContext.setupFilter(getFilterConfig(),
- filterRequestContext,
getFilterPath((HttpServletRequest)request));
+ filterRequestContext,
getFilterPath((HttpServletRequest)request));
httpServletRequest = filterRequestContext.getRequest();
httpServletResponse =
filterRequestContext.getResponse();
}
@@ -213,6 +214,7 @@
{
// always unset the application thread local
Application.unset();
+ RequestContext.unset();
}
}
else
@@ -233,13 +235,13 @@
* @throws IOException
*/
public void doGet(final HttpServletRequest servletRequest,
- final HttpServletResponse servletResponse) throws
ServletException, IOException
+ final HttpServletResponse servletResponse) throws
ServletException, IOException
{
String relativePath = getRelativePath(servletRequest);
// Special-case for home page - we redirect to add a trailing
slash.
if (relativePath.length() == 0 &&
-
!Strings.stripJSessionId(servletRequest.getRequestURI()).endsWith("/"))
+
!Strings.stripJSessionId(servletRequest.getRequestURI()).endsWith("/"))
{
final String redirectUrl =
servletRequest.getRequestURI() + "/";
servletResponse.sendRedirect(servletResponse.encodeRedirectURL(redirectUrl));
@@ -272,7 +274,7 @@
// the request has the same encoding.
This is especially
// important for forms and form
parameters.
servletRequest.setCharacterEncoding(webApplication.getRequestCycleSettings()
-
.getResponseRequestEncoding());
+ .getResponseRequestEncoding());
}
catch (UnsupportedEncodingException ex)
{
@@ -296,12 +298,12 @@
if (!Strings.isEmpty(queryString))
{
bufferedResponse =
webApplication.popBufferedResponse(sessionId,
- queryString);
+ queryString);
}
else
{
bufferedResponse =
webApplication.popBufferedResponse(sessionId,
- relativePath);
+ relativePath);
}
if (bufferedResponse != null)
@@ -330,7 +332,7 @@
response =
webApplication.newWebResponse(servletResponse);
response.setAjax(request.isAjax());
response.setCharacterEncoding(webApplication.getRequestCycleSettings()
- .getResponseRequestEncoding());
+ .getResponseRequestEncoding());
createRequestContext(request, response);
@@ -361,6 +363,7 @@
// Clean up thread local application if
this was an external call
// (if not, doFilter will clean it up)
Application.unset();
+ RequestContext.unset();
}
}
}
@@ -452,7 +455,7 @@
if (filterMapping == null)
{
InputStream is =
filterConfig.getServletContext().getResourceAsStream(
- "/WEB-INF/web.xml");
+ "/WEB-INF/web.xml");
if (is != null)
{
try
@@ -466,15 +469,14 @@
catch (SecurityException e)
{
// Swallow this at INFO.
- log
- .info("Couldn't
read web.xml to automatically pick up servlet/filter path: " +
-
e.getMessage());
+ log.info("Couldn't read web.xml
to automatically pick up servlet/filter path: " +
+ e.getMessage());
}
if (filterPath == null)
{
log.info("Unable to parse
filter mapping web.xml for " +
-
filterConfig.getFilterName() + ". " + "Configure with init-param " +
-
FILTER_MAPPING_PARAM + " if it is not \"/*\".");
+
filterConfig.getFilterName() + ". " + "Configure with init-param " +
+ FILTER_MAPPING_PARAM +
" if it is not \"/*\".");
}
}
}
@@ -512,7 +514,7 @@
webApplication.logStarted();
portletOnlyFilter =
Boolean.valueOf(filterConfig.getInitParameter(PORTLET_ONLY_FILTER))
- .booleanValue();
+ .booleanValue();
if (isPortletContextAvailable(filterConfig))
{
@@ -532,7 +534,7 @@
}
}
}
-
+
protected boolean isPortletContextAvailable(FilterConfig config) throws
ServletException
{
boolean detectPortletContext = false;
@@ -543,14 +545,16 @@
}
else
{
- parameter =
config.getServletContext().getInitParameter(DETECT_PORTLET_CONTEXT_FULL_NAME);
+ parameter = config.getServletContext().getInitParameter(
+ DETECT_PORTLET_CONTEXT_FULL_NAME);
if (parameter != null)
{
detectPortletContext =
Boolean.valueOf(parameter).booleanValue();
}
else
{
- InputStream is =
Thread.currentThread().getContextClassLoader()
+ InputStream is = Thread.currentThread()
+ .getContextClassLoader()
.getResourceAsStream(WICKET_PORTLET_PROPERTIES);
if (is != null)
{
@@ -558,13 +562,14 @@
{
Properties properties = new
Properties();
properties.load(is);
- detectPortletContext =
Boolean.valueOf(properties.getProperty(
-
DETECT_PORTLET_CONTEXT_FULL_NAME, "false")).booleanValue();
+ detectPortletContext =
Boolean.valueOf(
+
properties.getProperty(DETECT_PORTLET_CONTEXT_FULL_NAME, "false"))
+ .booleanValue();
}
catch (IOException e)
{
throw new ServletException(
- "Failed to load
WicketPortlet.properties from classpath", e);
+ "Failed to load
WicketPortlet.properties from classpath", e);
}
}
}
@@ -591,7 +596,7 @@
protected void createRequestContext(WebRequest request, WebResponse
response)
{
if (filterPortletContext == null ||
-
!filterPortletContext.createPortletRequestContext(request, response))
+
!filterPortletContext.createPortletRequestContext(request, response))
{
new RequestContext();
}
@@ -639,12 +644,14 @@
else if (elem.isClose() &&
elem.getName().equals(name))
{
encounteredFilterName =
parser.getInputFromPositionMarker(elem.getPos())
-
.toString().trim();
+ .toString()
+ .trim();
}
else if (elem.isClose() &&
elem.getName().equals("url-pattern"))
{
- urlPattern =
parser.getInputFromPositionMarker(elem.getPos()).toString()
- .trim();
+ urlPattern =
parser.getInputFromPositionMarker(elem.getPos())
+ .toString()
+ .trim();
}
}
while (urlPattern == null ||
encounteredFilterName == null);
@@ -666,8 +673,8 @@
if (urlPatterns.size() == 0)
{
throw new IllegalArgumentException("Error
initializing Wicket" + prefixUppered +
- " - you have no <" + mapping +
"> element with a url-pattern that uses " +
- prefix + ": " + filterName);
+ " - you have no <" + mapping + ">
element with a url-pattern that uses " +
+ prefix + ": " + filterName);
}
String urlPattern = (String)urlPatterns.get(0);
@@ -675,7 +682,7 @@
if (!urlPattern.startsWith("/") ||
!urlPattern.endsWith("*"))
{
throw new IllegalArgumentException("<" +
mapping + "> for Wicket" + prefixUppered +
- " \"" + filterName + "\" must
start with '/' and end with '*'.");
+ " \"" + filterName + "\" must start
with '/' and end with '*'.");
}
// Strip trailing '*' and keep leading '/'.
@@ -684,17 +691,17 @@
catch (IOException e)
{
throw new ServletException("Error finding <" + prefix +
"> " + filterName +
- " in web.xml", e);
+ " in web.xml", e);
}
catch (ParseException e)
{
throw new ServletException("Error finding <" + prefix +
"> " + filterName +
- " in web.xml", e);
+ " in web.xml", e);
}
catch (ResourceStreamNotFoundException e)
{
throw new ServletException("Error finding <" + prefix +
"> " + filterName +
- " in web.xml", e);
+ " in web.xml", e);
}
}
@@ -723,8 +730,9 @@
}
// Mounted page
- return
webApplication.getRequestCycleProcessor().getRequestCodingStrategy()
- .urlCodingStrategyForPath(relativePath) != null;
+ return webApplication.getRequestCycleProcessor()
+ .getRequestCodingStrategy()
+ .urlCodingStrategyForPath(relativePath) != null;
}
/**
@@ -770,8 +778,9 @@
try
{
// Try to find the specified factory class
- final Class factoryClass =
Thread.currentThread().getContextClassLoader()
- .loadClass(appFactoryClassName);
+ final Class factoryClass =
Thread.currentThread()
+ .getContextClassLoader()
+ .loadClass(appFactoryClassName);
// Instantiate the factory
return
(IWebApplicationFactory)factoryClass.newInstance();
@@ -779,7 +788,7 @@
catch (ClassCastException e)
{
throw new WicketRuntimeException("Application
factory class " +
- appFactoryClassName + " must
implement IWebApplicationFactory");
+ appFactoryClassName + " must implement
IWebApplicationFactory");
}
catch (ClassNotFoundException e)
{
@@ -824,10 +833,10 @@
if (filterConfig.getInitParameter("filterPath") != null)
{
throw new WicketRuntimeException(
- "\nThe filterPath init-param for
WicketFilter has been removed.\n" +
- "Please use a param
called " + FILTER_MAPPING_PARAM +
- " with a value that
exactly\n" +
- "matches that in the
<url-pattern> element of your <filter-mapping> (e.g. \"/app/*\").");
+ "\nThe filterPath init-param for WicketFilter
has been removed.\n" +
+ "Please use a param called " +
FILTER_MAPPING_PARAM +
+ " with a value that exactly\n" +
+ "matches that in the <url-pattern>
element of your <filter-mapping> (e.g. \"/app/*\").");
}
result = filterConfig.getInitParameter(FILTER_MAPPING_PARAM);
@@ -838,7 +847,7 @@
else if (!result.startsWith("/") || !result.endsWith("/*"))
{
throw new WicketRuntimeException("Your " +
FILTER_MAPPING_PARAM +
- " must start with \"/\" and end with
\"/*\". It is: " + result);
+ " must start with \"/\" and end with \"/*\". It
is: " + result);
}
return filterPath = stripWildcard(result);
}
@@ -847,7 +856,7 @@
* Strip trailing '*' and keep leading '/'
*
* @param result
- * @return
+ * @return The stripped String
*/
private String stripWildcard(String result)
{
@@ -867,8 +876,7 @@
if
(pathInfo.startsWith(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX))
{
- final String resourceReferenceKey = pathInfo
-
.substring(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX.length());
+ final String resourceReferenceKey =
pathInfo.substring(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX.length());
Resource resource = null;
@@ -930,6 +938,7 @@
// Clean up thread local application if
this was an external call
// (if not, doFilter will clean it up)
Application.unset();
+ RequestContext.unset();
}
if (Session.exists())
{