ca.sqlpower.wabit.dao
Interface WabitPersister

All Known Implementing Classes:
WabitJSONPersister, WabitSessionPersister

public interface WabitPersister

An interface for objects that persist WabitObjects. The medium into which they are persisted is entirely up to the implementation.


Nested Class Summary
static class WabitPersister.DataType
          Defines each type of object that can be persisted by the WabitPersister.
static class WabitPersister.WabitPersistMethod
          An enumeration of possible WabitPersister commands.
 
Method Summary
 void begin()
          Indicates the start of an atomic transaction of persisting multiple WabitObjects.
 void commit()
          Causes a current WabitObject persistence transaction to commit its results.
 void persistObject(java.lang.String parentUUID, java.lang.String type, java.lang.String uuid, int index)
          Adds a WabitObject into the persistent storage.
 void persistProperty(java.lang.String uuid, java.lang.String propertyName, WabitPersister.DataType propertyType, java.lang.Object newValue)
          Modifies the named property of the specified WabitObject in this persister's workspace.
 void persistProperty(java.lang.String uuid, java.lang.String propertyName, WabitPersister.DataType propertyType, java.lang.Object oldValue, java.lang.Object newValue)
          Modifies the named property of the specified WabitObject in this persister's workspace.
 void removeObject(java.lang.String parentUUID, java.lang.String uuid)
          Removes a WabitObject from persistent storage
 void rollback()
          Restores the persisted WabitObject back to the state it was in before the transaction began (i.e.
 

Method Detail

persistProperty

void persistProperty(java.lang.String uuid,
                     java.lang.String propertyName,
                     WabitPersister.DataType propertyType,
                     java.lang.Object oldValue,
                     java.lang.Object newValue)
                     throws WabitPersistenceException
Modifies the named property of the specified WabitObject in this persister's workspace. It may throw an Exception if the actual previous value in persistent storage does not match the expected previous value as an indication to the object using this WabitPersister that their cached copy of the WabitObject may be out of sync with the persistent storage.

Parameters:
uuid - The UUID of the WabitObject in which to set the property
propertyName - The JavaBeans property name of the property that changed, as it would be discovered by the java.beans.Introspector class
propertyType - The type, and Java representation, of this property
oldValue - The expected previous value of the property
newValue - The new value to set for the property
Throws:
WabitPersistenceException - A general Exception that is thrown if any Exception occurs while persisting the property. It can be used to wrap the specific cause Exception and provide other details like the WabitObject UUID. Some potential exceptional situations include:
  • The WabitObject UUID is unknown to this persister
  • The given property name does not exist
  • The given property is not writable
  • The property type of the given old/new values do not match each other or the actual property in the object
  • The existing persistent value doesn't match expected oldValue

persistProperty

void persistProperty(java.lang.String uuid,
                     java.lang.String propertyName,
                     WabitPersister.DataType propertyType,
                     java.lang.Object newValue)
                     throws WabitPersistenceException
Modifies the named property of the specified WabitObject in this persister's workspace. This version is an unconditional call, and does not check the previous state of the property. To ensure the WabitObjects stay in synch, this method should only be called by the Persister representing the master copy of the WabitObject.

Parameters:
uuid - The UUID of the WabitObject in which to set the property
propertyName - The JavaBeans property name of the property that changed, as it would be discovered by the java.beans.Introspector class
propertyType - The type, and Java representation, of this property
newValue - The new value to set for the property
Throws:
WabitPersistenceException - A general Exception that is thrown if any Exception occurs while persisting the property. It can be used to wrap the specific cause Exception and provide other details like the WabitObject UUID. Some potential exceptional situations include:
  • The WabitObject UUID is unknown to this persister
  • The given property name does not exist
  • The given property is not writable
  • The property type of the given value does not match the actual property in the object

persistObject

void persistObject(java.lang.String parentUUID,
                   java.lang.String type,
                   java.lang.String uuid,
                   int index)
                   throws WabitPersistenceException
Adds a WabitObject into the persistent storage. If the WabitObject already exists in persistent storage, then it will throw an exception Note that this will not persist its properties or any child objects.

Parameters:
parentUUID - The UUID of the parent WabitObject of the object to persist. If the WabitObject has no parent (as is the case for WabitWorkspace), then it can be set to null.
type - A String of the class name of the WabitObject to be persisted (ex. WabitWorkspace)
uuid - The UUID of the WabitObject to actually persist
index - The index of the WabitObject in its parents' list of children
Throws:
WabitPersistenceException - A general Exception that is thrown if any Exception occurs while persisting the WabitObject. It can be used to wrap the specific cause Exception and provide other details like the WabitObject UUID. Some potential exceptional situations include:
  • A WabitObject with the given UUID already exists in the persistent storage
  • A WabitObject with the given parent UUID does not exist

removeObject

void removeObject(java.lang.String parentUUID,
                  java.lang.String uuid)
                  throws WabitPersistenceException
Removes a WabitObject from persistent storage

Parameters:
parentUUID - The UUID of the parent WabitObject of the object to remove
uuid - The UUID of the WabitObject to remove
Throws:
WabitPersistenceException - A general Exception that is thrown if any Exception occurs while persisting the WabitObject. It can be used to wrap the specific cause Exception and provide other details like the WabitObject UUID.

begin

void begin()
           throws WabitPersistenceException
Indicates the start of an atomic transaction of persisting multiple WabitObjects. To be used with a paired call to commit()

Throws:
WabitPersistenceException - A general Exception that is thrown if any Exception occurs while persisting the WabitObject. It can be used to wrap the specific cause Exception and provide other details like the WabitObject UUID.

commit

void commit()
            throws WabitPersistenceException
Causes a current WabitObject persistence transaction to commit its results.

Throws:
WabitPersistenceException - A general Exception that is thrown if any Exception occurs while committing the transaction. This could be caused by one being thrown by #persistObject(String, String), #persistProperty(String, String, Object, Object), or removeObject(String, String). Some other exceptional situations include:
  • An update conflict with another transaction
  • Network issues
  • Insufficient permissions in the backing store

rollback

void rollback()
Restores the persisted WabitObject back to the state it was in before the transaction began (i.e. when the call to begin() was made). Typically, this would be called if an exception occurs during an atomic transaction. In the event that a rollback() is called within a nested transaction (that is, a begin() call after another begin() call before commit()), then the state of the WabitObjects must be rolled back to the state they were in before the highest level transaction began.



Copyright © 2009. All Rights Reserved.