/*
 * Created on 2004-8-14
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package workflow.client.listener;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import workflow.services.WorkflowSession;

/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */

/*
<!-- Listeners -->
<listener>
<listener-class>
workflow.client.listener.WorkflowClientDestroyer
</listener-class>
</listener>
*/

public final class WorkflowClientDestroyer implements HttpSessionListener
{ 
	/**
	 * Record the fact that a session has been created.
	 *
	 * @param event The session event
	 */
	public void sessionCreated(HttpSessionEvent event)
	{
	}

	/**
	 * Record the fact that a session has been destroyed.
	 *
	 * @param event The session event
	 */
	public void sessionDestroyed(HttpSessionEvent event)
	{
		HttpSession session=event.getSession();
		WorkflowSession workflowSession=(WorkflowSession)session.getAttribute(Constants.WORKFLOW_CLIENT_SESSION);
		if(workflowSession!=null)
		{
			session.removeAttribute(Constants.WORKFLOW_CLIENT_SESSION);
			workflowSession.invalidate();
		}
	}

}