org.keridwen.core.data.storage.service.impl
Class DefaultDataStorageService

java.lang.Object
  extended by org.keridwen.core.data.storage.service.impl.DefaultDataStorageService
All Implemented Interfaces:
DataStorage, DataStorageService

public class DefaultDataStorageService
extends Object
implements DataStorageService


Constructor Summary
DefaultDataStorageService()
           
 
Method Summary
 boolean addDataPacketListener(DataPacketId packetId, DataPacketListener listener)
          Adds a listener on a data packet with given Id.
 boolean addDataStorageListener(DataStorageListener listener)
          Adds a listener on this data storage.
 Set<DataPacketId> getDataListSafe(Class<?> objectClass)
          Gets the list of ids for the objects of the given type.
 Set<DataPacketId> getDataListUnsafe(Class<?> objectClass)
          Gets the list of ids for the objects of the given type.
<ObjectType extends Serializable>
ObjectType
getDataSafe(DataPacketId packetId)
          Gets the data object corresponding to the given unique id.
<ObjectType extends Serializable>
ObjectType
getDataSafe(String objectName)
          Gets the data object corresponding to the given name.
<ObjectType>
ObjectType
getDataUnsafe(DataPacketId packetId)
          Gets the data object corresponding to the given unique id.
<ObjectType>
ObjectType
getDataUnsafe(String objectName)
          Gets the data object corresponding to the given name.
 int getNbData()
          Get the total number of stored data (safe+unsafe).
 String getPacketInformation(DataPacketId packetId)
          Gets the information of the packet with the given id.
 Boolean isReadLocked(DataPacketId packetId)
          Checks if the data packet with the given id is read locked.
 Boolean isWriteLocked(DataPacketId packetId)
          Checks if the data packet with the given id is write locked.
 void onStartModule()
           
 void onStopModule()
           
 boolean removeDataPacketListener(DataPacketId packetId, DataPacketListener listener)
          Removes a listener from a data packet with given Id.
 boolean removeDataStorageListener(DataStorageListener listener)
          Removes a listener from this data storage.
 boolean setDataSafe(Serializable serializableObject, DataPacketId packetId)
          Sets the object with the given unique id in the data storage.
 DataPacketId setDataSafe(String name, Serializable serializableObject)
          Sets the object with the given name in the data storage.
<ObjectType>
DataPacketId
setDataUnsafe(String name, ObjectType object)
          Sets the object with the given name in the data storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDataStorageService

public DefaultDataStorageService()
Method Detail

onStartModule

public void onStartModule()
Specified by:
onStartModule in interface DataStorageService

onStopModule

public void onStopModule()
Specified by:
onStopModule in interface DataStorageService

getNbData

public int getNbData()
Description copied from interface: DataStorage
Get the total number of stored data (safe+unsafe).

Specified by:
getNbData in interface DataStorage
Returns:
the total number of stored data

setDataUnsafe

public <ObjectType> DataPacketId setDataUnsafe(String name,
                                               ObjectType object)
                           throws DataIOException
Description copied from interface: DataStorage
Sets the object with the given name in the data storage. This method is not safe.

Specified by:
setDataUnsafe in interface DataStorage
Type Parameters:
ObjectType - the type of the object to set
Parameters:
name - the object name
object - the object to set
Returns:
an unique DataPacketId
Throws:
DataIOException - if the data writting failed

setDataSafe

public DataPacketId setDataSafe(String name,
                                Serializable serializableObject)
                         throws DataIOException,
                                DataConcurrencyException
Description copied from interface: DataStorage
Sets the object with the given name in the data storage. This method is safe.

Specified by:
setDataSafe in interface DataStorage
Parameters:
name - the object name
serializableObject - the object to set
Returns:
an unique DataPacketId
Throws:
DataIOException - if the data writting failed
DataConcurrencyException - in case of concurrent access to the data

setDataSafe

public boolean setDataSafe(Serializable serializableObject,
                           DataPacketId packetId)
                    throws DataIOException,
                           DataConcurrencyException
Description copied from interface: DataStorage
Sets the object with the given unique id in the data storage.

Specified by:
setDataSafe in interface DataStorage
Parameters:
serializableObject - the object to set
packetId - the unique id of the object to set
Returns:
true in case of success
Throws:
DataIOException - if the data writting failed
DataConcurrencyException - in case of concurrent access to the data

getDataUnsafe

public <ObjectType> ObjectType getDataUnsafe(DataPacketId packetId)
                         throws DataIOException
