All Packages Class Hierarchy This Package Previous Next Index
If you want to have a system ObjectStorage, start it from a configuration file.
sample.conf: object[0].className=horb.orb.ObjectStorage object[0].implementation=horb.orb.ObjectStorage_Impl object[0].objectID=ObjectStorage command line: horb -conf sample.confThis object storage can be accessed as;
local: ObjectStorage os = (ObjectStorage)HORBServer.getObject("ObjectStorage"); os.saveObject(obj, "obj.fof"); remote: ObjectStorage os = new ObjectStorage_Proxy(new HorbURL("horb://host/ObjectStorage")); os.saveObject(obj, "obj.fof");
public abstract String saveObject(Object obj, String fname) throws HORBException, IOException
If a client does not give a filename, a temporary file is created and the filename is returned. If a client gives a filename, the filename may not include ".." in it and it may not be an absolute path. Thus filenames must be relative filename, for example, "data.fof" or "directory/data.fof". If ObjectStorage_Impl was instantiated with a directory name, the directory name is prepended to the filename.
public abstract Object loadObject(String fname) throws HORBException, IOException
Filename may not include ".." in it and it may not be an absolute path. Thus filenames must be relative filename, for example, "data.fof" or "directory/data.fof".
public abstract boolean lock(String fname, long timeout) throws HORBException
This locking system runs on memory, that is, the locking is valid while the HORB server is running.
Here is an example of atomic update of an object.
HorbURL url = new HorbURL(host, "ObjectStorage"); ObjectStorage_Proxy os = new ObjectStorage_Proxy(url); os.lock(file, 0); Data data = os.loadObject(file); data.update(); os.saveObject(data, file); os.unlock(file);
public abstract void unlock(String fname) throws IllegalMonitorStateException
If someone is waiting for the file, unlocking gives the next lock to the someone.
public abstract boolean isLocked(String fname)
public abstract boolean delete(String fname) throws HORBException, IOException
public abstract boolean rename(String fname1, String fname2) throws HORBException, IOException
public abstract void copy(String fname1, String fname2) throws IOException
public abstract String makeTemporaryFileName()
public abstract boolean exists(String fname) throws HORBException, IOException
All Packages Class Hierarchy This Package Previous Next Index