using ODMG as a singleton

2003-03-07 Thread Will Jaynes
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;
}
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: using ODMG as a singleton

2003-03-07 Thread Armin Waibel
Hi Will,

- Original Message -
From: Will Jaynes [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





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