Hi Thomas,

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 25, 2002 6:32 PM
Subject: threadsafe odmg without C/S-architecture?


> Hello,
>
> I'd like to use OJB/ODMG in a tomcat environement without using the
> ojb-C/S-architecture.
>
> Is the following servlet threadsafe?  (I mean the doGet()-method, not
the
> init()-method).
> #################################################
> public class gaga extends HttpServlet {
>     static Implementation odmg ;
>     static Database db ;
>
>     public void init(ServletConfig config) throws ServletException {
>         super.init(config);
>         if
l){        
> this.odmg = OJB.getInstance(); 
>         this.db = odmg.newDatabase(); 
###
            this.db.open(myRepository);
>        }
>     }
>     
>     protected void doGet(HttpServletRequest request, HttpServletResponse
> response)
>     throws ServletException, java.io.IOException {
>             Transaction tx = odmg.newTransaction();
>             tx.begin();
>             /* do the interesting things*/
>             tx.commit();
>     }
> }
> ################################################
> 
> If yes, is it a good solution?

Yes, this should be threadsafe.
But don't forget to open the database in the init method.
In my opinion it's a good solution.

By the way, changing the database within the doGet-method
would not be thread-safe.

regards,
Armin


> 
> If no, is there a threadsafe version for my servlet?
> 
> Thanks a lot for any help
> 
> Thomas
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 
> 



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to