com.mycompany.util
Class UserSession

java.lang.Object
  extended by com.mycompany.util.UserSession
All Implemented Interfaces:
java.io.Serializable

@Named(value="userSession")
@SessionScoped
public class UserSession
extends java.lang.Object
implements java.io.Serializable

Session-scoped CDI managed bean to store a User object.

Author:
Ian Hlavats (ian@tarantulaconsulting.com)
See Also:
Serialized Form

Constructor Summary
UserSession()
           
 
Method Summary
 User getUser()
          Returns the current User.
 void release()
          CDI calls this method before the bean is destroyed.
 void setUser(User user)
          Sets the User.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserSession

public UserSession()
Method Detail

getUser

public User getUser()
Returns the current User.

Returns:
A User object.

setUser

public void setUser(User user)
Sets the User.

Parameters:
user - The User object.

release

@PreDestroy
public void release()
CDI calls this method before the bean is destroyed. Since this class is session-scoped, it will get called if the user session expires, allowing us to remove the user from the active user list.