|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.iperg.part.persistency.IpRmsPersistencyManager
public class IpRmsPersistencyManager
The IpRmsPersistencyManager
class defines a
persistency manager that uses a record store to save and load
objects and identifiers. On J2ME platforms, the manager uses the
record store provided by the Java API. On J2SE platforms, the
manager uses a record store library based on ordinary disk files.
Field Summary |
---|
Fields inherited from interface org.iperg.part.persistency.IpPersistencyManager |
---|
ON_CHANGE, ON_TIMER |
Method Summary | |
---|---|
boolean |
contains(IpIdentifier objId)
Check if the state of a given object has been saved in the record store. |
boolean |
contains(java.lang.String name)
Check if the state of a given object has been saved in the record store. |
static IpRmsPersistencyManager |
getInstance()
The main access method to retrieve the singleton RMS persistency manager instance. |
int |
getPersistOnTimerInterval()
Get the interval of the peristency manager timer. |
void |
handleEvent(IpEvent event)
Is called by PART whenever an event has been generated in the local process or received from the network. |
IpObject |
load(IpIdentifier objId)
Load an object which has been previously saved in the persistency store. |
IpObject |
load(java.lang.String name)
Load 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. |
void |
remove(java.lang.String name)
Remove the saved state of the given object. |
void |
removeAll()
Remove the contents 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. |
void |
setPersistOnTimerInterval(int interval)
Set the interval of the peristency manager timer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static IpRmsPersistencyManager getInstance()
public void handleEvent(IpEvent event)
handleEvent
in interface IpEventHandler
event
- The eventpublic void removeAll() throws IpException
getId
.
removeAll
in interface IpPersistencyManager
IpException
- if an exception occurs while the content
is removed.public void persist(IpObject obj, java.lang.String name, int when) throws IpException
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
). If persits
is called several
times for the same object, the new Possible values of the when
parameter are:
ON_CHANGE
- Means that the object will be saved
soon as it has been modified. Modifications that will trigger a
save are additions, removals and updates of properties.ON_TIMER
- Means that if the object has been
modified, it will be saved the next time the persistency
manager timer triggers (see
getPersistOnTimerInterval
and
setPersistOnTimerInterval
). Note that the object
is only saved when the timer trigger if it has been modified
since the last time the timer was triggered. If the persist method is called several times for the same
object, but with different values for the when
parameter, only the last value will be used. I.e., if an object
was previously persisted using ON_CHANGE
, and
persits
is called with ON_TIMER
, the
object will only be peristed on timer triggers, not on changes.
persist
in interface IpPersistencyManager
obj
- The objectname
- The name to which the object will be associated when
saved (may be null
)when
- Determines when the object will be saved
IpException
- if an exception occurs while saving the
state.public int getPersistOnTimerInterval()
The timer contols how often objects that have been
persisted using ON_TIMER
(see
persist
) are saved if modified.
public void setPersistOnTimerInterval(int interval)
The timer contols how often objects that have been
persisted using ON_TIMER
(see
persist
) are saved if modified.
interval
- Interval in milliseconds. Must be > 0.public void save(IpObject obj, java.lang.String name) throws IpException
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
).
save
in interface IpPersistencyManager
obj
- The object whose state should be savedname
- A name to which the object will be associated, may be
null
IpException
- if an exception occurs while saving the
state.public IpObject load(IpIdentifier objId) throws IpException
load
in interface IpPersistencyManager
objId
- The identifier of the object that should be loaded
loaded
null
otherwise
IpException
- if an exception occurs while loading the
state.public IpObject load(java.lang.String name) throws IpException
load
in interface IpPersistencyManager
name
- The name that was associated to the object when
saved
null
otherwise
IpException
- if an exception occurs while loading the
state.public IpObject[] loadAll() throws IpException
loadAll
in interface IpPersistencyManager
null
is returned.
IpException
- if an exception occurs while loading the
store content.public boolean contains(IpIdentifier objId) throws IpException
contains
in interface IpPersistencyManager
objId
- The object identifier
true
if the object's state has been saved,false
otherwiseIpException
- if an exception occurs while checking if
the object is saved in the store.public boolean contains(java.lang.String name) throws IpException
contains
in interface IpPersistencyManager
name
- The name to which the object has been associated
when saved
true
if the object's state has been saved,false
otherwiseIpException
- if an exception occurs while checking if
the object is saved in the store.public void remove(IpIdentifier objId) throws IpException
persist
orpersistAll
for the object.
remove
in interface IpPersistencyManager
objId
- The identifier of the object whose state should be
removed
IpException
- if an exception occurs while the object
is removed.public void remove(java.lang.String name) throws IpException
persist
orpersistAll
for the object.
remove
in interface IpPersistencyManager
name
- The name under which the object is stored
IpException
- if an exception occurs while the object
is removed.public IpIdentifier loadId(java.lang.String name) throws IpException
saveId
.
loadId
in interface IpPersistencyManager
name
- The name that was given when the identifier was
saved
null
otherwise
IpException
- if an exception occurs while the
identifer is loaded.public void saveId(IpIdentifier id, java.lang.String name) throws IpException
loadId
.
If an identifier is already saved under the given name, it will be overwritten.
saveId
in interface IpPersistencyManager
id
- The identifier to savename
- The name to which the identifier will be
associated. May not be null
.
IpException
- if an exception occurs while the
identifer is saved.public void removeId(java.lang.String name) throws IpException
saveId
.
removeId
in interface IpPersistencyManager
name
- The name that was given when the identifier was
saved
IpException
- if an exception occurs while the
identifer is loaded.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |