Made threadlocals generic

This commit is contained in:
Arjen Poutsma 2009-02-03 11:24:10 +00:00
parent c8d6c15a05
commit 5786f6c359
1 changed files with 5 additions and 5 deletions

View File

@ -46,10 +46,10 @@ public abstract class RequestContextHolder {
private static final boolean jsfPresent = private static final boolean jsfPresent =
ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader()); ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
private static final ThreadLocal requestAttributesHolder = new NamedThreadLocal("Request attributes"); private static final ThreadLocal<RequestAttributes> requestAttributesHolder = new NamedThreadLocal<RequestAttributes>("Request attributes");
private static final ThreadLocal inheritableRequestAttributesHolder = private static final ThreadLocal<RequestAttributes> inheritableRequestAttributesHolder =
new NamedInheritableThreadLocal("Request context"); new NamedInheritableThreadLocal<RequestAttributes>("Request context");
/** /**
@ -93,9 +93,9 @@ public abstract class RequestContextHolder {
* or <code>null</code> if none bound * or <code>null</code> if none bound
*/ */
public static RequestAttributes getRequestAttributes() { public static RequestAttributes getRequestAttributes() {
RequestAttributes attributes = (RequestAttributes) requestAttributesHolder.get(); RequestAttributes attributes = requestAttributesHolder.get();
if (attributes == null) { if (attributes == null) {
attributes = (RequestAttributes) inheritableRequestAttributesHolder.get(); attributes = inheritableRequestAttributesHolder.get();
} }
return attributes; return attributes;
} }