KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > YapObjectCarrier


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o;
22
23 import com.db4o.config.*;
24 import com.db4o.ext.*;
25 import com.db4o.inside.convert.*;
26 import com.db4o.types.*;
27
28 /**
29  * no reading
30  * no writing
31  * no updates
32  * no weak references
33  * navigation by ID only both sides need synchronised ClassCollections and
34  * MetaInformationCaches
35  *
36  * @exclude
37  */

38 public class YapObjectCarrier extends YapMemoryFile {
39     
40     YapObjectCarrier (Configuration config,YapStream a_callingStream, MemoryFile memoryFile) {
41         super(config,a_callingStream, memoryFile);
42     }
43     
44     protected void initialize1(Configuration config){
45         i_handlers = i_parent.i_handlers;
46         _classCollection = i_parent.classCollection();
47         i_config = i_parent.configImpl();
48         i_references = new YapReferences(this);
49         initialize2();
50     }
51     
52     void initialize2NObjectCarrier(){
53         // do nothing
54
}
55     
56     void initializeEssentialClasses(){
57         // do nothing
58
}
59     
60     void initialize4NObjectCarrier(){
61         // do nothing
62
}
63     
64     void initNewClassCollection(){
65         // do nothing
66
}
67     
68     boolean canUpdate(){
69         return false;
70     }
71     
72     void configureNewFile() {
73         // do nothing
74
}
75     
76     public int converterVersion() {
77         return Converter.VERSION;
78     }
79         
80     public boolean close() {
81         
82         // TODO: An object carrier can simply be gc'd.
83
// It does not need to be cleaned up.
84

85         synchronized (i_lock) {
86             boolean ret = close1();
87             if (ret) {
88                 i_config = null;
89             }
90             return ret;
91         }
92     }
93     
94     final public Transaction newTransaction(Transaction parentTransaction) {
95         if (null != parentTransaction) {
96             return parentTransaction;
97         }
98         return new TransactionObjectCarrier(this, null);
99     }
100     
101     public long currentVersion(){
102         return 0;
103     }
104     
105     public Db4oType db4oTypeStored(Transaction a_trans, Object JavaDoc a_object) {
106         return null;
107     }
108     
109     public boolean dispatchsEvents() {
110         return false;
111     }
112     
113     protected void finalize() {
114         // do nothing
115
}
116     
117     
118     public final void free(int a_address, int a_length){
119         // do nothing
120
}
121     
122     public int getSlot(int length){
123         return appendBlocks(length);
124     }
125     
126     public Db4oDatabase identity() {
127         return i_parent.identity();
128     }
129     
130     public boolean maintainsIndices(){
131         return false;
132     }
133     
134     void message(String JavaDoc msg){
135         // do nothing
136
}
137     
138     public void raiseVersion(long a_minimumVersion){
139         // do nothing
140
}
141     
142     void readThis(){
143         // do nothing
144
}
145     
146     boolean stateMessages(){
147         return false; // overridden to do nothing in YapObjectCarrier
148
}
149     
150     public void write(boolean shuttingDown) {
151         checkNeededUpdates();
152         writeDirty();
153         getTransaction().commit();
154     }
155     
156     final void writeHeader(boolean shuttingDown) {
157         // do nothing
158
}
159     
160     protected void writeVariableHeader(){
161         
162     }
163
164
165 }
Popular Tags