0

My purpose is to have a @Singleton class which runs automated scheduled methods throughout the application on a cloud server. But I also have @SessionScoped beans which I would like to communicate with. Is it possible to reach a @SessionScoped bean if I'm not in a user's web-session and the reverse: How can I use my @Singleton Bean as a user from my session?

Thanks and best regards!

v-peter
  • 1
  • 2

1 Answers1

1

You can reach Singleton Bean in SessionScoped Bean using application context to get Singleton bean or maybe injection in SessionScoped Bean.

context.getBean(SomeSingletonClass.class)

To do the reverse, there is no good way, you can put sessions in list of WeakReference inside se Singleton bean.

Mr_Thorynque
  • 1,749
  • 1
  • 20
  • 31