Class DefaultScopeContainer
java.lang.Object
com.cumulocity.microservice.context.scope.DefaultScopeContainer
- All Implemented Interfaces:
ScopeContainer
Implements a scope container.
- Author:
- Darek Kaczynski
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDestructionCallback
(String name, Runnable callback) Adds a detruction callback for the bean of given name.void
clear()
Clears the container destroying all contained beans.boolean
Checks if a bean of given name is present within the container.Gets the given bean by name.Gets the names of all beans within the container.void
Puts a bean of given name into the container.removeObject
(String name) Removes the bean of given name from the container.
-
Constructor Details
-
DefaultScopeContainer
public DefaultScopeContainer()
-
-
Method Details
-
getObjectNames
Description copied from interface:ScopeContainer
Gets the names of all beans within the container.- Specified by:
getObjectNames
in interfaceScopeContainer
- Returns:
- the list of contained bean names.
-
contains
Description copied from interface:ScopeContainer
Checks if a bean of given name is present within the container.- Specified by:
contains
in interfaceScopeContainer
- Parameters:
name
- the name of the bean to check.- Returns:
- true if the bean was found, false otherwise.
-
getObject
Description copied from interface:ScopeContainer
Gets the given bean by name.- Specified by:
getObject
in interfaceScopeContainer
- Parameters:
name
- the name of the bean to retrieve.- Returns:
- the bean of given name, or
null
if was not contained.
-
putObject
Description copied from interface:ScopeContainer
Puts a bean of given name into the container.- Specified by:
putObject
in interfaceScopeContainer
- Parameters:
name
- the bean name to put.obj
- the bean instance to put.
-
removeObject
Description copied from interface:ScopeContainer
Removes the bean of given name from the container.- Specified by:
removeObject
in interfaceScopeContainer
- Parameters:
name
- the name of the bean to remove.- Returns:
- the removed bean, or
null
if it was not contained.
-
addDestructionCallback
Description copied from interface:ScopeContainer
Adds a detruction callback for the bean of given name. All added callbacks will be run upon bean removal from the container.- Specified by:
addDestructionCallback
in interfaceScopeContainer
- Parameters:
name
- the name of the bean to register callback for.callback
- the destrution callback to register.
-
clear
public void clear()Description copied from interface:ScopeContainer
Clears the container destroying all contained beans.- Specified by:
clear
in interfaceScopeContainer
-