try myXYZ.remove(), the container will remove the bean whenever it get to
it. 
( there is no guarantee that the container will do it right away !!)

> -----Original Message-----
> From: Dean Hutchins [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, February 01, 2001 8:43 AM
> To:   Orion-Interest
> Subject:      Removing Stateful Session Beans
> 
> Hello,
> 
> I am using Orion 1.3.8.  I have created a stateful session bean reference
> in
> a JSP and saved the reference in the session.  My problem is that the
> session bean doesn't timeout and I can't determine a method for removing
> the
> bean.  I have tried to create a class implementing the
> HttpSessionBindingListener in the hopes that I could call remove() on the
> reference at this point, but the unbound function isn't called when the
> session is invalidated.  I noticed that a bug has been reported concerning
> the fact that the timeout doesn't seem to be working starting in version
> 1.3.8.  I've included some sample code snippets below for reference.  Any
> help on a method for removing these beans when the session invalidates
> would
> be much appreciated.
> 
> Thanks,
> Dean
> 
> Sample JSP code:
> 
> <html>
> <head><title>Test Session Page</title></head>
> <body>
> Session = <%=session.getId() %>
> <ejb:useHome id="home" 
>              type="test.ejb.XYZHome" 
>              location="java:comp/env/ejb/XYZ" />
> <%
>     test.ejb.XYZ myXYZ = (test.ejb.XYZ)
> session.getAttribute("SESSION_XYZ");
>     if (myXYZ == null) {
>        System.out.println("creating and saving session bean");
>        myXYZ = home.create();
>        session.setAttribute("SESSION_XYZ", myXYZ);
>     } else {
>        myXYZ = (test.ejb.XYZ) session.getAttribute("SESSION_XYZ");
>     }
> %>
> </body>
> </html>
> 
> Bean Segment (note I've also tried a separate class than only implemented
> HttpSessionBindingListener and it doesn't get called):
> 
> public class XYZBean extends Object
> implements SessionBean, HttpSessionBindingListener {
>     private SessionContext ivContext;           // CLient specific context
>     private Hashtable ivXYZs = null;                // Client Specific
> State
> 
>     
>     public void valueBound(HttpSessionBindingEvent event) { 
>     } 
>     public void valueUnbound(HttpSessionBindingEvent event) { 
>       System.out.println("In the unbound function");
>       try {
>           ivContext.getEJBObject().remove();
>       }
>       catch (Exception e) {
>           e.printStackTrace();
>       }
>     } 
>       etc...
> 

------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE: If you have received this e-mail in error, please immediately 
notify the sender by e-mail at the address shown.  This e-mail transmission may 
contain confidential information.  This information is intended only for the use of 
the individual(s) or entity to whom it is intended even if addressed incorrectly.  
Please delete it from your files if you are not the intended recipient.  Thank you for 
your compliance.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Reply via email to