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: AdminObjectContainer.java,v 1.2 2002/06/08 00:49:39 mediumnet Exp $
008:
009: package org.ozoneDB.core.admin;
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: * @author <a href="http://www.softwarebuero.de/">SMB</a>
019: * @version $Revision: 1.2 $Date: 2002/06/08 00:49:39 $
020: */
021: public class AdminObjectContainer extends AbstractObjectContainer {
022:
023: protected final static long serialVersionUID = 1L;
024:
025: protected Env env;
026:
027: protected OzoneCompatible target;
028:
029: protected ObjectID objID;
030:
031: protected String name;
032:
033: protected Lock lock;
034:
035: protected Permissions permissions;
036:
037: public AdminObjectContainer() {
038: }
039:
040: public AdminObjectContainer(Env _env, OzoneCompatible _target,
041: ObjectID _objID) {
042: state = STATE_CREATED;
043: target = _target;
044: objID = _objID;
045: env = _env;
046: env.logWriter.newEntry(this , "admin container created...",
047: LogWriter.INFO);
048: }
049:
050: public long modTime() {
051: throw new RuntimeException("Not supported: modTime()");
052: }
053:
054: public Class targetClass() {
055: return target.getClass();
056: }
057:
058: public void setTarget(OzoneCompatible _target) {
059: if (target != null) {
060: target.setContainer(null);
061: }
062: target = _target;
063: target.setContainer(this );
064: }
065:
066: public OzoneCompatible target() {
067: return target;
068: }
069:
070: public void touch() {
071: }
072:
073: public Lock lock() {
074: return lock;
075: }
076:
077: public void updateLockLevel(Transaction ta) throws Exception {
078: if (env.logWriter.hasTarget(LogWriter.DEBUG3)) {
079: env.logWriter.newEntry(this , "upgradeLockLevel(): ",
080: LogWriter.DEBUG3);
081: }
082: throw new RuntimeException("Not supported: updateLockLevel()");
083: }
084:
085: public Permissions permissions() {
086: return permissions;
087: }
088:
089: public int lockLevel(Transaction ta) {
090: return lock.level(ta);
091: }
092:
093: public Object invokeTarget(Env env, String methodName, String sig,
094: Object[] args) throws Exception {
095: if (env.logWriter.hasTarget(LogWriter.DEBUG3)) {
096: env.logWriter.newEntry(this , "invokeTarget(): ",
097: LogWriter.DEBUG3);
098: }
099: return super .invokeTarget(env, methodName, sig, args);
100: }
101:
102: public void deleteTarget() {
103: if (env.logWriter.hasTarget(LogWriter.DEBUG3)) {
104: env.logWriter.newEntry(this , "deleteTarget(): ",
105: LogWriter.DEBUG3);
106: }
107: throw new RuntimeException("Not supported: deleteTarget()");
108: }
109:
110: public void nameTarget(String _name) {
111: if (env.logWriter.hasTarget(LogWriter.DEBUG3)) {
112: env.logWriter.newEntry(this , "nameTarget(): ",
113: LogWriter.DEBUG3);
114: }
115: throw new RuntimeException("Not supported: nameTarget()");
116: }
117:
118: public DxCollection allLockers() {
119: throw new RuntimeException("Not supported: allLockers()");
120: }
121:
122: public boolean equals(Object obj) {
123: if (obj != null && obj instanceof AdminObjectContainer) {
124: AdminObjectContainer rhs = (AdminObjectContainer) obj;
125: return objID.equals(rhs.objID);
126: }
127: return false;
128: }
129:
130: public ObjectID id() {
131: return objID;
132: }
133:
134: public String name() {
135: return name;
136: }
137:
138: public void setName(String _name) {
139: name = _name;
140: }
141:
142: /**
143: Pins this ObjectContainer.
144: Every caller of this method must pair this call with a call to {@link #unpin}.
145: An ObjectContainer remains in main memory at least as long as it is pinned.
146: */
147: public void pin() {
148: }
149:
150: /**
151: Unpins this ObjectContainer.
152: This method must be called exactly once for every call to {@link #pin}.
153: */
154: public void unpin() {
155: }
156:
157: /**
158: Returns wether this ObjectContainer is pinned.
159: */
160: public boolean isPinned() {
161: return false;
162: }
163:
164: /**
165: Ensures that the garbageCollectionLevel is at least the given currentGarbageCollectionLevel.
166: The return value is meaningful if the supplied newGarbageCollectionLevel is the currentGarbageCollectionLevel
167:
168: @return
169: <=0 if this object still has to be processed.
170: This is the case if it belongs to the surelyReachable set but not to the processedReachable set
171: > otherwise
172:
173: <0 if this object has been updated
174: =0 if this object has not been updated, it is surelyReachable
175: >0 if this object has not been updated, it is processedReachable
176: */
177: public int ensureGarbageCollectionLevel(
178: int newGarbageCollectionLevel) {
179: return 1;
180: }
181:
182: /**
183: Returns the garbageCollectionLevel this ObjectContainer has reached due to (not) calling {@link #ensureGarbageCollectionLevel}.
184: */
185: public int getGarbageCollectionLevel() {
186: // Hope this will never be called.
187: return 0;
188: }
189: }
|