com.sap.ip.me.api.services
Class MultiObjectFileStorage

java.lang.Object
  extended bycom.sap.ip.me.api.services.MultiObjectFileStorage

public class MultiObjectFileStorage
extends java.lang.Object

This class stores serializable objects in the file system with each object tree being stored in a seperate file.

Author:
SAP

Method Summary
 java.util.Enumeration allObjects()
          This method returns all objects that are accessible with this instance.
 java.util.Enumeration bufferedObjects()
          This method returns all cached objects.
 void clearCache()
          Clears the object cache and triggers garbage collection
 void commit()
          This method executes all changes prepared by writeOnCommit / deleteOnCommit on the file-system.
static MultiObjectFileStorage createInstance(java.lang.String subDirectory)
          This method returns a MultiObjectFileStorage instance for a given subdirectory.
 void delete(java.lang.String key)
          This method immediately deletes an object from the file-system
 void deleteOnCommit(java.lang.String key)
          This method prepares an object to be deleted to the file-system.
 java.lang.Object read(java.lang.String key)
          This method reads an object from the storage.
 java.lang.Object read(java.lang.String key, boolean bypassCache)
          This method reads an object from the storage with explictly ignoring the cache (if the bypassCache parameter is set to false).
 void rollback()
          This mehtod reverses all changes prepared by writeOnCommit / deleteOnCommit since the last commit Technically, this is archieved by re-reading the cache.
 void write(java.lang.String key, java.lang.Object value)
          This method immedeately writes any object to the file-system.
 void writeOnCommit(java.lang.String key, java.lang.Object value)
          This method prepares an object to be written to the file-system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createInstance

public static MultiObjectFileStorage createInstance(java.lang.String subDirectory)
This method returns a MultiObjectFileStorage instance for a given subdirectory.

Parameters:
subDirectory - The subdirectory for the MultiObjectFileStorage .
Returns:
A MultiObjectFileStorage instance for a given subdirectory. null iff there are any failures while creating a MultiObjectFileStorage instance.

clearCache

public void clearCache()
Clears the object cache and triggers garbage collection


read

public java.lang.Object read(java.lang.String key)
This method reads an object from the storage. First, the cache is accessed. In case the object cannot be retrieved from the cache, the actual file- access is invoked

Parameters:
key - Unique key which the object is associated to
Returns:
The object / null, if no object could be found

read

public java.lang.Object read(java.lang.String key,
                             boolean bypassCache)
This method reads an object from the storage with explictly ignoring the cache (if the bypassCache parameter is set to false). In case the object can / shall not be retrieved from the cache, the actual file-access is invoked

Parameters:
key - Unique key the object is associated to
bypassCache - If true then read directly from file and update the cache otherwise the object will be get from cache.
Returns:
The object / null, if no object could be found

write

public void write(java.lang.String key,
                  java.lang.Object value)
This method immedeately writes any object to the file-system.

Parameters:
key - Unique key the object is associated to.
value - Object to be stored.

delete

public void delete(java.lang.String key)
This method immediately deletes an object from the file-system

Parameters:
key - The key of the object that has to be deleted.

writeOnCommit

public void writeOnCommit(java.lang.String key,
                          java.lang.Object value)
This method prepares an object to be written to the file-system. The actual writing is performed when invoking commit(). For the meantime, the cache already contains the changed object, which means read-accesses without explicitly bypassing the cache will already return the changed object

Parameters:
key - The unique key that represents the object.
value - The object istself.

deleteOnCommit

public void deleteOnCommit(java.lang.String key)
This method prepares an object to be deleted to the file-system. The actual deletion is performed when invoking commit(). For the meantime, the object is already removed from the cache. However, when invoking the read() method, it will be retrieved and put into cache again as the read-strategy first checks the cache and then the file-system. However, the actual deletion will take place.

Parameters:
key - The unique key of the object that has to be deleted.

commit

public void commit()
This method executes all changes prepared by writeOnCommit / deleteOnCommit on the file-system.


bufferedObjects

public java.util.Enumeration bufferedObjects()
This method returns all cached objects.

Returns:
Enumeration of cached objects.

allObjects

public java.util.Enumeration allObjects()
This method returns all objects that are accessible with this instance. Please be aware of the performance this method-invocation might take,

Returns:
Enumeration of accessible objects for this instance of the MultiObjectFileStorage.

rollback

public void rollback()
This mehtod reverses all changes prepared by writeOnCommit / deleteOnCommit since the last commit Technically, this is archieved by re-reading the cache.



Copyright © 2005 SAP AG. All Rights Reserved.