public class ThreadContext extends Object
Modifier and Type | Field and Description |
---|---|
static short |
HTTP_SESSION
session types
|
static short |
INTERNAL_SESSION |
protected static org.slf4j.Logger |
logger |
static short |
REST_SESSION |
static short |
RMI_SESSION |
static short |
WEBDAV_SESSION |
static short |
WEBSERVICE_SESSION |
static short |
WOPI_SESSION |
Constructor and Description |
---|
ThreadContext() |
Modifier and Type | Method and Description |
---|---|
static void |
addThreadLocale(ThreadLocal<?> local) |
static void |
clean()
Clean the thread context.
|
static Object |
getAttribute(Object key)
Gets the value identified by the passed key
|
Iterator<Object> |
getAttributeKeys()
Returns an iterator over all keys which were added via method
setAttribute(Object, Object) |
static String |
getSessionId()
Get the thread sessionId.
|
static ThreadLocal2<String> |
getSessions()
Get the sessions.
|
static short |
getSessionType()
Get the type of the Session
|
static Locale |
getThreadLocale()
Get the thread locale.
|
static <T extends Principal> |
getThreadPrincipal()
Get the thread principal, the user who performs the action.
|
static HttpServletRequest |
getThreadRequest()
Get the HttpServletRequest of this thread.
|
static TimeZone |
getThreadTimeZone()
Get the thread TimeZone
|
static boolean |
isPrivileged()
Is the thread privileged.
|
static void |
removeAttribute(Object key)
Removes the key-value pair identified by the passed key
|
static void |
setAttribute(Object key,
Object value)
Adds a key-value pair to the thread's context.
|
static void |
setPrivileged()
Set the thread privileged.
|
static void |
setSessionId(String s)
Set the session id of the thread.
|
static void |
setSessionType(short s)
Set the type of this thread.
|
static void |
setThreadLocale(Locale l)
Set the locale of the thread.
|
static void |
setThreadPrincipal(Principal p)
Set the principal of the thread.
|
static void |
setThreadRequest(HttpServletRequest req)
Set the HttpServletRequest of the thread.
|
static void |
setThreadTimeZone(TimeZone t)
Set the TimeZone of the thread.
|
static AutoCloseable |
switchThreadLocale(Locale locale)
Change the locale of the thread.
|
static AutoCloseable |
switchThreadPrincipal(Principal p)
Change the principal of the thread.
|
static AutoCloseable |
switchThreadTimeZone(TimeZone tz)
Change the timezone of the thread.
|
protected static final org.slf4j.Logger logger
public static final short HTTP_SESSION
public static final short RMI_SESSION
public static final short INTERNAL_SESSION
public static final short WEBDAV_SESSION
public static final short WEBSERVICE_SESSION
public static final short WOPI_SESSION
public static final short REST_SESSION
public static void setThreadLocale(Locale l)
l
- a locale objectpublic static Locale getThreadLocale()
public static void setThreadPrincipal(Principal p)
p
- a Principal objectpublic static AutoCloseable switchThreadPrincipal(Principal p)
p
- a Principal objectAutoCloseable
may be used in combination with a try-with-resources
statement
try(AutoCloseable
closable = switchThreadPrincipal(Principal)
) {
...
}
public static AutoCloseable switchThreadLocale(Locale locale)
locale
- a Locale
objectAutoCloseable
may be used in combination with a try-with-resources
statement
try(AutoCloseable
closable = switchThreadLocale(Locale)
) {
...
}
public static AutoCloseable switchThreadTimeZone(TimeZone tz)
tz
- a TimeZone
objectAutoCloseable
may be used in combination with a try-with-resources
statement
try(AutoCloseable
closable = switchThreadTimeZone(TimeZone)
) {
...
}
public static <T extends Principal> T getThreadPrincipal()
public static void setSessionId(String s)
s
- a string objectpublic static String getSessionId()
public static void setThreadTimeZone(TimeZone t)
t
- a TimeZone objectpublic static TimeZone getThreadTimeZone()
public static ThreadLocal2<String> getSessions()
public static void setPrivileged()
public static boolean isPrivileged()
public static void setThreadRequest(HttpServletRequest req)
req
- a HttpServletRequest objectpublic static HttpServletRequest getThreadRequest()
public static short getSessionType()
public static void setSessionType(short s)
s
- either HTTP_SESSION, RMI_SESSION or INTERNAL_SESSIONpublic static void setAttribute(Object key, Object value)
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keypublic static Object getAttribute(Object key)
key
- key whose value should be retrievedpublic static void removeAttribute(Object key)
key
- key whose value should be removedpublic Iterator<Object> getAttributeKeys()
setAttribute(Object, Object)
public static void clean()
public static void addThreadLocale(ThreadLocal<?> local)
@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.