views:

16

answers:

0

Hello all,

I really like to use spring stereotype annotated beans in spring MVC apps and would like to use Spring scope annotations to the full extend. No more need to fiddle around in HttpServletRequest or it' s session. One thing isn' t really clear to me though and maybe someone could provide me with some insight or explanation on how to handle this. I have a cache implemented a singleton spring bean. It caches several object of a certain type "Foo". Foo is defined as a session scoped bean through annotations. The intended behavior is that each new session has it' s own "Foo" instance. How do I move the state of one of the cahced "foo" instances to the session scoped Foo (copy, clone or simple assignment)? I would like to achieve the same behavior of storing a Foo instance from the cache into the session available in a HttpSession, but this through the Spring session scoped objects. Goal is to remove all boilerplate code of moving to a HttpSession and retrieving from a HttpSession.

Example of how I define Foo:

@Component @Scope(value="session",proxyMode=ScopedProxyMode.TARGET_CLASS) public class Foo extends BaseEntity { //Some stuff done here private Long id;

}

related questions