I want to use UserContext class in web and stand-alone applications. The application will have multiple users. I am using JDK 1.5 and WebSphere 6.1. For a given user, I set the userID by calling setUserId(
String userId). I want to get this back this userID, when I call getUserID() method. However, I would like to get some assurance on my approach that it will work. I am yet to
test it in a multiuser and clustered environment.
As every user logs in, I set userID of the user by calling UserContext.setUserId(String userId). For example, if user John logs in, I set his userID as "John". If user Peter logs in, I set his userID as "Peter". Obviously, userID set is not as simple as "John", or "Peter"; but some other kind of identifier. But this is an example.
My questions are:
1. When I call UserContext.getUserID() in the code, will it return "John" for user John and "Peter" for user Peter? My understanding is, ues; it will return "John" for user John and "Peter" for user Peter.
2. Can I call UserContext.getUserID() method in any part of the code to get the userID back? Or, do I a need to call UserContext.getUserID() ) in a particular part of the code and pass the retrieved user ID as argument to any method. My understanding is, I can call UserContext.getUserID() in any part of the code and it will correctly return "John" or "Peter".
I think my assumptions are correct.
Any comment or suggestion will be appreciated.