>From a third-party module (tynamo-security) I have the id (principal) of a 
>Hibernate entity
representing the currently logged in user in the HttpSession. I now want to 
inject that user into
pages after loading it from persistent storage. The entity class shall be 
called User.

Three options come to my mind:

1. Wrap the entity in another class, e.g. CurrentUser, which takes a Hibernate 
session and has a
getUser() accessor which retrieves the User object from persistent storage. 
Store CurrentUser as a
Session State Object and inject it using @SessionState. Needs an 
ApplicationStateCreator. Downside:
needs an additional call to currentUser.getUser() every time I want to access 
the actual logged in user.

2. Create a UserSource service that looks up the User instance, build a 
PropertyShadowBuilder around
it and bind it to the interface of the User class. Downside: requires the User 
entity to have an
interface.

3. Create a persistence strategy that uses the principal from the http session 
to restore the User
from persistent storage. Similar to @Persist("entity").

The goal is to just @Inject User currentUser; or @SessionState User 
currentUser; or @Persist User
currentUser; in a page or service and have acces to the user as denoted by the 
principal stored in
the http session. Which option would you chose? Are there others, maybe more 
straightforward ones,
that I'm missing?

Cheers,

Uli

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to