public class SessionContext
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CURRENCY |
static java.lang.String |
CURRENTDATE |
static java.lang.String |
CURRENTDATE_VALID_TO |
static java.lang.String |
LANGUAGE |
static java.lang.String |
LOCALE |
static java.lang.String |
PRICEFACTORY |
static java.lang.String |
TIMEOFFSET
The name of the attribute which stores the time offset in milliseconds.
|
static java.lang.String |
TIMEZONE |
static java.lang.String |
TRANSACTION_4_ALLATTRIBUTES |
static java.lang.String |
TRANSACTION_IN_CREATE_DISABLED
Setting this attribute to 'TRUE' will DISABLE the execution of Item#newInstance( SessionContext, JaloSession,
ComposedType, Map ) inside a transaction.
|
static java.lang.String |
USER |
static java.lang.Long |
ZERO_TIME_OFFSET |
| Modifier | Constructor and Description |
|---|---|
|
SessionContext() |
|
SessionContext(SessionContext context) |
protected |
SessionContext(SessionContext context,
boolean asLocal) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAllAttributes(java.util.Map<java.lang.String,? extends java.lang.Object> attributes) |
boolean |
equals(java.lang.Object object) |
protected void |
fixStaleItemsInContext() |
protected <T> T |
fixStaleItemsInValue(java.lang.String name,
T currentValue) |
java.util.Date |
getAdjustedCurrentDate()
Returns the current time ( see
getAdjustedCurrentTime() ) with hours, minutes, seconds and milliseconds
normalized to zero. |
protected long |
getAdjustedCurrentDateMillis() |
java.util.Date |
getAdjustedCurrentTime()
Returns the adjusted current time relative to time set by calling
setCurrentTime(Date) early. |
protected long |
getAdjustedCurrentTimeMillis() |
java.util.Collection<java.lang.String> |
getAllAttributeNames() |
<T> T |
getAttribute(java.lang.String name)
Returns the attribute mapped to key 'name'
|
java.util.Enumeration |
getAttributeNames()
Deprecated.
since ages
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Returns a unmodifiable copy of the session attributes
|
Currency |
getCurrency()
Method getCurrency
|
protected long |
getCurrentTimeMillis()
Override for testing only !
|
Language |
getLanguage()
Returns the language currently associated with this session context.
|
java.util.Locale |
getLocale()
Returns the
Locale which matches the current language settings best. |
PriceFactory |
getPriceFactory()
Method getPriceFactory
|
long |
getTimeOffset()
Returns the time offset in milliseconds.
|
java.util.TimeZone |
getTimeZone()
Returns the
TimeZone which is currently associated with this session context. |
User |
getUser()
Method getUser
|
int |
hashCode() |
protected void |
initializeOnSessionStartup(User user,
Language language,
Currency currency,
java.util.TimeZone timeZone,
PriceFactory injectedPriceFactory) |
java.lang.Object |
removeAttribute(java.lang.String name)
Method removeAttribute
|
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value)
Method setAttribute
|
void |
setAttributes(java.util.Map<java.lang.String,? extends java.lang.Object> attributes)
Method setAttributes
|
void |
setCurrency(Currency currency)
Method setCurrency
|
void |
setCurrentTime(java.util.Date timeInstance)
Set the given timeInstance as the current time.
|
void |
setCurrentTimeSystem()
Set the current time back to system time
|
void |
setLanguage(Language language)
Method setLanguage
|
void |
setLocale(java.util.Locale loc)
Changes the
Locale which should be associated with this session context. |
void |
setPriceFactory(PriceFactory pricefactory)
Method setPriceFactory
|
protected void |
setSession(JaloSession session) |
void |
setSessionContextValues(SessionContext ctx) |
void |
setTimeZome(java.util.TimeZone timezone)
Deprecated.
since ages - use
setTimeZone(TimeZone) instead |
void |
setTimeZone(java.util.TimeZone timezone)
Changes the time zone which is associated with this session context.
|
void |
setUser(User user)
Method setUser
|
java.lang.String |
toString() |
public static final java.lang.String USER
public static final java.lang.String LANGUAGE
public static final java.lang.String CURRENCY
public static final java.lang.String PRICEFACTORY
public static final java.lang.String LOCALE
public static final java.lang.String TIMEZONE
public static final java.lang.Long ZERO_TIME_OFFSET
public static final java.lang.String TIMEOFFSET
public static final java.lang.String CURRENTDATE
public static final java.lang.String CURRENTDATE_VALID_TO
public static final java.lang.String TRANSACTION_IN_CREATE_DISABLED
Sample:
ctx.setAttribute( SessionContext.TRANSACTION_IN_CREATE_DISABLED, Boolean.TRUE );
public static final java.lang.String TRANSACTION_4_ALLATTRIBUTES
public SessionContext()
public SessionContext(SessionContext context)
protected SessionContext(SessionContext context, boolean asLocal)
public boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectprotected void setSession(JaloSession session)
protected void initializeOnSessionStartup(User user, Language language, Currency currency, java.util.TimeZone timeZone, PriceFactory injectedPriceFactory)
public java.lang.String toString()
toString in class java.lang.Objectpublic void setSessionContextValues(SessionContext ctx)
public void setLanguage(Language language)
language - public Language getLanguage()
public java.util.Locale getLocale()
Locale which matches the current language settings best. This affects all data formatting
logic within the hybris platform ( like Currency.formatPrice(double) ). The algorithm works as follows:
setLocale(Locale) : return it directlyLanguage.getLocale() returns a non-null locale: return this
language dependent localeLocale.getDefault().public void setLocale(java.util.Locale loc)
Locale which should be associated with this session context. This affects all data formatting
logic within the hybris platform ( like Currency.formatPrice(double) ).public java.util.TimeZone getTimeZone()
TimeZone which is currently associated with this session context. If no time zone has been set
via setTimeZome(TimeZone) the default vm time zone is returned (see TimeZone.getDefault(). This
affects all date formatting and parsing logic within the hybris platform.public long getTimeOffset()
setCurrentTime(Date), a value of
zero is returned.@Deprecated public void setTimeZome(java.util.TimeZone timezone)
setTimeZone(TimeZone) insteadpublic void setTimeZone(java.util.TimeZone timezone)
public void setCurrency(Currency currency)
currency - public Currency getCurrency()
public void setUser(User user)
user - public User getUser()
public void setPriceFactory(PriceFactory pricefactory)
pricefactory - public PriceFactory getPriceFactory()
public void setAttributes(java.util.Map<java.lang.String,? extends java.lang.Object> attributes)
attributes - public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
protected void fixStaleItemsInContext()
public <T> T getAttribute(java.lang.String name)
protected <T> T fixStaleItemsInValue(java.lang.String name,
T currentValue)
public java.lang.Object setAttribute(java.lang.String name,
java.lang.Object value)
@Deprecated public java.util.Enumeration getAttributeNames()
getAllAttributeNames() instead.public java.util.Collection<java.lang.String> getAllAttributeNames()
public void addAllAttributes(java.util.Map<java.lang.String,? extends java.lang.Object> attributes)
public java.lang.Object removeAttribute(java.lang.String name)
public void setCurrentTime(java.util.Date timeInstance)
protected long getCurrentTimeMillis()
public java.util.Date getAdjustedCurrentTime()
setCurrentTime(Date) early. If
setCurrentTime(Date) was never called before, then current system time is returned.protected long getAdjustedCurrentTimeMillis()
public void setCurrentTimeSystem()
public java.util.Date getAdjustedCurrentDate()
getAdjustedCurrentTime() ) with hours, minutes, seconds and milliseconds
normalized to zero.protected long getAdjustedCurrentDateMillis()
Copyright © 2018 SAP SE. All Rights Reserved.