package com.udapsoft.waf.system.session;

import java.io.Serializable;

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

import kr.co.hsnc.common.logger.Logger;
import kr.co.hsnc.common.util.ValueObject;
import kr.co.hsnc.j2ee.waf.controller.web.util.WebKeys;

public class SessionListener implements Serializable, HttpSessionListener {

	private static final long serialVersionUID = 6381248715652561212L;

	public SessionListener() {
		super();
	}

	public void sessionCreated(HttpSessionEvent httpSessionEvent) {
		
	}

	public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
		try {
			//SignOnUser Release
			HttpSession session = httpSessionEvent.getSession();
			ValueObject user = (ValueObject)session.getAttribute(WebKeys.SIGNED_ON_USER);
			SignOnSession sessions = SignOnSession.getInstance();
			sessions.delSession(user, session.getId());

		}
		catch(Exception e) {
			Logger.sys.printStackTrace(e);
		}
	}
}
