cziegeler 02/03/28 01:56:58 Modified: src/java/org/apache/cocoon/components/store FilesystemStore.java MRUMemoryStore.java MemoryStore.java Log: Paranoid synchronization fix Revision Changes Path 1.14 +10 -10 xml-cocoon2/src/java/org/apache/cocoon/components/store/FilesystemStore.java Index: FilesystemStore.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/store/FilesystemStore.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- FilesystemStore.java 8 Mar 2002 04:09:59 -0000 1.13 +++ FilesystemStore.java 28 Mar 2002 09:56:58 -0000 1.14 @@ -73,7 +73,7 @@ * * @author ? * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> - * @version CVS $Id: FilesystemStore.java,v 1.13 2002/03/08 04:09:59 vgritsenko Exp $ + * @version CVS $Id: FilesystemStore.java,v 1.14 2002/03/28 09:56:58 cziegeler Exp $ */ public final class FilesystemStore extends AbstractLoggable @@ -173,7 +173,7 @@ /** * Get the File object associated with the given unique key name. */ - public Object get(final Object key) { + public synchronized Object get(final Object key) { final File file = fileFromKey(key); if (file != null && file.exists()) { @@ -200,7 +200,7 @@ * 2) String values are dumped to text files * 3) Object values are serialized */ - public void store(final Object key, final Object value) + public synchronized void store(final Object key, final Object value) throws IOException { final File file = fileFromKey(key); @@ -232,7 +232,7 @@ /** * Holds the given object in a volatile state. */ - public void hold(final Object key, final Object value) + public synchronized void hold(final Object key, final Object value) throws IOException { this.store(key, value); final File file = (File) this.fileFromKey(key); @@ -244,7 +244,7 @@ /** * Remove the object associated to the given key. */ - public void remove(final Object key) { + public synchronized void remove(final Object key) { final File file = fileFromKey(key); if (file != null) { file.delete(); @@ -254,7 +254,7 @@ /** * Indicates if the given key is associated to a contained object. */ - public boolean containsKey(final Object key) { + public synchronized boolean containsKey(final Object key) { final File file = fileFromKey(key); if (file == null) { return false; @@ -265,7 +265,7 @@ /** * Returns the list of stored files as an Enumeration of Files */ - public Enumeration keys() { + public synchronized Enumeration keys() { final FSEnumeration enum = new FSEnumeration(); this.addKeys(enum, this.directoryFile); return enum; @@ -275,7 +275,7 @@ * Returns count of the objects in the store, or -1 if could not be * obtained. */ - public int size() { + public synchronized int size() { return countKeys(this.directoryFile); } @@ -353,9 +353,9 @@ return null; } - public void free() {} + public synchronized void free() {} - public Object getObject(final Object key) + public synchronized Object getObject(final Object key) throws IOException, ClassNotFoundException { final File file = (File) this.fileFromKey(key); 1.15 +9 -9 xml-cocoon2/src/java/org/apache/cocoon/components/store/MRUMemoryStore.java Index: MRUMemoryStore.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/store/MRUMemoryStore.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- MRUMemoryStore.java 8 Mar 2002 04:09:59 -0000 1.14 +++ MRUMemoryStore.java 28 Mar 2002 09:56:58 -0000 1.15 @@ -80,7 +80,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Gerhard Froehlich</a> * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> - * @version CVS $Id: MRUMemoryStore.java,v 1.14 2002/03/08 04:09:59 vgritsenko Exp $ + * @version CVS $Id: MRUMemoryStore.java,v 1.15 2002/03/28 09:56:58 cziegeler Exp $ */ public final class MRUMemoryStore extends AbstractLoggable @@ -180,7 +180,7 @@ * @param key The key for the object to store * @param value The object to store */ - public void store(Object key, Object value) { + public synchronized void store(Object key, Object value) { this.hold(key,value); } @@ -192,7 +192,7 @@ * @param key The key of the object to be stored * @param value The object to be stored */ - public void hold(Object key, Object value) { + public synchronized void hold(Object key, Object value) { if (getLogger().isDebugEnabled()) { getLogger().debug("Holding object in memory:"); getLogger().debug(" key: " + key); @@ -215,7 +215,7 @@ * @param key The key of the requested object * @return the requested object */ - public Object get(Object key) { + public synchronized Object get(Object key) { Object value = this.cache.get(key); if (value != null) { /** put the accessed key on top of the linked list */ @@ -255,7 +255,7 @@ * * @param key The key of to be removed object */ - public void remove(Object key) { + public synchronized void remove(Object key) { if (getLogger().isDebugEnabled()) { getLogger().debug("Removing object from store"); getLogger().debug(" key: " + key); @@ -273,7 +273,7 @@ * @param key The key of the object * @return true if the key exists */ - public boolean containsKey(Object key) { + public synchronized boolean containsKey(Object key) { if(persistent) { return (cache.containsKey(key) || persistentStore.containsKey(key)); } else { @@ -286,7 +286,7 @@ * * @return the enumeration of the cache */ - public Enumeration keys() { + public synchronized Enumeration keys() { return this.cache.keys(); } @@ -294,7 +294,7 @@ * Returns count of the objects in the store, or -1 if could not be * obtained. */ - public int size() { + public synchronized int size() { return this.cache.size(); } @@ -302,7 +302,7 @@ * Frees some of the fast memory used by this store. * It removes the last element in the store. */ - public void free() { + public synchronized void free() { try { if (this.cache.size() > 0) { // This can throw NoSuchElementException 1.7 +9 -9 xml-cocoon2/src/java/org/apache/cocoon/components/store/MemoryStore.java Index: MemoryStore.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/store/MemoryStore.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- MemoryStore.java 22 Feb 2002 07:00:13 -0000 1.6 +++ MemoryStore.java 28 Mar 2002 09:56:58 -0000 1.7 @@ -63,7 +63,7 @@ * (Apache Software Foundation) * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> * (Apache Software Foundation, Exoffice Technologies) - * @version CVS $Id: MemoryStore.java,v 1.6 2002/02/22 07:00:13 cziegeler Exp $ + * @version CVS $Id: MemoryStore.java,v 1.7 2002/03/28 09:56:58 cziegeler Exp $ */ public class MemoryStore implements Store, ThreadSafe { /* WARNING: Hashtable is threadsafe, whereas HashMap is not. @@ -78,7 +78,7 @@ /** * Get the object associated to the given unique key. */ - public Object get(Object key) { + public synchronized Object get(Object key) { return(table.get(key)); } @@ -87,7 +87,7 @@ * caller to ensure that the key has a persistent state across * different JVM executions. */ - public void store(Object key, Object value) { + public synchronized void store(Object key, Object value) { this.hold(key,value); } @@ -96,30 +96,30 @@ * the object store will discard held objects if the * virtual machine is restarted or some error happens. */ - public void hold(Object key, Object value) { + public synchronized void hold(Object key, Object value) { table.put(key,value); } /** * Remove the object associated to the given key. */ - public void remove(Object key) { + public synchronized void remove(Object key) { table.remove(key); } - public void free() {} + public synchronized void free() {} /** * Indicates if the given key is associated to a contained object. */ - public boolean containsKey(Object key) { + public synchronized boolean containsKey(Object key) { return(table.containsKey(key)); } /** * Returns the list of used keys as an Enumeration of Objects. */ - public Enumeration keys() { + public synchronized Enumeration keys() { return(table.keys()); } @@ -127,7 +127,7 @@ * Returns count of the objects in the store, or -1 if could not be * obtained. */ - public int size() + public synchronized int size() { return table.size(); }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]