Is it possible in Springframework 2.5.6 to have scope = "session" create an object when creating a session

I have a project using the Jetspeed portal and Springframework 2.5.6, where I need a Jetspeed-level service that will be unique for each registered user. This is best done using Spring AOP and scope = "session". The problem is that these are behind the scenes beans that should be launched right after the session starts. It seems like Spring AOP picks a lazy boot design and doesn't create or run the actual implementation until the method in the bean is called.

Is there a way to get Spring AOP to create a new bean as soon as the session object is created?

+3
source share
1 answer

Great question. The simplest option that comes to mind (if you excuse the expression) is to associate a bean in the controller with your session, which is called when the first request for the session arrives (and for this the controller must be either the session bean itself, or your bean must will use aop:scoped-proxy).

If you can call different controllers at the beginning of the session, you can connect the bean to the interceptor with the communication session and configure the display of URLs for sending requests through the interceptor, ensuring that the bean is initialized at the beginning of the session.

. HttpSessionListener, getBean("my-session-scoped-bean") , sessionCreated(), .

+2

Source: https://habr.com/ru/post/1718821/


All Articles