Class DefaultScopeContainer
- java.lang.Object
-
- com.cumulocity.microservice.context.scope.DefaultScopeContainer
-
- All Implemented Interfaces:
ScopeContainer
public class DefaultScopeContainer extends Object implements ScopeContainer
Implements a scope container.- Author:
- Darek Kaczynski
-
-
Constructor Summary
Constructors Constructor Description DefaultScopeContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
contains(String name)
Checks if a bean of given name is present within the container.Object
getObject(String name)
Gets the given bean by name.Set<String>
getObjectNames()
Gets the names of all beans within the container.void
putObject(String name, Object obj)
Puts a bean of given name into the container.Object
removeObject(String name)
Removes the bean of given name from the container.
-
-
-
Method Detail
-
getObjectNames
public Set<String> 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
public boolean contains(String name)
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
public Object getObject(String name)
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
public void putObject(String name, Object obj)
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
public Object removeObject(String name)
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
public void addDestructionCallback(String name, Runnable callback)
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
-
-