public class WriteableBeanDatabaseImpl extends java.lang.Object implements WriteableBeanDatabase
Modifier and Type | Class and Description |
---|---|
private class |
WriteableBeanDatabaseImpl.TwoPhaseResourceImpl |
Modifier and Type | Field and Description |
---|---|
private long |
baseRevision |
private java.util.LinkedList<Change> |
changes |
private java.lang.Object |
commitMessage |
private boolean |
committed |
private HubImpl |
hub |
private java.util.LinkedList<WriteableTypeImpl> |
removedTypes |
private WriteableBeanDatabaseImpl.TwoPhaseResourceImpl |
resource |
private java.util.HashMap<java.lang.String,WriteableTypeImpl> |
types |
Constructor and Description |
---|
WriteableBeanDatabaseImpl(HubImpl hub,
BeanDatabaseImpl currentDatabase) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addChange(Change change) |
WriteableType |
addType(java.lang.String typeName)
Adds a type of the given name
|
private void |
checkState() |
void |
commit()
This method should be called when the writeable database should become
the current database.
|
void |
commit(java.lang.Object commitMessage)
This method should be called when the writeable database should become
the current database.
|
void |
dumpDatabase()
Dumps the type and instance names to stderr
|
void |
dumpDatabase(java.io.PrintStream output)
Dumps the type and instance names to the given stream
|
java.lang.String |
dumpDatabaseAsString()
Dumps the type and instance names to a String for debugging
|
WriteableType |
findOrAddWriteableType(java.lang.String typeName)
Gets or creates a writeable type with the given name
|
java.util.Set<Type> |
getAllTypes()
Gets an unmodifiable set of all the types in the bean database
|
java.util.Set<WriteableType> |
getAllWriteableTypes()
Gets an unmodifiable set of all the types in the bean database
|
(package private) long |
getBaseRevision() |
private java.lang.String |
getChanges() |
java.lang.Object |
getCommitMessage()
Gets the commit message for this writeable bean database
|
Instance |
getInstance(java.lang.String type,
java.lang.String instanceKey)
Returns the instance with the given instanceKey from the
type with the given name
|
TwoPhaseResource |
getTwoPhaseResource()
Returns a two-phase resource that can be used by a
DynamicConfiguration to tie the transaction done by
this WriteableBeanDatabase into a commit done by the
DynamicConfiguration.
|
Type |
getType(java.lang.String type)
Gets the type with the given name
|
WriteableType |
getWriteableType(java.lang.String typeName)
Gets a writeable type of the given name
|
Type |
removeType(java.lang.String typeName)
Removed the given type and all of its instances from the database.
|
void |
setCommitMessage(java.lang.Object commitMessage)
Sets the commit message for this writeable bean database
|
java.lang.String |
toString() |
private final long baseRevision
private final java.util.HashMap<java.lang.String,WriteableTypeImpl> types
private final HubImpl hub
private final WriteableBeanDatabaseImpl.TwoPhaseResourceImpl resource
private final java.util.LinkedList<Change> changes
private final java.util.LinkedList<WriteableTypeImpl> removedTypes
private boolean committed
private java.lang.Object commitMessage
WriteableBeanDatabaseImpl(HubImpl hub, BeanDatabaseImpl currentDatabase)
public java.util.Set<Type> getAllTypes()
BeanDatabase
getAllTypes
in interface BeanDatabase
public java.util.Set<WriteableType> getAllWriteableTypes()
WriteableBeanDatabase
getAllWriteableTypes
in interface WriteableBeanDatabase
public Type getType(java.lang.String type)
BeanDatabase
getType
in interface BeanDatabase
type
- The non-null namepublic Instance getInstance(java.lang.String type, java.lang.String instanceKey)
BeanDatabase
getInstance
in interface BeanDatabase
type
- The non-null name of the type to get the instance frominstanceKey
- The non-null key of the instanceprivate void checkState()
public WriteableType addType(java.lang.String typeName)
WriteableBeanDatabase
addType
in interface WriteableBeanDatabase
typeName
- The name of the type to addpublic Type removeType(java.lang.String typeName)
WriteableBeanDatabase
removeType
in interface WriteableBeanDatabase
typeName
- The non-null type namepublic WriteableType getWriteableType(java.lang.String typeName)
WriteableBeanDatabase
getWriteableType
in interface WriteableBeanDatabase
typeName
- The non-null name of the type to fetchpublic WriteableType findOrAddWriteableType(java.lang.String typeName)
WriteableBeanDatabase
findOrAddWriteableType
in interface WriteableBeanDatabase
typeName
- The non-null name of the type to find or createpublic void commit()
WriteableBeanDatabase
commit
in interface WriteableBeanDatabase
public void commit(java.lang.Object commitMessage)
WriteableBeanDatabase
commit
in interface WriteableBeanDatabase
commitMessage
- An object to pass to any BeanDatabaseUpdateListener
that is registeredlong getBaseRevision()
void addChange(Change change)
public void dumpDatabase()
BeanDatabase
dumpDatabase
in interface BeanDatabase
public void dumpDatabase(java.io.PrintStream output)
BeanDatabase
dumpDatabase
in interface BeanDatabase
output
- - The non-null outut stream to write the database topublic java.lang.String dumpDatabaseAsString()
BeanDatabase
dumpDatabaseAsString
in interface BeanDatabase
public TwoPhaseResource getTwoPhaseResource()
WriteableBeanDatabase
getTwoPhaseResource
in interface WriteableBeanDatabase
public java.lang.Object getCommitMessage()
WriteableBeanDatabase
getCommitMessage
in interface WriteableBeanDatabase
public void setCommitMessage(java.lang.Object commitMessage)
WriteableBeanDatabase
setCommitMessage
in interface WriteableBeanDatabase
commitMessage
- The possibly null commit message
for this writeable bean databaseprivate java.lang.String getChanges()
public java.lang.String toString()
toString
in class java.lang.Object