Interface ScopeContainer
- All Known Implementing Classes:
DefaultScopeContainer
public interface ScopeContainer
Defines a scope container.
- Author:
- Darek KaczyĆski
-
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.
-
Method Details
-
getObjectNames
Gets the names of all beans within the container.- Returns:
- the list of contained bean names.
- Throws:
IllegalStateException
- if the scope container is currently in destruction.
-
contains
Checks if a bean of given name is present within the container.- Parameters:
name
- the name of the bean to check.- Returns:
- true if the bean was found, false otherwise.
- Throws:
IllegalStateException
- if the whole container is currently in destruction.
-
getObject
Gets the given bean by name.- Parameters:
name
- the name of the bean to retrieve.- Returns:
- the bean of given name, or
null
if was not contained. - Throws:
IllegalStateException
- if object of given name or the whole container is currently in destruction.
-
putObject
Puts a bean of given name into the container.- Parameters:
name
- the bean name to put.obj
- the bean instance to put.- Throws:
IllegalArgumentException
- if an object for given name is already present in the container.IllegalStateException
- if object of given name or the whole container is currently in destruction.
-
removeObject
Removes the bean of given name from the container.- Parameters:
name
- the name of the bean to remove.- Returns:
- the removed bean, or
null
if it was not contained. - Throws:
IllegalStateException
- if object of given name or the whole container is currently in destruction.
-
addDestructionCallback
Adds a detruction callback for the bean of given name. All added callbacks will be run upon bean removal from the container.- Parameters:
name
- the name of the bean to register callback for.callback
- the destrution callback to register.- Throws:
IllegalStateException
- if object of given name or the whole container is currently in destruction.
-
clear
void clear()Clears the container destroying all contained beans.- Throws:
IllegalStateException
- if the scope container is already during destruction.
-