01: package org.apache.ojb.ejb.odmg;
02:
03: import org.apache.ojb.odmg.OJB;
04: import org.odmg.Database;
05: import org.odmg.Implementation;
06: import org.odmg.ODMGException;
07:
08: /* Copyright 2002-2005 The Apache Software Foundation
09: *
10: * Licensed under the Apache License, Version 2.0 (the "License");
11: * you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software
17: * distributed under the License is distributed on an "AS IS" BASIS,
18: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19: * See the License for the specific language governing permissions and
20: * limitations under the License.
21: */
22:
23: /**
24: * Helper class that provide access to the OJB main/access classes.
25: * Nevertheless it is recommended to bind OJB main classes to JNDI and to
26: * lookup the {@link org.odmg.Implementation} instance via JNDI.
27: *
28: * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
29: * @version $Id: ODMGHelper.java,v 1.1.2.2 2005/12/21 22:21:39 tomdz Exp $
30: */
31: public class ODMGHelper {
32: public static final String DEF_DATABASE_NAME = "default";
33: private static Implementation odmg;
34: private static Database db;
35:
36: static {
37: odmg = OJB.getInstance();
38: db = odmg.newDatabase();
39: try {
40: System.out.println("[ODMG] Open new database " + db
41: + " using databaseName name " + DEF_DATABASE_NAME);
42: db.open(DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
43: } catch (ODMGException e) {
44: e.printStackTrace();
45: }
46: }
47:
48: public static Implementation getODMG() {
49: return odmg;
50: }
51:
52: static Database getDatabase() {
53: return db;
54: }
55: }
|