uk.ac.soton.ecs.iam.grid.client.staterepos
Class AbstractStateRepository

java.lang.Object
  extended by uk.ac.soton.ecs.iam.grid.client.staterepos.AbstractStateRepository
All Implemented Interfaces:
StateRepository
Direct Known Subclasses:
MemoryStateRepository

public abstract class AbstractStateRepository
extends Object
implements StateRepository

A state repository is a database of conversations. New Conversation objects are created by the StateRepository, which typically stores them in a persistant database. You can use a subclass of AbstractStateRepository to store your Conversation objects.


Field Summary
protected  org.apache.log4j.Logger log
           
 
Constructor Summary
AbstractStateRepository()
           
 
Method Summary
 void addListener(StateRepositoryListener listener)
          Add a listener which will receive RespositoryChangedEvents.
 void addObject(StorableInStateRepository object)
          Add this object to the repository.
protected abstract  void addObjectInternal(StorableInStateRepository object)
           
 void checkForUpdates()
          Ensure that the repository is up-to-date.
protected abstract  void deleteConversation(Conversation conversation)
          Remove conversation from the StateRepository.
abstract  void dump()
          For debugging
 Conversation[] getAccountConversations()
          Deprecated. 
abstract  StorableInStateRepository[] getAll()
          Returns all items in the state repository
abstract  StorableInStateRepository[] getByParent(URL parentID)
          Returns a list of all children of the given conversation.
abstract  Conversation getConversationByID(URL cid)
          Returns the Conversation object corresponding to the given URL.
<T extends StorableInStateRepository>
T
getOrCreateObject(Class<T> type, org.apache.axis.message.addressing.EndpointReferenceType EPR)
          Get the existing object with this EPR's ID.
 StorableInStateRepository getOrCreateObject(org.apache.axis.message.addressing.EndpointReferenceType EPR)
          Get the existing object with this EPR's ID.
<T extends StorableInStateRepository>
T
instantiateObject(Class<T> type, org.apache.axis.message.addressing.EndpointReferenceType EPR)
          Convenience wrapper for instantiateObject that sets the type in the EPR first.
 StorableInStateRepository instantiateObject(org.apache.axis.message.addressing.EndpointReferenceType EPR)
          Create a new object, in the same way that the StateRepository does when loading saved instances.
 void notifyChanged(StorableInStateRepository object)
          Deprecated. 
 void notifyChanged(StorableInStateRepository object, RepositoryChangedEventType eventType)
          Notify listeners that this object has changed.
protected abstract  void notifyChangedInternal(StorableInStateRepository object)
           
protected  void notifyListeners(StorableInStateRepository object)
          Deprecated. The RepositoryChangedEvent should have an RepositoryChangedEventType
protected  void notifyListeners(StorableInStateRepository object, RepositoryChangedEventType eventType)
          Send a RepositoryChangedEvent with Type RepositoryChangedEventType to every listener registered with addListener.
 void removeListener(StateRepositoryListener listener)
          Remove a listener previously added with addListener().
 void removeObject(StorableInStateRepository object)
          Remove conversation from the StateRepository.
protected abstract  void removeObjectInternal(StorableInStateRepository object)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.soton.ecs.iam.grid.comms.client.StateRepository
getConversationsByType, getObject, getProperty, getToplevel, setProperty
 

Field Detail

log

protected org.apache.log4j.Logger log
Constructor Detail

AbstractStateRepository

public AbstractStateRepository()
Method Detail

getConversationByID

public abstract Conversation getConversationByID(URL cid)
                                          throws NoSuchConversation
Description copied from interface: StateRepository
Returns the Conversation object corresponding to the given URL.

Specified by:
getConversationByID in interface StateRepository
Throws:
NoSuchConversation

getByParent

public abstract StorableInStateRepository[] getByParent(URL parentID)
                                                 throws NoSuchConversation
Description copied from interface: StateRepository
Returns a list of all children of the given conversation.

Specified by:
getByParent in interface StateRepository
Throws:
NoSuchConversation

addObjectInternal

protected abstract void addObjectInternal(StorableInStateRepository object)
                                   throws ObjectAlreadyExists
Throws:
ObjectAlreadyExists

removeObjectInternal

protected abstract void removeObjectInternal(StorableInStateRepository object)
                                      throws NoSuchConversation
Throws:
NoSuchConversation

getAll

public abstract StorableInStateRepository[] getAll()
Description copied from interface: StateRepository
Returns all items in the state repository

Specified by:
getAll in interface StateRepository

getAccountConversations

@Deprecated
public Conversation[] getAccountConversations()
Deprecated. 

Description copied from interface: StateRepository
Returns an array of all account conversations.

Specified by:
getAccountConversations in interface StateRepository

notifyChangedInternal

protected abstract void notifyChangedInternal(StorableInStateRepository object)

removeObject

public void removeObject(StorableInStateRepository object)
                  throws NoSuchConversation
