Back Forum Reply New

AOP for some common parameters like user profile

i am writing a web application with Spring. The app needs to be aware of using user preferences throughout every workflow. For example, Code:
getToolbar(UserPrefs userPrefs);
getDocument(Keyword keyword, UserPrefs userPrefs);
Almost all functions need to be preference-aware. Users could change their preferences at the runtime. I feel like it duplicate to add userPrefs to parameters of all functions. I could put userPrefs in a session, but I am wondering if that's the best way to do it? Is there something in Spring-AOP I could use for that purpose?

thanks,

Why not create a UserPrefsHolder based on a ThreadLocal, that way you can simply call the UserPrefsHolder.getUserPrefs(). You can set it at the start of each request with a servlet filter or HandlerInterceptor
¥
Back Forum Reply New