java - How to invoke a method in @SessionScoped bean from @ApplicationScoped bean -
Is there a way that I can get a context for the session @ session bean and an @ Can I call a method?
BeanManager.getContext ()
works during a request, but it seems that it is not outside of a request. I keep a list of active HttpsSessions in the GlobalHttpSessionController
, but it does not seem to be of any help Thanks to your comments.
@ Application public class MyAppScopedClass {@ Injection GlobalHttpSessionController globalHttpSessionController; @beenmanager bean manager; Public Zero updateSessions () {// List of active user sessions list & lt; Http session & gt; Session = global HTCController (.); Set up & lt; Bean & lt ;? & Gt; & Gt; Set = Bean Manager. Gatebens (User Bean Class); (Bean Bean: Set) ((User Session) Bean Manager.Tettext (Bean Getscope ()). (Bean, Bean Manager. Content Consortal Contex (Bean))). Method (); }}}
You can try to mimic Spring MVC when you have a In singleton scod bean inject a session squanded
, it injects a proxy that uses bean in the current session. Because without it, you get a bean at the time you created the bean made app and only access it.
Edit:
It seems that it is not easy to actually remove a session bean (this happens when its session is not active). So you should store Bean as a session attribute in order to easily get it recovered as a reference.
But I think what you need event management. Unfortunately, I have never used it in the Java EE CDI environment.
Comments
Post a Comment