• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

access FacesContext from JMX NotificationListener

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi;
I have a JSF web application that has a JMX notification listener, I have a Comet Component that is updating a webpage om certain events, but I need to update a certain value in the page when a JMX Server sends the JMX client embedded in my web app a certain notification. I'm receiving the notification but I do not have access to the FacesContext to retrieve the session-scoped backbean (which contains the Comet Channel) from session.

please can anyone help me?

note: I tried to store the FacesContext current instance in a statix global variable, bu when I try to use it I got an exception that this instance must be released before being candidate to use again
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Tammam!

I see 2 problems here. First, JMX MBeans aren't supposed to be application components. They're supposed to be components that manage and monitor other components.

Secondly, and more seriously, the FacesContext is not a durable datastructure. Not only can you not cache it, it doesn't even exist at all, most of the time!

A FacesContext is constructed when a JSF URL request comes in. Each request gets its very own FacesContext custom-built to handle that request. The FacesContext is the repository for JSF internal information needed to process the request and generate the response to the request. Once that response has been generated and sent back to the client, that particular FacesContext is destroyed. If you attempt to cache it, you'll end up with a component whose contents are obsolete, incorrect, and otherwise useless.

You could create a JSF View that accesses an MBean, as far as it goes, but the reverse is not true.
 
reply
    Bookmark Topic Watch Topic
  • New Topic