001: // You can redistribute this software and/or modify it under the terms of
002: // the Ozone Core License version 1 published by ozone-db.org.
003: //
004: // The original code and portions created by SMB are
005: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006: //
007: // $Id: ClassicStore.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
008:
009: package org.ozoneDB.core.classicStore;
010:
011: import java.io.*;
012: import org.ozoneDB.DxLib.*;
013: import org.ozoneDB.*;
014: import org.ozoneDB.core.*;
015: import org.ozoneDB.util.*;
016:
017: /**
018: * ClassicStore acts as the mediator (director) of the classicStore module
019: * especially for ClusterSpace, ObjectSpace, PersistentSpace. Currently it
020: * serves only as container for the references but this should change in the
021: * future to decouple class implementations.
022: */
023: public final class ClassicStore extends Object implements Store {
024: /** */
025: protected Env env;
026: protected ObjectSpace objectSpace;
027:
028: /** */
029: public ClassicStore() {
030: }
031:
032: /** */
033: public void init(Env _env) {
034: env = _env;
035: objectSpace = new ObjectSpace(_env);
036: }
037:
038: /** */
039: public void startup() throws Exception {
040: env.logWriter.newEntry(this , "startup...", LogWriter.INFO);
041: objectSpace.startup();
042: }
043:
044: /** */
045: public void shutdown() throws Exception {
046: env.logWriter.newEntry(this , "shutdown...", LogWriter.INFO);
047: objectSpace.shutdown();
048: }
049:
050: /** */
051: public ObjectContainer newContainer(Transaction ta,
052: OzoneCompatible target, ObjectID objID,
053: Permissions permissions) throws Exception {
054: return objectSpace.newContainer(ta, target, objID, permissions);
055: }
056:
057: /** */
058: public ObjectContainer containerForID(Transaction ta, ObjectID id)
059: throws Exception {
060: return objectSpace.objectForID(id);
061: }
062:
063: /**
064: * @param name The object name to search for.
065: * @param ta
066: * @return The object container for the name or null.
067: */
068: public ObjectContainer containerForName(Transaction ta, String name)
069: throws Exception {
070: return objectSpace.objectForName(name);
071: }
072:
073: /**
074: * @param ta
075: * @param container
076: * @param name
077: */
078: public void nameContainer(Transaction ta,
079: ObjectContainer container, String name)
080: throws PermissionDeniedExc {
081: try {
082: objectSpace.nameObject(container, name);
083: } catch (ClassicStoreExc e) {
084: throw new PermissionDeniedExc(e.toString());
085: }
086: }
087:
088: /** */
089: public void join(Transaction ta, ObjectContainer container,
090: int lockLevel) throws Exception {
091: //System.out.println ("join: " + container.id());
092: ClassicObjectContainer classicCon = (ClassicObjectContainer) container;
093: classicCon.upgradeLockLevel(ta, lockLevel);
094: ta.idTable.addForKey(classicCon, classicCon.id());
095: }
096:
097: /**
098: * @param ta Transaction that will be commited.
099: */
100: public void prepareCommitTransaction(Transaction ta)
101: throws Exception {
102: objectSpace.prepareCommitObjects(ta);
103: }
104:
105: /** */
106: public void commitTransaction(Transaction ta) {
107: objectSpace.commitObjects(ta);
108: }
109:
110: /**
111: * @param ta ID of the comitting transaction.
112: * @param created
113: * @param modified
114: */
115: public void abortTransaction(Transaction ta) {
116: try {
117: objectSpace.abortObjects(ta);
118: } catch (Exception e) {
119: env.logWriter.newEntry(this , "Abort of transaction "
120: + ta.taID() + " failed !\n" + e, LogWriter.ERROR);
121: }
122: }
123:
124: /** */
125: public void upgradeLockLevel(Transaction ta,
126: ObjectContainer container, int lockLevel) throws Exception {
127: ((ClassicObjectContainer) container).upgradeLockLevel(ta,
128: lockLevel);
129: }
130: }
|