Remove conversation from the StateRepository. Must not have any child conversations. This is called by Conversation.finish(), which is the interface presented by the library.

Specified by:
removeObject in interface StateRepository
Throws:
NoSuchConversation - if the object is not in the repository.

notifyChanged

@Deprecated
public void notifyChanged(StorableInStateRepository object)
Deprecated. 

Description copied from interface: StateRepository
Notify listeners that this object has changed. Typically, this is called by the object itself.

Specified by:
notifyChanged in interface StateRepository
Parameters:
object - the object that changed, or null if changes are not limited to a specific object

notifyChanged

public void notifyChanged(StorableInStateRepository object,
                          RepositoryChangedEventType eventType)
Description copied from interface: StateRepository
Notify listeners that this object has changed. Typically, this is called by the object itself.

Specified by:
notifyChanged in interface StateRepository
Parameters:
object - the object that changed, or null if changes are not limited to a specific object
eventType - the type of event that has occured RepositoryChangedEventType

deleteConversation

protected abstract void deleteConversation(Conversation conversation)
                                    throws NoSuchConversation
Remove conversation from the StateRepository. This is overridden by subclasses of AbstractStateRepository. It implements the behaviour of removeConversation, but does not call notifyListeners at the end.

Throws:
NoSuchConversation

addListener

public void addListener(StateRepositoryListener listener)
Description copied from interface: StateRepository
Add a listener which will receive RespositoryChangedEvents.

Specified by:
addListener in interface StateRepository

removeListener

public void removeListener(StateRepositoryListener listener)
Description copied from interface: StateRepository
Remove a listener previously added with addListener().

Specified by:
removeListener in interface StateRepository

notifyListeners

@Deprecated
protected void notifyListeners(StorableInStateRepository object)
Deprecated. The RepositoryChangedEvent should have an RepositoryChangedEventType

Send a RepositoryChangedEvent to every listener registered with addListener.


notifyListeners

protected void notifyListeners(StorableInStateRepository object,
                               RepositoryChangedEventType eventType)
Send a RepositoryChangedEvent with Type RepositoryChangedEventType to every listener registered with addListener.


addObject

public void addObject(StorableInStateRepository object)
               throws NoSuchConversation,
                      ObjectAlreadyExists
Description copied from interface: StateRepository
Add this object to the repository.

Specified by:
addObject in interface StateRepository
Throws:
NoSuchConversation - if the parent isn't in the repository
ObjectAlreadyExists - if an object with the URL is already present.

dump

public abstract void dump()
For debugging


checkForUpdates

public void checkForUpdates()
Description copied from interface: StateRepository
Ensure that the repository is up-to-date. If not, events will be sent to registered listeners. This call is only needed when the repository may have been modified by another process (if two programs are using the same repository at once).

Specified by:
checkForUpdates in interface StateRepository

instantiateObject

public <T extends StorableInStateRepository> T instantiateObject(Class<T> type,
                                                                 org.apache.axis.message.addressing.EndpointReferenceType EPR)
                                                      throws ObjectAlreadyExists
Description copied from interface: StateRepository
Convenience wrapper for instantiateObject that sets the type in the EPR first.

Specified by:
instantiateObject in interface StateRepository
Throws:
ObjectAlreadyExists

instantiateObject

public StorableInStateRepository instantiateObject(org.apache.axis.message.addressing.EndpointReferenceType EPR)
                                            throws ObjectAlreadyExists
Description copied from interface: StateRepository
Create a new object, in the same way that the StateRepository does when loading saved instances.

Specified by:
instantiateObject in interface StateRepository
Throws:
ObjectAlreadyExists

getOrCreateObject

public <T extends StorableInStateRepository> T getOrCreateObject(Class<T> type,
                                                                 org.apache.axis.message.addressing.EndpointReferenceType EPR)
Description copied from interface: StateRepository
Get the existing object with this EPR's ID. If there isn't one, create a new one.

Specified by:
getOrCreateObject in interface StateRepository
Parameters:
type - class of object's interface
EPR - EPR for the object to find or create
Returns:
an implementation of type for this EPR
See Also:
StateRepository.instantiateObject(org.apache.axis.message.addressing.EndpointReferenceType), StateRepository.getObject(java.net.URL)

getOrCreateObject

public StorableInStateRepository getOrCreateObject(org.apache.axis.message.addressing.EndpointReferenceType EPR)
Description copied from interface: StateRepository
Get the existing object with this EPR's ID. If there isn't one, create a new one.

Specified by:
getOrCreateObject in interface StateRepository
Parameters:
EPR - EPR for the object to find or create
Returns:
a StorableInStateRepository for this EPR
See Also:
StateRepository.instantiateObject(org.apache.axis.message.addressing.EndpointReferenceType), StateRepository.getObject(java.net.URL)


Copyright © 2001-2007 University of Southampton IT Innovation Centre. All Rights Reserved.