How can I reach JSF @Singleton Bean from inside @SessionScoped Bean and vice versa?

121 views Asked by At

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!

1

There are 1 answers

0
Mr_Thorynque On

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.