DLESE Tools
v1.6.0

org.dlese.dpc.datamgr
Class ListenerDataManager

java.lang.Object
  extended by org.dlese.dpc.datamgr.ListenerDataManager

public abstract class ListenerDataManager
extends Object

Provides an abstract implementation of a common interface for applications needing to work with a data store. Implementers of DataListener register with a DataManager instance. An instance of data is uniquely identified using an object identifier. Applications must request locks to restrict writing of data.

Version:
1.0, 9/30/02
Author:
Dave Deniman, John Weatherley

Constructor Summary
ListenerDataManager()
           
 
Method Summary
abstract  void addListener(DataListener listener)
          Add a DataListener to this DataManager.
abstract  void delete(String oid)
          Deletes an existing data object iff the object is not locked.
abstract  void delete(String oid, String lockKey)
          Deletes an existing data object, assuming the caller had requested and recieved the necessary lock.
protected abstract  void fireDataAddedEvent(List dataToAdd)
          Construct the DataEvent object and invoke the appropriate method of all the listeners to this DataManager.
protected abstract  void fireDataChangedEvent(List dataToChange)
          Construct the DataEvent object and invoke the appropriate method of all the listeners to this DataManager.
protected abstract  void fireDataRemovedEvent(List dataToRemove)
          Construct the DataEvent object and invoke the appropriate method of all the listeners to this DataManager.
abstract  List get(List oids)
          Retrieves a List of data objects.
abstract  Object get(String oid)
          Retrieves a single data object.
abstract  boolean isLocked(String oid)
          Determine whether a given object is locked.
abstract  boolean isValidLock(String oid, String lockKey)
          Determine whether a given object is locked with the given key.
abstract  String lock(String oid)
          Request a lock for a data object.
abstract  boolean oidExists(String oid)
          Determines whether an object with the given oid exists in the DataManager.
abstract  Object put(String oid, Object obj)
          Adds a new object of data.
abstract  Object remove(String oid)
          Removes an existing data object iff the object is not locked.
abstract  Object remove(String oid, String lockKey)
          Removes an existing data object, assuming the caller had requested and recieved the necessary lock.
abstract  void removeListener(DataListener listener)
          Remove a DataListener from this DataManager.
abstract  boolean unlock(String oid, String lockKey)
          Remove the lock on a data object.
abstract  Object update(String oid, Object obj)
          Updates a new object of data iff the object is not locked.
abstract  Object update(String oid, Object obj, String lockKey)
          Updates a new object of data, assuming the caller had requested and recieved the necessary lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListenerDataManager

public ListenerDataManager()
Method Detail

get

public abstract Object get(String oid)
                    throws OIDDoesNotExistException
Retrieves a single data object.

Parameters:
oid - The data identifier
Returns:
Object of data
Throws:
OIDDoesNotExistException

get

public abstract List get(List oids)
                  throws OIDDoesNotExistException
Retrieves a List of data objects.

Parameters:
oids - List of data identifiers
Returns:
List of corresponding data objects
Throws:
OIDDoesNotExistException

put

public abstract Object put(String oid,
                           Object obj)
                    throws OIDAlreadyExistsException,
                           ObjectNotSupportedException
Adds a new object of data.

Parameters:
oid - The unique identifier that references the new data object
obj - The new data object
Returns:
The added data object, if successful
Throws:
OIDAlreadyExistsException
ObjectNotSupportedException

remove

public abstract Object remove(String oid,
                              String lockKey)
                       throws OIDDoesNotExistException,
                              InvalidLockException
Removes an existing data object, assuming the caller had requested and recieved the necessary lock.

Parameters:
oid - The unique identifier that references the data object to be removed
lockKey - The key corresponding to the lock on this data object
Returns:
The removed data object, if successful
Throws:
OIDDoesNotExistException
InvalidLockException

remove

public abstract Object remove(String oid)
                       throws OIDDoesNotExistException,
                              LockNotAvailableException
Removes an existing data object iff the object is not locked. If the object is locked a LockNotAvailableException is thrown. After successful completion the object is removed from the DataManager and returned to the caller.

Parameters:
oid - The unique identifier that references the data object to be removed
Throws:
OIDDoesNotExistException
LockNotAvailableException

delete

public abstract void delete(String oid,
                            String lockKey)
                     throws OIDDoesNotExistException,
                            InvalidLockException
