public class IlvComponentSessionAttribute extends Object implements jakarta.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(jakarta.servlet.http.HttpSessionBindingEvent event)
This method is automatically invoked when the proxy is bound to an HTTP
session.
|
void |
valueUnbound(jakarta.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(jakarta.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 jakarta.servlet.http.HttpSessionBindingListener
public void valueUnbound(jakarta.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 jakarta.servlet.http.HttpSessionBindingListener
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.