Announcement Announcement Module
No announcement yet.
Custom initialization of session scoped bean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom initialization of session scoped bean

    I need custom initialization of session scoped beans.

    For example, I have defined a session scoped bean currentUser that refers to currently logged in user. I need to create instance of current user based on the parameters present in the request fist time when user logs in.

    another example is the example given in spring reference guide about user preferences.

    <!-- a HTTP Session-scoped bean exposed as a proxy -->
    <bean id="userPreferences" class="" scope="session">

    However user preferences needs to be initialized by loading preferences from database. how can I achieve this?

    Lot's of folks seems to finding a standard way of achieving this without any success.

    Last edited by ___; Dec 5th, 2009, 03:56 AM.

  • #2
    You can use lifecycle callbacks or @PostConstruct and @PreDestroy annotations with your beans in order to perform the initialization there. That methods are called on every new bean instance construction, so, you can perform necessary initialization there.