You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Will Jaynes <ja...@umich.edu> on 2003/03/07 15:37:46 UTC
using ODMG as a singleton
Is it proper to use ODMG as a singleton in my web application? I have
the following class (brief version) that gets the ODMG Implementation
object once, and opens the database once. From then on I simply call
OjbDAOFactory.getODMG().
Is this a safe and proper way to do things? If not, what would be a
better usage? Thanks.
public class OjbDAOFactory
{
static Implementation odmg;
static Database db;
static {
try {
odmg = OJB.getInstance();
db = odmg.newDatabase();
db.open("default", Database.OPEN_READ_WRITE);
} catch (ODMGException ex) {
LOGGER.error("", ex);
}
}
public static Implementation getODMG()
{
return odmg;
}
Re: using ODMG as a singleton
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Will,
----- Original Message -----
From: "Will Jaynes" <ja...@umich.edu>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Friday, March 07, 2003 3:37 PM
Subject: using ODMG as a singleton
> Is it proper to use ODMG as a singleton in my web application? I have
> the following class (brief version) that gets the ODMG Implementation
> object once, and opens the database once. From then on I simply call
> OjbDAOFactory.getODMG().
>
> Is this a safe and proper way to do things?
I don't see any problems (as long as only
one Database was used).
regards,
Armin
> If not, what would be a
> better usage? Thanks.
>
>
> public class OjbDAOFactory
> {
> static Implementation odmg;
> static Database db;
> static {
> try {
> odmg = OJB.getInstance();
> db = odmg.newDatabase();
> db.open("default", Database.OPEN_READ_WRITE);
> } catch (ODMGException ex) {
> LOGGER.error("", ex);
> }
> }
> public static Implementation getODMG()
> {
> return odmg;
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>