Deletes an existing data object, assuming the caller had requested and recieved the necessary lock. Similar to remove() except no object is returned and thus is more efficient if an object is not required.

Parameters:
oid - The unique identifier that references the data object to be deleted
lockKey - The key corresponding to the lock on this data object
Throws:
OIDDoesNotExistException
InvalidLockException

delete

public abstract void delete(String oid)
                     throws OIDDoesNotExistException,
                            LockNotAvailableException
Deletes an existing data object iff the object is not locked. If the object is locked a LockNotAvailableException is thrown. Similar to remove() except no object is returned and thus is more efficient. After successful completion the object is deleted from the DataManager.

Parameters:
oid - The unique identifier that references the data object to be deleted
Throws:
OIDDoesNotExistException
LockNotAvailableException

update

public abstract Object update(String oid,
                              Object obj,
                              String lockKey)
                       throws OIDDoesNotExistException,
                              ObjectNotSupportedException,
                              InvalidLockException
Updates a new object of data, assuming the caller had requested and recieved the necessary lock.

Parameters:
oid - The unique identifier that references the data object to be updated
obj - The new updated data object
lockKey - The key corresponding to the lock on this data object
Returns:
The updated data object, if successful
Throws:
OIDDoesNotExistException
ObjectNotSupportedException
InvalidLockException

update

public abstract Object update(String oid,
                              Object obj)
                       throws OIDDoesNotExistException,
                              ObjectNotSupportedException,
                              LockNotAvailableException
Updates a new object of data iff the object is not locked. If the object is locked a LockNotAvailableException is thrown.

Parameters:
oid - The unique identifier that references the data object to be updated
obj - The new updated data object
Returns:
The updated data object, if successful otherwise null
Throws:
OIDDoesNotExistException
ObjectNotSupportedException
LockNotAvailableException

lock

public abstract String lock(String oid)
                     throws OIDDoesNotExistException,
                            LockNotAvailableException
Request a lock for a data object.

Parameters:
oid - The unique identifier that references the data object to be locked
Returns:
The key for this lock, as a String, if successful
Throws:
OIDDoesNotExistException
LockNotAvailableException

unlock

public abstract boolean unlock(String oid,
                               String lockKey)
                        throws OIDDoesNotExistException,
                               InvalidLockException
Remove the lock on a data object.

Parameters:
oid - The unique identifier that references the locked data object
lockKey - The key corresponding to the lock on this data object
Returns:
true if successful, false otherwise
Throws:
OIDDoesNotExistException
InvalidLockException

oidExists

public abstract boolean oidExists(String oid)
Determines whether an object with the given oid exists in the DataManager.

Parameters:
oid - The unique identifier that references the data object
Returns:
True iff the given object exists in this DataManager

isLocked

public abstract boolean isLocked(String oid)
Determine whether a given object is locked.

Parameters:
oid - The unique identifier that references the data object
Returns:
True iff the object referred to by this oid is locked

isValidLock

public abstract boolean isValidLock(String oid,
                                    String lockKey)
Determine whether a given object is locked with the given key.

Parameters:
oid - The unique identifier that references the data object
lockKey - The lock key
Returns:
True iff the object referred to by this oid is locked with the given key

addListener

public abstract void addListener(DataListener listener)
Add a DataListener to this DataManager.

Parameters:
listener - The listener to add

removeListener

public abstract void removeListener(DataListener listener)
Remove a DataListener from this DataManager.

Parameters:
listener - The listener to remove

fireDataAddedEvent

protected abstract void fireDataAddedEvent(List dataToAdd)
Construct the DataEvent object and invoke the appropriate method of all the listeners to this DataManager.

Parameters:
dataToAdd - The list of OIDs for data added to this manager

fireDataChangedEvent

protected abstract void fireDataChangedEvent(List dataToChange)
Construct the DataEvent object and invoke the appropriate method of all the listeners to this DataManager.

Parameters:
dataToChange - The list of OIDs for data changed by this manager

fireDataRemovedEvent

protected abstract void fireDataRemovedEvent(List dataToRemove)
Construct the DataEvent object and invoke the appropriate method of all the listeners to this DataManager.

Parameters:
dataToRemove - The list of OIDs for data removed by this manager

DLESE Tools
v1.6.0