D. How to customize a UWS ?
9. The interface HttpSessionBindingEvent
- This part of the documentation is useful only if you put any instance of AbstractUWS subclass in a session (so it is stored in the navigator of the client).
- A better way to keep your UWS in state is to use saveUWs and restoreUWS of UWSToolBox. See the part E. UWS Tools-Box.
When a session is finishing the contained UWS is not accessible anymore through a servlet. It can cause some problems. Indeed if all jobs of the previous session are still running, they continue to hold resources and so the performances of your computer are decreasing.
In order to clear all UWS resources (stop threads and timers, delete files, ...) when a session is finishing, the class AbstractUWS implements the interface HttpSessionBindingListener. This interface contains two methods:
- valueBound(HttpSessionBindingEvent): called when the UWS is added as attribute of a session.
- valueUnbound(HttpSessionBindingEvent): called when the UWS is removed from a session.
These two methods are already implemented but can be overrided. By default valueBound(HttpSessionBindingEvent) does nothing except printing a message. valueUnbound(HttpSessionBindingEvent) calls the method removeAllJobLists() which calls the method clearResources() for all Jobs of all managed JobLists.