Hi,

I don't know if it can help, but have a look at the code below.  It provides
you a way to have a single PersistenceManager on the server and to track the
number of clients

Bertrand

public class PersistenceManager
{

   static private PersistenceManager instance;
   static private int clients;

   private PersistenceManager()
   {
      init();
   }


   static synchronized public PersistenceManager getInstance()
   {
      if (instance == null)
      {
         instance = new PersistenceManager();
      }
      clients++;
      return instance;
   }
...
 public synchronized void release()
   {
      // Wait until called by the last client
      if (--clients != 0)
      {
         return;
      }
...

> -----Original Message-----
> From: heyhey [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, December 06, 1999 11:43 AM
> To:   [EMAIL PROTECTED]
> Subject:      tracking initialization and destruction of JSP objects
>
> Hello ,
>
> I am developing JSP system that works with some persistent data on the
> server. I don't wont to fix the persistence mechanism - persistence
> engine should be easily replaced with another one (DBManager,
> FileManager, XMLManager) - and my problem is that I don't know how to
> implement the initialization / destruction of the Persistent Manager
> object
>
> the ideal solution would be
> // pseudo JSP page code
> <some code that will be invoked when new JSP object is initialized -
>   will initialize the PersistenceEngine or increment a counter>
> <some code that will be invoked when this JSP object is destroyed
>   will decrement the counter and destroy the PersistenceEngine if
>   counter == 0>
>
> ....
> normal code that handles JSP page request // we know that the
> persistence engine is initialized
> ...
>
> (I have working prototype with Servlets, but generating complex
> dynamic web pages from servlet is ... simple nightmare :(
>
> there  is  probably  some  very simple (standard) solution, but I work
> with JSP only for three days ...
>
> Thank you :) and excuse my English.
>
> --
> Best regards,
>  heyhey                          mailto:[EMAIL PROTECTED]
>
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to