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

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

public class MemoryStateRepository
extends AbstractStateRepository

This is the simplest available StateRepository, which does no long-term storage. It is mainly useful for testing.


Field Summary
protected  HashMap<URL,StorableInStateRepository> objects
           
protected  Hashtable<QName,String> properties
           
 
Fields inherited from class uk.ac.soton.ecs.iam.grid.client.staterepos.AbstractStateRepository
log
 
Constructor Summary
MemoryStateRepository()
           
 
Method Summary
protected  void addObjectInternal(StorableInStateRepository object)
           
 void checkForUpdates()
          Since a MemoryStateRepository is always up-to-date, this method does nothing.
protected  void deleteConversation(Conversation conversation)
          Remove conversation from the StateRepository.
 void dump()
          For debugging
 StorableInStateRepository[] getAll()
          Returns all items in the state repository
 StorableInStateRepository[] getByParent(URL parentID)
          Returns a list of all children of the given conversation.
<T extends StorableInStateRepository>
T[]
getByType(Class<T> type)
           
 Conversation getConversationByID(URL cid)
          Returns the Conversation object corresponding to the given URL.
<T extends Conversation>
T[]
getConversationsByType(Class<T> type)
          Return all conversations of the given type (a subclass of Conversation).
 StorableInStateRepository getObject(URL id)
          Get an object based on its URL.
 String getProperty(QName name)
          Get a property set with setProperty.
 StorableInStateRepository[] getToplevel()
          Returns an array of all top-level object (those whose parent is null).
protected  void notifyChangedInternal(StorableInStateRepository object)
           
protected  void removeObjectInternal(StorableInStateRepository object)
           
 void setProperty(QName name, String value)
          Set a general property on the repository.
 
Methods inherited from class uk.ac.soton.ecs.iam.grid.client.staterepos.AbstractStateRepository
addListener, addObject, getAccountConversations, getOrCreateObject, getOrCreateObject, instantiateObject, instantiateObject, notifyChanged, notifyChanged, notifyListeners, notifyListeners, removeListener, removeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objects

protected HashMap<URL,StorableInStateRepository> objects

properties

protected Hashtable<QName,String> properties
Constructor Detail

MemoryStateRepository

public MemoryStateRepository()
Method Detail

getConversationByID

public 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
Specified by:
getConversationByID in class AbstractStateRepository
Throws:
NoSuchConversation

getObject

public StorableInStateRepository getObject(URL id)
                                    throws NoSuchConversation
Description copied from interface: StateRepository
Get an object based on its URL.

Throws:
NoSuchConversation - if no object has this ID.

getConversationsByType

public <T extends Conversation> T[] getConversationsByType(Class<T> type)
Description copied from interface: StateRepository
Return all conversations of the given type (a subclass of Conversation).


getByType

public <T extends StorableInStateRepository> T[] getByType(Class<T> type)

getToplevel

public StorableInStateRepository[] getToplevel()
Description copied from interface: StateRepository
Returns an array of all top-level object (those whose parent is null).


getAll

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

Specified by:
getAll in interface StateRepository
Specified by:
getAll in class AbstractStateRepository

getByParent

public 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
Specified by:
getByParent in class AbstractStateRepository
Throws:
NoSuchConversation

addObjectInternal

protected void addObjectInternal(StorableInStateRepository object)
                          throws ObjectAlreadyExists
Specified by:
addObjectInternal in class AbstractStateRepository
Throws:
ObjectAlreadyExists

deleteConversation

protected void deleteConversation(Conversation conversation)
                           throws NoSuchConversation
Description copied from class: AbstractStateRepository
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.

Specified by:
deleteConversation in class AbstractStateRepository
Throws:
NoSuchConversation

removeObjectInternal

protected void removeObjectInternal(StorableInStateRepository object)
                             throws NoSuchConversation
Specified by:
removeObjectInternal in class AbstractStateRepository
Throws:
NoSuchConversation

dump

public void dump()
Description copied from class: AbstractStateRepository
For debugging

Specified by:
dump in class AbstractStateRepository

notifyChangedInternal

protected void notifyChangedInternal(StorableInStateRepository object)
Specified by:
notifyChangedInternal in class AbstractStateRepository

checkForUpdates

public void checkForUpdates()
Since a MemoryStateRepository is always up-to-date, this method does nothing.

Specified by:
checkForUpdates in interface StateRepository
Overrides:
checkForUpdates in class AbstractStateRepository

setProperty

public void setProperty(QName name,
                        String value)
Description copied from interface: StateRepository
Set a general property on the repository. This is saved with the object inside the repository. Calls notifyChanged.

Parameters:
name - a unique name for the property
value - the value of the property (null to unset)

getProperty

public String getProperty(QName name)
Description copied from interface: StateRepository
Get a property set with setProperty.

Parameters:
name - the name passed to setProperty
Returns:
the value passed to setProperty, or null if not set


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