• 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

Hooking Beans Based on Scope

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we hook beans so that when they are about to go out of scope that we can name a callback function to be executed first?

Thanks
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not beans themselves, no. A bean is something that can (in theory) be a member of more than one collection, although obviously putting a bean in both the session and request collections is a little silly. What you can do, however, is set up a listener to the collection itself. For example, when the session is destroyed, a session listener is a clue that all the beans in the session are going out of scope, since the scope itself is being destroyed. Beans don't just evaporate, so that's usually sufficient unless you have code that's manually inserting/removing beans.
 
Dennis Hopfer
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim. Is this the class I should be messing with:

http://download.oracle.com/javaee/6/api/javax/servlet/http/HttpSessionListener.html


Appears someone else was using it over here:

https://coderanch.com/t/210736/JSF/java/HttpSessionListener-JSF-App
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep. It's popular for that kind of stuff.
 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic