KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > trading > db > pse > PSEDatabaseMgr


1
2 // Copyright (C) 1998-1999
3
// Object Oriented Concepts, Inc.
4

5 // **********************************************************************
6
//
7
// Copyright (c) 1997
8
// Mark Spruiell (mark@intellisoft.com)
9
//
10
// See the COPYING file for more information
11
//
12
// **********************************************************************
13

14 package org.jacorb.trading.db.pse;
15
16 import java.io.*;
17 import COM.odi.*;
18 import org.jacorb.trading.db.DatabaseMgr;
19 import org.jacorb.trading.db.OfferDatabase;
20 import org.jacorb.trading.db.TypeDatabase;
21 import org.jacorb.trading.db.pse.offers.OfferDatabaseImpl;
22 import org.jacorb.trading.db.pse.types.TypeDatabaseImpl;
23 import org.jacorb.trading.db.pse.util.TransactionMgr;
24
25
26 public class PSEDatabaseMgr implements DatabaseMgr
27 {
28   private TransactionMgr m_txnMgr;
29   private OfferDatabaseImpl m_offerDb;
30   private TypeDatabaseImpl m_typeDb;
31
32
33   protected PSEDatabaseMgr()
34   {
35   }
36
37
38   public PSEDatabaseMgr(String JavaDoc dirPath)
39   {
40     COM.odi.ObjectStore.initialize(null, null);
41
42     String JavaDoc dbPath = dirPath + File.separator + "jtrader.odb";
43     Database db = null;
44
45     try {
46       db = Database.open(dbPath, ObjectStore.OPEN_UPDATE);
47     }
48     catch (DatabaseNotFoundException e) {
49       db = Database.create(dbPath,
50         ObjectStore.ALL_READ | ObjectStore.ALL_WRITE);
51     }
52
53     if (db == null) {
54       System.out.println("Unable to create database: " + dbPath);
55       System.exit(1);
56     }
57
58     m_txnMgr = new TransactionMgr();
59     m_offerDb = new OfferDatabaseImpl(db, m_txnMgr);
60     m_typeDb = new TypeDatabaseImpl(db, m_txnMgr);
61   }
62
63
64   public OfferDatabase getOfferDatabase()
65   {
66     return m_offerDb;
67   }
68
69
70   public TypeDatabase getTypeDatabase()
71   {
72     return m_typeDb;
73   }
74
75
76   public void shutdown()
77   {
78     COM.odi.ObjectStore.shutdown(true);
79   }
80 }
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Popular Tags