Class RestSessionProvider

java.lang.Object
ai.yda.framework.channel.rest.spring.session.RestSessionProvider
All Implemented Interfaces:
ai.yda.framework.session.core.SessionProvider

@Component public class RestSessionProvider extends Object implements ai.yda.framework.session.core.SessionProvider
Provides methods for storing and retrieving data associated with a Session using a key-value store in the REST context.

This component interacts with the HttpSession to manage Session attributes. It provides methods to add and retrieve objects from the Session based on a key.

Since:
0.1.0
  • Constructor Details

    • RestSessionProvider

      public RestSessionProvider(jakarta.servlet.http.HttpSession httpSession)
      Constructs a new RestSessionProvider instance with the specified HttpSession.
      Parameters:
      httpSession - the HttpSession to be used for storing and retrieving Session attributes.
  • Method Details

    • put

      public void put(String key, Object value)
      Stores an object in the Session with the specified key.
      Specified by:
      put in interface ai.yda.framework.session.core.SessionProvider
      Parameters:
      key - the key with which the object is to be associated.
      value - the object to be stored in the Session.
    • get

      public Optional<Object> get(String key)
      Retrieves an object from the Session associated with the specified key.
      Specified by:
      get in interface ai.yda.framework.session.core.SessionProvider
      Parameters:
      key - the key whose associated value is to be retrieved.
      Returns:
      an Optional containing the value associated with the key, or an empty Optional if the key does not exist in the Session.