public void lifecycleEvent(LifecycleEvent event) {
if (event.getType() == Lifecycle.BEFORE_STOP_EVENT) {
// The container is getting stopped, close all current connections
Iterator<Request> iterator = cometRequests.iterator();
while (iterator.hasNext()) {
Request request = iterator.next();
// Remove the session tracking attribute as it isn't
// serializable or required.
HttpSession session = request.getSession(false);
if (session != null) {
session.removeAttribute(cometRequestsAttribute);
}
// Close the comet connection
try {
CometEventImpl cometEvent = request.getEvent();
cometEvent.setEventType(CometEvent.EventType.END);
cometEvent.setEventSubType(
CometEvent.EventSubType.WEBAPP_RELOAD);
getNext().event(request, request.getResponse(), cometEvent);
cometEvent.close();
} catch (Exception e) {
container.getLogger().warn(
sm.getString("cometConnectionManagerValve.event"),
e);