Hello ,

my problem is how to call getInstance() and release() when JSP page
object is created or destroyed (it's easy with servlet)

Thanks

Monday, December 06, 1999, 10:32:52 AM, you wrote:

LB> Hi,

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

LB> Bertrand

LB> public class PersistenceManager
LB> {

LB>    static private PersistenceManager instance;
LB>    static private int clients;

LB>    private PersistenceManager()
LB>    {
LB>       init();
LB>    }


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

>> -----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]
>>

--
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

Reply via email to