Description copied from interface: DataStorage
Gets the data object corresponding to the given unique id. This method is not safe.

Specified by:
getDataUnsafe in interface DataStorage
Parameters:
packetId - the unique id of the object to retrieve
Returns:
the retrieved object
Throws:
DataIOException - in case data reading failed

getDataSafe

public <ObjectType extends Serializable> ObjectType getDataSafe(String objectName)
                                            throws DataIOException,
                                                   DataConcurrencyException
Description copied from interface: DataStorage
Gets the data object corresponding to the given name. This method is safe.

Specified by:
getDataSafe in interface DataStorage
Parameters:
objectName - the name of the object to retrieve
Returns:
the retrieved object
Throws:
DataIOException - in case data reading failed
DataConcurrencyException - in case of concurrent access to the data

getDataUnsafe

public <ObjectType> ObjectType getDataUnsafe(String objectName)
                         throws DataIOException
Description copied from interface: DataStorage
Gets the data object corresponding to the given name. This method is not safe.

Specified by:
getDataUnsafe in interface DataStorage
Parameters:
objectName - the name of the object to retrieve
Returns:
the retrieved object
Throws:
DataIOException - in case data reading failed

getDataSafe

public <ObjectType extends Serializable> ObjectType getDataSafe(DataPacketId packetId)
                                            throws DataIOException,
                                                   DataConcurrencyException
Description copied from interface: DataStorage
Gets the data object corresponding to the given unique id. This method is safe.

Specified by:
getDataSafe in interface DataStorage
Parameters:
packetId - the unique id of the object to retrieve
Returns:
the retrieved object
Throws:
DataIOException - in case data reading failed
DataConcurrencyException - in case of concurrent access to the data

getDataListSafe

public Set<DataPacketId> getDataListSafe(Class<?> objectClass)
Description copied from interface: DataStorage
Gets the list of ids for the objects of the given type. This method is safe.

Specified by:
getDataListSafe in interface DataStorage
Parameters:
objectClass - the type of object to fetch
Returns:
the list of unique ids of the objects

getDataListUnsafe

public Set<DataPacketId> getDataListUnsafe(Class<?> objectClass)
Description copied from interface: DataStorage
Gets the list of ids for the objects of the given type. This method is safe.

Specified by:
getDataListUnsafe in interface DataStorage
Parameters:
objectClass - the type of object to fetch
Returns:
the list of unique ids of the objects

addDataPacketListener

public boolean addDataPacketListener(DataPacketId packetId,
                                     DataPacketListener listener)
Description copied from interface: DataStorage
Adds a listener on a data packet with given Id.

Specified by:
addDataPacketListener in interface DataStorage
Parameters:
packetId - the id of the packet to listen

removeDataPacketListener

public boolean removeDataPacketListener(DataPacketId packetId,
                                        DataPacketListener listener)
Description copied from interface: DataStorage
Removes a listener from a data packet with given Id.

Specified by:
removeDataPacketListener in interface DataStorage
Parameters:
packetId - the id of the packet to stop listenning

getPacketInformation

public String getPacketInformation(DataPacketId packetId)
Description copied from interface: DataStorage
Gets the information of the packet with the given id.

Specified by:
getPacketInformation in interface DataStorage
Parameters:
packetId - the id of the packet
Returns:
the string information regarding the data packet

isWriteLocked

public Boolean isWriteLocked(DataPacketId packetId)
Description copied from interface: DataStorage
Checks if the data packet with the given id is write locked.

Specified by:
isWriteLocked in interface DataStorage
Parameters:
packetId - the id of the packet to check
Returns:
true if the packet is locked for writing. Returns null if no packet is found.

isReadLocked

public Boolean isReadLocked(DataPacketId packetId)
Description copied from interface: DataStorage
Checks if the data packet with the given id is read locked.

Specified by:
isReadLocked in interface DataStorage
Parameters:
packetId - the id of the packet to check
Returns:
true if the packet is locked for reading. Returns null if no packet is found.

addDataStorageListener

public boolean addDataStorageListener(DataStorageListener listener)
Description copied from interface: DataStorage
Adds a listener on this data storage.

Specified by:
addDataStorageListener in interface DataStorage
Parameters:
listener - the listener to add

removeDataStorageListener

public boolean removeDataStorageListener(DataStorageListener listener)
Description copied from interface: DataStorage
Removes a listener from this data storage.

Specified by:
removeDataStorageListener in interface DataStorage
Parameters:
listener - the listener to remove


Copyright © 2010-2013 Artenum. All Rights Reserved.