⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sessionlistener.java

📁 噶额外噶外骨骼感广泛高热感 就 啊啊
💻 JAVA
字号:
/*
 * @author                        : Neelesh
 * @Version                       : 1.0
 *
 * Development Environment        : Oracle9i JDeveloper
 * Name of the Application        : SessionListener.java
 * Creation/Modification History  :
 *
 * Neelesh      27-Mar-2003      Created
 *
 */
package oracle.otnsamples.vsm;

import javax.ejb.EJBObject;

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


/**
 * The session listener class is used to remove references of stateful EJBs in
 * the session explicitly to prevent object leaking from the EJB pool.
 * @author Neelesh
 * @version 1.0
 */
public class SessionListener implements javax.servlet.http.HttpSessionListener {

  private HttpSession session = null;

  /**
   * The method is called by the servlet container just after http session is
   * created. The implementation does nothing.
   *
   * @param <b>event</b> HttpSessionEvent
   */
  public void sessionCreated(HttpSessionEvent event) {
    session = event.getSession();
  }
  /**
   * The method is called by the servlet container just before http session is
   * destroyed. The implementation removes any references of ShoppingCart bean
   *
   * @param <b>event</b> HttpSessionEvent
   */
  public void sessionDestroyed(HttpSessionEvent event) {
    session = event.getSession();

    try {

      // Get the cart EJB
      EJBObject cartEJB = (EJBObject) session.getAttribute("_cart");

      if(cartEJB != null) {

        // remove the object if not null
        cartEJB.remove();
      }
    } catch(Exception ex) {
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -