KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > admin > AdminObjectContainer


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: AdminObjectContainer.java,v 1.4 2002/09/18 06:54:16 per_nyfelt Exp $
8

9 package org.ozoneDB.core.admin;
10
11 import org.ozoneDB.DxLib.DxCollection;
12 import org.ozoneDB.OzoneCompatible;
13 import org.ozoneDB.core.*;
14 import org.ozoneDB.util.LogWriter;
15
16
17 /**
18  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
19  * @version $Revision: 1.4 $Date: 2002/09/18 06:54:16 $
20  */

21 public class AdminObjectContainer extends AbstractObjectContainer {
22
23     protected final static long serialVersionUID = 1L;
24
25     protected Env env;
26
27     protected OzoneCompatible target;
28
29     protected ObjectID objID;
30
31     protected String JavaDoc name;
32
33     protected Lock lock;
34
35     protected Permissions permissions;
36
37
38     public AdminObjectContainer() {
39     }
40
41
42     public AdminObjectContainer( Env _env, OzoneCompatible _target, ObjectID _objID ) {
43         state = STATE_CREATED;
44         target = _target;
45         objID = _objID;
46         env = _env;
47         env.logWriter.newEntry( this, "admin container created...", LogWriter.INFO );
48     }
49
50
51     public long modTime() {
52         throw new RuntimeException JavaDoc( "Not supported: modTime()" );
53     }
54
55
56     public Class JavaDoc targetClass() {
57         return target.getClass();
58     }
59
60
61     public void setTarget( OzoneCompatible _target ) {
62         if (target != null) {
63             target.setContainer( null );
64         }
65         target = _target;
66         target.setContainer( this );
67     }
68
69
70     public OzoneCompatible target() {
71         return target;
72     }
73
74
75     public void touch() {
76     }
77
78
79     public Lock lock() {
80         return lock;
81     }
82
83
84     public void updateLockLevel( Transaction ta ) throws Exception JavaDoc {
85         if (env.logWriter.hasTarget( LogWriter.DEBUG3 )) {
86             env.logWriter.newEntry( this, "upgradeLockLevel(): ", LogWriter.DEBUG3 );
87         }
88         throw new RuntimeException JavaDoc( "Not supported: updateLockLevel()" );
89     }
90
91
92     public Permissions permissions() {
93         return permissions;
94     }
95
96
97     public int lockLevel( Transaction ta ) {
98         return lock.level( ta );
99     }
100
101
102     public Object JavaDoc invokeTarget( Env env, String JavaDoc methodName, String JavaDoc sig, Object JavaDoc[] args ) throws Exception JavaDoc {
103         if (env.logWriter.hasTarget( LogWriter.DEBUG3 )) {
104             env.logWriter.newEntry( this, "invokeTarget(): ", LogWriter.DEBUG3 );
105         }
106         return super.invokeTarget( env, methodName, sig, args );
107     }
108
109
110     public void deleteTarget() {
111         if (env.logWriter.hasTarget( LogWriter.DEBUG3 )) {
112             env.logWriter.newEntry( this, "deleteTarget(): ", LogWriter.DEBUG3 );
113         }
114         throw new RuntimeException JavaDoc( "Not supported: deleteTarget()" );
115     }
116
117
118     public void nameTarget( String JavaDoc _name ) {
119         if (env.logWriter.hasTarget( LogWriter.DEBUG3 )) {
120             env.logWriter.newEntry( this, "nameTarget(): ", LogWriter.DEBUG3 );
121         }
122         throw new RuntimeException JavaDoc( "Not supported: nameTarget()" );
123     }
124
125
126     public DxCollection allLockers() {
127         throw new RuntimeException JavaDoc( "Not supported: allLockers()" );
128     }
129
130
131     public boolean equals( Object JavaDoc obj ) {
132         if (obj != null && obj instanceof AdminObjectContainer) {
133             AdminObjectContainer rhs = (AdminObjectContainer)obj;
134             return objID.equals( rhs.objID );
135         }
136         return false;
137     }
138
139
140     public ObjectID id() {
141         return objID;
142     }
143
144
145     public String JavaDoc name() {
146         return name;
147     }
148
149
150     public void setName( String JavaDoc _name ) {
151         name = _name;
152     }
153
154     /**
155         Pins this ObjectContainer.
156         Every caller of this method must pair this call with a call to {@link #unpin}.
157         An ObjectContainer remains in main memory at least as long as it is pinned.
158     */

159     public void pin() {
160     }
161
162     /**
163         Unpins this ObjectContainer.
164         This method must be called exactly once for every call to {@link #pin}.
165     */

166     public void unpin() {
167     }
168
169     /**
170         Returns wether this ObjectContainer is pinned.
171     */

172     public boolean isPinned() {
173         return false;
174     }
175
176     /**
177         Ensures that the garbageCollectionLevel is at least the given currentGarbageCollectionLevel.
178         The return value is meaningful if the supplied newGarbageCollectionLevel is the currentGarbageCollectionLevel
179
180         @return
181             <=0 if this object still has to be processed.
182                 This is the case if it belongs to the surelyReachable set but not to the processedReachable set
183             > otherwise
184
185             <0 if this object has been updated
186             =0 if this object has not been updated, it is surelyReachable
187             >0 if this object has not been updated, it is processedReachable
188     */

189     public int ensureGarbageCollectionLevel(int newGarbageCollectionLevel) {
190         return 1;
191     }
192
193     /**
194         Returns the garbageCollectionLevel this ObjectContainer has reached due to (not) calling {@link #ensureGarbageCollectionLevel}.
195     */

196     public int getGarbageCollectionLevel() {
197         // Hope this will never be called.
198
return 0;
199     }
200 }
201
Popular Tags