The following is a utility class that is called by a LoginBean to add and get a User object from a session through FacesContext.
The application uses Spring. Should I use an annotation or is it an accepted practise to have static methods in this sort of class? If an annotation is advised, should I use @Component or @Service?
// Annotate as Service/Component?
public class WebUtils {
// Add user object to session
public void setUser( User user ){
FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getSessionMap().put( "user", user );
}
// Get user from session
public User getUser( FacesContext context ){
if( context != null )
return (User) context.getExternalContext().getSessionMap().get("user");
return null;
}