![]() Sounds like a lot of work? It’s actually not as bad as you would think, and gives us the power to ensure our resources are cleaned up if the browser is closed.įirst, we implement the DisposableBean interface (which is an ICEFaces interface that is included with the framework as of version 1.7) to our Bean class. jspx page to listen for the browser close event and navigate to the “Logout” URL, which will run our Logout servlet code. Add a Logout servlet that will call the dispose() method on any or all of the managed beans we want to clean up.Implement the DisposableBean interface, which includes overriding the dispose() method and adding our logic to cleanup our bean there. ![]() Let’s make the following changes to our Bean class: This is where DisposableBean interface comes in. When that browser window closes I wanted to run some clean up code. However, after I run my process, which could take up to 2 hours, and I close my browser window, I’m left with a session object that is going to be laying around for potentially longer (depending on how long the session timeout is set for). Great! This gives us our list for what we’re trying to accomplish. So let’s say I have a simple session-scoped managed bean as such: What this interfaces does is define one method (dispose()) that gets called when the session is invalidated, either naturally or by application code. Since ICEFaces 1.7, they have included an interface with their framework called DisposableBean. I’m using JSF 1.2, ICEFaces 1.8, and Tomcat 6.0. After a morning or so of research, however, I have an implementation that I like and seems to be working. The second one, however, proved to be quite the task in nailing down so it worked to my satisfaction. The first one is somewhat trivial, in that JSF manages a lot of that bean clean up for us. The user closes their internet browser.I wanted to have a mechanism in place for cleanup code to executed in the following two cases: Why do I need to wait for 2 hours to invalidate that session if the user is done and back to surfin' the net after 5 minutes?! Let’s say they only want to run a very tiny file, like 10 MB, and this only takes 5 minutes to run. Let’s say 2 hours, to ensure we can get through a really large file, if need be. ![]() In order to assure that the process finishes to completion we want to set our session timeout to be something longer than that. Let’s say this process takes upwards of 45 minutes - 1 hour to complete, depending on the input file. ![]() Fairly straightforward back end logic, maybe aggregate a column on the file and write the total to a SQL database somewhere. Say, power through a 2GB file and run some processing on each record. Your user has this web application that runs a data process. ICEFaces DisposableBean and Cleaning Up Session Resources Thu, Aug 20, 2009 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |