Package de.hybris.platform.jalo
Class SessionContext
java.lang.Object
de.hybris.platform.jalo.SessionContext
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
StandardSearchContext
The Context-Object of a JaloSession.
This object is responsible for the current user, language, currency and custom session properties.
This object is responsible for the current user, language, currency and custom session properties.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe name of the attribute which stores the time offset in milliseconds.static final Stringstatic final Stringstatic final StringSetting this attribute to 'TRUE' will DISABLE the execution of Item#newInstance( SessionContext, JaloSession, ComposedType, Map ) inside a transaction.static final Stringstatic final Long -
Constructor Summary
ConstructorsModifierConstructorDescriptionSessionContext(SessionContext context) protectedSessionContext(SessionContext context, boolean asLocal) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllAttributes(Map<String, ? extends Object> attributes) booleanprotected voidprotected <T> TfixStaleItemsInValue(String name, T currentValue) Returns the current time ( seegetAdjustedCurrentTime()) with hours, minutes, seconds and milliseconds normalized to zero.protected longReturns the adjusted current time relative to time set by callingsetCurrentTime(Date)early.protected long<T> TgetAttribute(String name) Returns the attribute mapped to key 'name'Deprecated.since agesReturns a unmodifiable copy of the session attributesMethod getCurrencyprotected longOverride for testing only !Returns the language currently associated with this session context.Returns theLocalewhich matches the current language settings best.Method getPriceFactorylongReturns the time offset in milliseconds.Returns theTimeZonewhich is currently associated with this session context.getUser()Method getUserinthashCode()protected voidinitializeOnSessionStartup(User user, Language language, Currency currency, TimeZone timeZone, PriceFactory injectedPriceFactory) removeAttribute(String name) Method removeAttributesetAttribute(String name, Object value) Method setAttributevoidsetAttributes(Map<String, ? extends Object> attributes) Method setAttributesvoidsetCurrency(Currency currency) Method setCurrencyvoidsetCurrentTime(Date timeInstance) Set the given timeInstance as the current time.voidSet the current time back to system timevoidsetLanguage(Language language) Method setLanguagevoidChanges theLocalewhich should be associated with this session context.voidsetPriceFactory(PriceFactory pricefactory) Method setPriceFactoryprotected voidsetSession(JaloSession session) setSessionContextAttributesLocally(SessionContext context, Map<String, Object> contextAttributes) setSessionContextAttributesLocally(Map<String, Object> contextAttributes) voidvoidsetTimeZome(TimeZone timezone) Deprecated.since ages - usesetTimeZone(TimeZone)insteadvoidsetTimeZone(TimeZone timezone) Changes the time zone which is associated with this session context.voidMethod setUsertoString()
-
Field Details
-
USER
- See Also:
-
LANGUAGE
- See Also:
-
CURRENCY
- See Also:
-
PRICEFACTORY
- See Also:
-
LOCALE
- See Also:
-
TIMEZONE
- See Also:
-
ZERO_TIME_OFFSET
-
TIMEOFFSET
The name of the attribute which stores the time offset in milliseconds. This attribute allows adjusting time in a consistent way across the entire session.- See Also:
-
CURRENTDATE
- See Also:
-
CURRENTDATE_VALID_TO
- See Also:
-
TRANSACTION_IN_CREATE_DISABLED
Setting this attribute to 'TRUE' will DISABLE the execution of Item#newInstance( SessionContext, JaloSession, ComposedType, Map ) inside a transaction.Sample:
ctx.setAttribute( SessionContext.TRANSACTION_IN_CREATE_DISABLED, Boolean.TRUE );- See Also:
-
TRANSACTION_4_ALLATTRIBUTES
- See Also:
-
-
Constructor Details
-
SessionContext
public SessionContext() -
SessionContext
-
SessionContext
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
setSession
-
initializeOnSessionStartup
protected void initializeOnSessionStartup(User user, Language language, Currency currency, TimeZone timeZone, PriceFactory injectedPriceFactory) -
toString
-
setSessionContextValues
-
setLanguage
Method setLanguage- Parameters:
language-
-
getLanguage
Returns the language currently associated with this session context. Please note that for some reasons the session context may hold no language at all ( e.g. when using the context to fetch all values of a localized attribute at once). -
getLocale
Returns theLocalewhich matches the current language settings best. This affects all data formatting logic within the hybris platform ( likeCurrency.formatPrice(double)). The algorithm works as follows:- a locale has been set via
setLocale(Locale): return it directly - a language is present and its method
Language.getLocale()returns a non-null locale: return this language dependent locale - otherwise simply return the vm default locale from
Locale.getDefault().
- Since:
- 3.0 M2
- a locale has been set via
-
setLocale
Changes theLocalewhich should be associated with this session context. This affects all data formatting logic within the hybris platform ( likeCurrency.formatPrice(double)).- Since:
- 3.0 M2
-
getTimeZone
Returns theTimeZonewhich is currently associated with this session context. If no time zone has been set viasetTimeZome(TimeZone)the default vm time zone is returned (seeTimeZone.getDefault(). This affects all date formatting and parsing logic within the hybris platform.- Since:
- 3.0 M2
-
getTimeOffset
public long getTimeOffset()Returns the time offset in milliseconds. If there has been no call tosetCurrentTime(Date), a value of zero is returned. -
setTimeZome
Deprecated.since ages - usesetTimeZone(TimeZone)insteadChanges the time zone which is associated with this session context.- Since:
- 3.0 M2
-
setTimeZone
Changes the time zone which is associated with this session context.- Since:
- 3.0 M2
-
setCurrency
Method setCurrency- Parameters:
currency-
-
getCurrency
Method getCurrency -
setUser
Method setUser- Parameters:
user-
-
getUser
Method getUser -
setPriceFactory
Method setPriceFactory- Parameters:
pricefactory-
-
getPriceFactory
Method getPriceFactory -
setAttributes
Method setAttributes- Parameters:
attributes-
-
getAttributes
Returns a unmodifiable copy of the session attributes- Returns:
- map
-
fixStaleItemsInContext
protected void fixStaleItemsInContext() -
getAttribute
Returns the attribute mapped to key 'name' -
fixStaleItemsInValue
-
setAttribute
Method setAttribute -
getAttributeNames
Deprecated.since agesReturns an Enumeration of String objects containing the names of all the objects bound to this session. UsegetAllAttributeNames()instead. -
getAllAttributeNames
-
addAllAttributes
-
removeAttribute
Method removeAttribute -
setCurrentTime
Set the given timeInstance as the current time. This method is used to adjust the current time to either a past or future instant. -
getCurrentTimeMillis
protected long getCurrentTimeMillis()Override for testing only ! -
getAdjustedCurrentTime
Returns the adjusted current time relative to time set by callingsetCurrentTime(Date)early. IfsetCurrentTime(Date)was never called before, then current system time is returned. -
getAdjustedCurrentTimeMillis
protected long getAdjustedCurrentTimeMillis() -
setCurrentTimeSystem
public void setCurrentTimeSystem()Set the current time back to system time -
getAdjustedCurrentDate
Returns the current time ( seegetAdjustedCurrentTime()) with hours, minutes, seconds and milliseconds normalized to zero. -
getAdjustedCurrentDateMillis
protected long getAdjustedCurrentDateMillis() -
setSessionContextAttributesLocally
public static SessionContext.SessionContextAttributeSetter setSessionContextAttributesLocally(SessionContext context, Map<String, Object> contextAttributes) -
setSessionContextAttributesLocally
public SessionContext.SessionContextAttributeSetter setSessionContextAttributesLocally(Map<String, Object> contextAttributes)
-