org.iperg.part.persistency
Interface IpPersistencyManager

All Known Implementing Classes:
IpRmsPersistencyManager

public interface IpPersistencyManager

The IpPersistencyManager specifies an interface that needs to be implemented by all persistenct manager components. A persistency manager can be used to save the state of an object to stable storage, and then load the state at some later point in time, for instance after a restart. The details of how this is done is is internal to each manager implementation.

 // Save state of an object
 IpPersistencyManager mgr = ...;
 mgr.save(obj, "myObj");
 ...
 // now load the object
 IpObject obj = mgr.load("myObj");
Persistency managers can also be used to save and load unique identifiers. This allows for instance an application process to maintain its identity after a restart.
 // Get the persisted identifier of this process
 IpIdentifier id = mgr.getId("myProc");
 // Set the PART process identifier to the loaded one. Will
 // cause our process id to always be the same when started. 
 IpSystem.initialize(id);


Field Summary
static int ON_CHANGE
           
static int ON_TIMER
           
 
Method Summary
 boolean contains(IpIdentifier objId)
          Check if the state of a given object has been saved in the persistency store.
 boolean contains(java.lang.String name)
          Check if the an object has been saved in the store under a given name.
 IpObject load(IpIdentifier objId)
          Load and return an object which has been previously saved in the persistency store.
 IpObject load(java.lang.String name)
          Load and return an object which has been previously saved in the persistency store.
 IpObject[] loadAll()
          Load and return all objects saved in the persistency store.
 IpIdentifier loadId(java.lang.String name)
          Load an identifier which has previously been saved using saveId.
 void persist(IpObject obj, java.lang.String name, int when)
          Save the state of the object repeatedly as specified by the when paramater.
 void remove(IpIdentifier objId)
          Remove the saved state of the given object from the persistency store.
 void remove(java.lang.String name)
          Remove the saved state of an object associated to the given name.
 void removeAll()
          Remove the content of the persistency store.
 void removeId(java.lang.String name)
          Remove an identifier which has previously been saved using saveId.
 void save(IpObject obj, java.lang.String name)
          Save the state of an object in the persistency store.
 void saveId(IpIdentifier id, java.lang.String name)
          Save an identifier in the store and associate it to a name.
 

Field Detail

ON_CHANGE

static final int ON_CHANGE
See Also:
Constant Field Values

ON_TIMER

static final int ON_TIMER
See Also:
Constant Field Values
Method Detail

save

void save(IpObject obj,
          java.lang.String name)
          throws IpException
Save the state of an object in the persistency store. May be called several times to update the state saved in the store. The object will be associated to the given name (if not null), which means that it can later be loaded using the name only:
 IpPersistencyManager pm = ...;
 pm.save(obj, "test");
 ..
 obj = pm.load("test");
If the name parameter is null and the object hasn't been saved before, the object is not associated to any name when saved. If the parameter is null and the object has been saved before, the object will be associated to the same name as was given when previously saved (may be null).

Parameters:
obj - The object whose state should be saved
name - A name to which the object will be associated, may be null
Throws:
IpException - if an exception occurs while saving the state.

persist

void persist(IpObject obj,
             java.lang.String name,
             int when)
             throws IpException
Save the state of the object repeatedly as specified by the when paramater. Will also cause the object to be saved immediately, If the name parameter is null and the object hasn't been saved before, the object is not associated to a name when saved. If the parameter is null and the object has been saved before, the object will be associated to the same name as was given when previously saved (may be null).

Parameters:
obj - The object
name - The name to which the object will be associated when saved (may be null)
when - Determines when the object will be saved
Throws:
IpException - if an exception occurs while saving the state.

load

IpObject load(IpIdentifier objId)
              throws IpException
Load and return an object which has been previously saved in the persistency store. Note that if the object whose state is loaded already exists in the local process, its state will be overwritten with the state saved in the store.

Parameters:
objId - The identifier of the object to load
Throws:
IpException - if an exception occurs while loading the object.

load

IpObject load(java.lang.String name)
              throws IpException
Load and return an object which has been previously saved in the persistency store. Note that if the object whose state is loaded already exists in the local process, its state will be overwritten with the state saved in the store.

Parameters:
name - The name that was given when the object was saved
Throws:
IpException - if an exception occurs while loading the object.

loadAll

IpObject[] loadAll()
                   throws IpException
Load and return all objects saved in the persistency store. If an object that is loaded already exists in the local process, the state of the existing object will be overwritten with the state loaded from the persistency store.

Returns:
An array of objects loaded from the store. If no objects were loaded, null is returned.
Throws:
IpException - if an exception occurs while loading the store content.

removeAll

void removeAll()
               throws IpException
Remove the content of the persistency store. Will remove all saved objects and also all name to identifier mappings created via getId.

Throws:
IpException - if an exception occurs while the content is removed.

contains

boolean contains(java.lang.String name)
                 throws IpException
Check if the an object has been saved in the store under a given name.

Parameters:
name - The name to which the object was associated when saved
Returns:

true

if the object's state has been saved under the given name,

false

otherwise
Throws:
IpException - if an exception occurs while checking if the object is saved in the store.

contains

boolean contains(IpIdentifier objId)
                 throws IpException
Check if the state of a given object has been saved in the persistency store.

Parameters:
objId - The identifier of the object
Returns:

true

if the object's state has been saved,

false

otherwise
Throws:
IpException - if an exception occurs while checking if the object is saved in the store.

remove

void remove(IpIdentifier objId)
            throws IpException
Remove the saved state of the given object from the persistency store. Will also cancel the effect of any previous call to

persist

concerning the object.

Parameters:
objId - The identifier of the object to remove
Throws:
IpException - if an exception occurs while the object is removed.

remove

void remove(java.lang.String name)
            throws IpException
Remove the saved state of an object associated to the given name. The name should be the same as given to the save or persist methods.

Parameters:
name - The name to which the object has been associated
Throws:
IpException - if an exception occurs while the object is removed.

loadId

IpIdentifier loadId(java.lang.String name)
                    throws IpException
Load an identifier which has previously been saved using saveId.

Parameters:
name - The name that was given when the identifier was saved
Returns:
The identifier if found, null otherwise
Throws:
IpException - if an exception occurs while the identifer is loaded.

saveId

void saveId(IpIdentifier id,
            java.lang.String name)
            throws IpException
Save an identifier in the store and associate it to a name. The name can later be used to load the identifier via loadId.

If an identifier is already saved under the given name, it will be overwritten.

Parameters:
id - The identifier to save
name - The name to which the identifier will be associated. May not be null.
Throws:
IpException - if an exception occurs while the identifer is saved.

removeId

void removeId(java.lang.String name)
              throws IpException
Remove an identifier which has previously been saved using saveId.

Parameters:
name - The name that was given when the identifier was saved
Throws:
IpException - if an exception occurs while the identifer is loaded.