Class WriteableBeanDatabaseImpl
java.lang.Object
org.glassfish.hk2.configuration.hub.internal.WriteableBeanDatabaseImpl
- All Implemented Interfaces:
BeanDatabase
,WriteableBeanDatabase
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private final LinkedList
<Change> private Object
private boolean
private final HubImpl
private final LinkedList
<WriteableTypeImpl> private final WriteableBeanDatabaseImpl.TwoPhaseResourceImpl
private final HashMap
<String, WriteableTypeImpl> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
Adds a type of the given nameprivate void
void
commit()
This method should be called when the writeable database should become the current database.void
This method should be called when the writeable database should become the current database.void
Dumps the type and instance names to stderrvoid
dumpDatabase
(PrintStream output) Dumps the type and instance names to the given streamDumps the type and instance names to a String for debuggingfindOrAddWriteableType
(String typeName) Gets or creates a writeable type with the given nameGets an unmodifiable set of all the types in the bean databaseGets an unmodifiable set of all the types in the bean database(package private) long
private String
Gets the commit message for this writeable bean databasegetInstance
(String type, String instanceKey) Returns the instance with the given instanceKey from the type with the given nameReturns 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.Gets the type with the given namegetWriteableType
(String typeName) Gets a writeable type of the given nameremoveType
(String typeName) Removed the given type and all of its instances from the database.void
setCommitMessage
(Object commitMessage) Sets the commit message for this writeable bean databasetoString()
-
Field Details
-
baseRevision
private final long baseRevision -
types
-
hub
-
resource
-
changes
-
removedTypes
-
committed
private boolean committed -
commitMessage
-
-
Constructor Details
-
WriteableBeanDatabaseImpl
WriteableBeanDatabaseImpl(HubImpl hub, BeanDatabaseImpl currentDatabase)
-
-
Method Details
-
getAllTypes
Description copied from interface:BeanDatabase
Gets an unmodifiable set of all the types in the bean database- Specified by:
getAllTypes
in interfaceBeanDatabase
- Returns:
- A non-null unmodifiable and possibly empty set of all the types in the database
-
getAllWriteableTypes
Description copied from interface:WriteableBeanDatabase
Gets an unmodifiable set of all the types in the bean database- Specified by:
getAllWriteableTypes
in interfaceWriteableBeanDatabase
- Returns:
- A non-null unmodifiable and possibly empty set of all the types in the database
-
getType
Description copied from interface:BeanDatabase
Gets the type with the given name- Specified by:
getType
in interfaceBeanDatabase
- Parameters:
type
- The non-null name- Returns:
- The type corresponding to the given name. May return null
-
getInstance
Description copied from interface:BeanDatabase
Returns the instance with the given instanceKey from the type with the given name- Specified by:
getInstance
in interfaceBeanDatabase
- Parameters:
type
- The non-null name of the type to get the instance frominstanceKey
- The non-null key of the instance- Returns:
- The bean from the given type with the given name. Will return null if the type does not exist or an instance with that key does not exist
-
checkState
private void checkState() -
addType
Description copied from interface:WriteableBeanDatabase
Adds a type of the given name- Specified by:
addType
in interfaceWriteableBeanDatabase
- Parameters:
typeName
- The name of the type to add- Returns:
- The non-null type that has been added to the database
-
removeType
Description copied from interface:WriteableBeanDatabase
Removed the given type and all of its instances from the database. The set of changes will include the instances removed prior to the change indicating that the type was removed- Specified by:
removeType
in interfaceWriteableBeanDatabase
- Parameters:
typeName
- The non-null type name- Returns:
- The type that was removed
-
getWriteableType
Description copied from interface:WriteableBeanDatabase
Gets a writeable type of the given name- Specified by:
getWriteableType
in interfaceWriteableBeanDatabase
- Parameters:
typeName
- The non-null name of the type to fetch- Returns:
- The existing type, or null if the type does not already exist
-
findOrAddWriteableType
Description copied from interface:WriteableBeanDatabase
Gets or creates a writeable type with the given name- Specified by:
findOrAddWriteableType
in interfaceWriteableBeanDatabase
- Parameters:
typeName
- The non-null name of the type to find or create- Returns:
- The non-null writeable type that was created or found
-
commit
public void commit()Description copied from interface:WriteableBeanDatabase
This method should be called when the writeable database should become the current database. All changes will be communicated to the listeners. If the current database has been modified since this writeable database was created then this method will throw an IllegalStateException. This version of commit will use the commit message set on this writeable bean database- Specified by:
commit
in interfaceWriteableBeanDatabase
-
commit
Description copied from interface:WriteableBeanDatabase
This method should be called when the writeable database should become the current database. All changes will be communicated to the listeners. If the current database has been modified since this writeable database was created then this method will throw an IllegalStateException. This version of commit will use the commit message passed in rather than the one set on this writeable bean database- Specified by:
commit
in interfaceWriteableBeanDatabase
- Parameters:
commitMessage
- An object to pass to anyBeanDatabaseUpdateListener
that is registered
-
getBaseRevision
long getBaseRevision() -
addChange
-
dumpDatabase
public void dumpDatabase()Description copied from interface:BeanDatabase
Dumps the type and instance names to stderr- Specified by:
dumpDatabase
in interfaceBeanDatabase
-
dumpDatabase
Description copied from interface:BeanDatabase
Dumps the type and instance names to the given stream- Specified by:
dumpDatabase
in interfaceBeanDatabase
- Parameters:
output
- - The non-null outut stream to write the database to
-
dumpDatabaseAsString
Description copied from interface:BeanDatabase
Dumps the type and instance names to a String for debugging- Specified by:
dumpDatabaseAsString
in interfaceBeanDatabase
- Returns:
- A string with all type and instance names
-
getTwoPhaseResource
Description copied from interface:WriteableBeanDatabase
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. When the DynamicConfiguration calls commit this WriteableBeanDatabase will be part of the transaction- Specified by:
getTwoPhaseResource
in interfaceWriteableBeanDatabase
- Returns:
- A non-null TwoPhaseResource to be used by a DynamicConfiguration
-
getCommitMessage
Description copied from interface:WriteableBeanDatabase
Gets the commit message for this writeable bean database- Specified by:
getCommitMessage
in interfaceWriteableBeanDatabase
- Returns:
- The possibly null commit message for this writeable bean database
-
setCommitMessage
Description copied from interface:WriteableBeanDatabase
Sets the commit message for this writeable bean database- Specified by:
setCommitMessage
in interfaceWriteableBeanDatabase
- Parameters:
commitMessage
- The possibly null commit message for this writeable bean database
-
getChanges
-
toString
-