0

All. I looked through web but didn't find applicable solution for me.

I need to access information, from globalsession scoped beans in HttpSessionListener , before the session is destroyed.

I found one solution, after inspecting session attributes, but it doesn't seems smooth:

MyBean myBean = httpSessionEvent.getSession().getAttribute("scopedTarget."+"myBeanImlp");

I also have singleton beans, containing session beans via target+proxy, but getting them in sessionDestroyed via ctx.getBean("mySingletonBean"), the reference to session bean is invalid inside them (session bean was already destroyed before sessionDestroyed call)

Does anybody know good and proper solution for such problem?

I'm thinking we need something like DestructionAwareBeanPostProcessor, but for session beans, where I could look through beans, ready for destroy and take an action I need.

Java Devil
  • 10,629
  • 7
  • 33
  • 48
vasekaa
  • 1
  • 1

1 Answers1

0

You can try to define your session listener as a component and inject ApplicationContext (or required bean) and then access it. You can take a look at How to inject dependencies into HttpSessionListener, using Spring?

Community
  • 1
  • 1
Stan
  • 1,410
  • 10
  • 14