Class SessionContext

java.lang.Object
de.hybris.platform.jalo.SessionContext
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
StandardSearchContext

public class SessionContext extends Object implements Serializable
The Context-Object of a JaloSession.
This object is responsible for the current user, language, currency and custom session properties.
See Also:
  • Field Details

  • Constructor Details

    • SessionContext

      public SessionContext()
    • SessionContext

      public SessionContext(SessionContext context)
    • SessionContext

      protected SessionContext(SessionContext context, boolean asLocal)
  • Method Details

    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • setSession

      protected void setSession(JaloSession session)
    • initializeOnSessionStartup

      protected void initializeOnSessionStartup(User user, Language language, Currency currency, TimeZone timeZone, PriceFactory injectedPriceFactory)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setSessionContextValues

      public void setSessionContextValues(SessionContext ctx)
    • setLanguage

      public void setLanguage(Language language)
      Method setLanguage
      Parameters:
      language -
    • getLanguage

      public 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

      public Locale getLocale()
      Returns the 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:
      Since:
      3.0 M2
    • setLocale

      public void setLocale(Locale loc)
      Changes the Locale which should be associated with this session context. This affects all data formatting logic within the hybris platform ( like Currency.formatPrice(double) ).
      Since:
      3.0 M2
    • getTimeZone

      public TimeZone getTimeZone()
      Returns the 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.
      Since:
      3.0 M2
    • getTimeOffset

      public long getTimeOffset()
      Returns the time offset in milliseconds. If there has been no call to setCurrentTime(Date), a value of zero is returned.
    • setTimeZome

      @Deprecated(since="ages", forRemoval=false) public void setTimeZome(TimeZone timezone)
      Deprecated.
      since ages - usesetTimeZone(TimeZone) instead
      Changes the time zone which is associated with this session context.
      Since:
      3.0 M2
    • setTimeZone

      public void setTimeZone(TimeZone timezone)
      Changes the time zone which is associated with this session context.
      Since:
      3.0 M2
    • setCurrency

      public void setCurrency(Currency currency)
      Method setCurrency
      Parameters:
      currency -
    • getCurrency

      public Currency getCurrency()
      Method getCurrency
    • setUser

      public void setUser(User user)
      Method setUser
      Parameters:
      user -
    • getUser

      public User getUser()
      Method getUser
    • setPriceFactory

      public void setPriceFactory(PriceFactory pricefactory)
      Method setPriceFactory
      Parameters:
      pricefactory -
    • getPriceFactory

      public PriceFactory getPriceFactory()
      Method getPriceFactory
    • setAttributes

      public void setAttributes(Map<String,? extends Object> attributes)
      Method setAttributes
      Parameters:
      attributes -
    • getAttributes

      public Map<String,Object> getAttributes()
      Returns a unmodifiable copy of the session attributes
      Returns:
      map
    • fixStaleItemsInContext

      protected void fixStaleItemsInContext()
    • getAttribute

      public <T> T getAttribute(String name)
      Returns the attribute mapped to key 'name'
    • fixStaleItemsInValue

      protected <T> T fixStaleItemsInValue(String name, T currentValue)
    • setAttribute

      public Object setAttribute(String name, Object value)
      Method setAttribute
    • getAttributeNames

      @Deprecated(since="ages", forRemoval=false) public Enumeration getAttributeNames()
      Deprecated.
      since ages
      Returns an Enumeration of String objects containing the names of all the objects bound to this session. Use getAllAttributeNames() instead.
    • getAllAttributeNames

      public Collection<String> getAllAttributeNames()
    • addAllAttributes

      public void addAllAttributes(Map<String,? extends Object> attributes)
    • removeAttribute

      public Object removeAttribute(String name)
      Method removeAttribute
    • setCurrentTime

      public void setCurrentTime(Date timeInstance)
      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

      public Date getAdjustedCurrentTime()
      Returns the adjusted current time relative to time set by calling setCurrentTime(Date) early. If setCurrentTime(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

      public Date getAdjustedCurrentDate()
      Returns the current time ( see getAdjustedCurrentTime() ) 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)