public class IlvComponentSessionAttribute extends Object implements javax.servlet.http.HttpSessionBindingListener
IlvComponentSessionAttribute
class acts as a proxy for a
GUI component bound to an HttpSession
. When you bind a GUI
component as an attribute of an HttpSession
, proper cleanup of
the component must occur when the session is invalidated or expires. This
allows the component to be garbage collected or restored to a pool of available
components, depending on your choice of strategies. Instead of binding the
component directly to the session, use an instance of this class as a proxy:
When all the sessions that the proxy and its component are associated with expire, theComponent component = null; HttpSession session = request.getSession(); if (session.isNew()) { component = ... create new or fetch from pool ... IlvComponentSessionAttribute proxy = new IlvComponentSessionAttribute(component); session.setAttribute(COMP_KEY, proxy); } else { IlvComponentSessionAttribute proxy = (IlvComponentSessionAttribute)session.getAttribute(COMP_KEY); if (proxy != null) component = proxy.getComponent(); } if (component == null) throw new ServletException("session problem");
componentUnbound()
method of the proxy will be invoked. You
can override this method to customize your strategy for handling components
that are no longer associated with any sessions.Constructor and Description |
---|
IlvComponentSessionAttribute(Component component)
Creates an
IlvComponentSessionAttribute proxy for the
specified component. |
Modifier and Type | Method and Description |
---|---|
protected void |
componentUnbound()
This method is automatically invoked when the proxy is unbound from its
last HTTP session.
|
Component |
getComponent()
Returns the proxy component.
|
void |
valueBound(javax.servlet.http.HttpSessionBindingEvent event)
This method is automatically invoked when the proxy is bound to an HTTP
session.
|
void |
valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
This method is automatically invoked when the proxy is unbound from an HTTP
session.
|
public IlvComponentSessionAttribute(Component component)
IlvComponentSessionAttribute
proxy for the
specified component.component
- The component.public Component getComponent()
protected void componentUnbound()
Window
it may have been added to, and disposes the window. Subclasses can
override this method to provide specialized cleanup of the proxy component.public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
Warning: This method is considered to be part of an
IlvComponentSessionAttribute
's internal implementation and is
not a public API.
valueBound
in interface javax.servlet.http.HttpSessionBindingListener
public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
componentUnbound()
method instead.
Warning: This method is considered to be part of an
IlvComponentSessionAttribute
's internal implementation and is
not a public API.
valueUnbound
in interface javax.servlet.http.HttpSessionBindingListener
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.