KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > readonly > InTransactionBaseImageReadOnly


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.se.impl.readonly;
25
26 import org.objectweb.jalisto.se.api.*;
27 import org.objectweb.jalisto.se.api.physical.PluggablePhysicalFileAccess;
28 import org.objectweb.jalisto.se.api.internal.*;
29 import org.objectweb.jalisto.se.impl.InFileAddress;
30 import org.objectweb.jalisto.se.JalistoFactory;
31
32 import java.util.Collection JavaDoc;
33 import java.util.Map JavaDoc;
34
35 public class InTransactionBaseImageReadOnly implements InTransactionBaseImage {
36
37     public InTransactionBaseImageReadOnly(PluggablePhysicalFileAccess physicalAccess, JalistoProperties properties) {
38         this.readObjects = JalistoFactory.getInternalFactory().getCache(properties,
39                                                           properties.getPageCacheSize(),
40                                                           "inTransactionBaseImageCache");
41         this.physicalAccess = physicalAccess;
42         this.keepInMemory = properties.isKeepingInMemory();
43     }
44
45     public boolean isWorking() {
46         return false;
47     }
48
49     public boolean startWorking() {
50         return true;
51     }
52
53     public void stopWorking() {
54     }
55
56     public void begin() {
57     }
58
59     public synchronized void commit() {
60         if (!keepInMemory) {
61             readObjects.clear();
62         }
63     }
64
65     public synchronized void rollback() {
66         if (!keepInMemory) {
67             readObjects.clear();
68         }
69     }
70
71     public synchronized JalistoObject readFileObjectAt(InFileAddress ifa) {
72         String JavaDoc address = ifa.getAddress();
73         JalistoObject result = (JalistoObject) readObjects.get(address);
74         if (result != null)
75             return result;
76         result = physicalAccess.readFileObjectAt(ifa);
77         readObjects.put(address, result);
78         return result;
79     }
80
81     public Map JavaDoc getReadObjects() {
82         return readObjects;
83     }
84
85     public boolean isKeepInMemory() {
86         return keepInMemory;
87     }
88
89     public void setKeepInMemory(boolean keepInMemory) {
90         this.keepInMemory = keepInMemory;
91     }
92
93
94     public void deleteFileObject(InFileAddress ifa) {
95         throw new UnsupportedOperationException JavaDoc();
96     }
97
98     public int getDeletedObjectsSize() {
99         throw new UnsupportedOperationException JavaDoc();
100     }
101
102     public int getModifiedObjectsSize() {
103         throw new UnsupportedOperationException JavaDoc();
104     }
105
106     public int getNewObjectsSize() {
107         throw new UnsupportedOperationException JavaDoc();
108     }
109
110     public void insertFileObject(InFileAddress ifa, JalistoObject fo) {
111         throw new UnsupportedOperationException JavaDoc();
112     }
113
114     public void updateFileObject(InFileAddress ifa, JalistoObject fo) {
115         throw new UnsupportedOperationException JavaDoc();
116     }
117
118     public Collection JavaDoc getKeysStartingWith(String JavaDoc filter, boolean withOrder) {
119         return physicalAccess.getKeysStartingWith(filter);
120     }
121
122     private Map JavaDoc readObjects;
123     private PluggablePhysicalFileAccess physicalAccess;
124     private boolean keepInMemory;
125 }
126
Popular Tags