Package com.bobocode.bring.core.context
Interface BringBeanFactory
- All Known Implementing Classes:
AnnotationBringBeanRegistry
,BringApplicationContext
,DefaultBringBeanFactory
public interface BringBeanFactory
An interface representing a simplified Bean Factory, allowing retrieval of beans by type or name.
Implementations of this interface provide methods to retrieve beans based on specified criteria.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the container.This method is typically called when the container is being shut down to allow beans to perform necessary cleanup operations or release resources before being destroyed.Retrieve a map containing all registered beans, where the key is the bean name and the value is the bean instance.<T> T
Retrieve a bean of the specified type.<T> T
Retrieve a bean of the specified type and name.Retrieve a map of beans of the specified type, where the key is the bean name and the value is the bean instance.
-
Method Details
-
getBean
Retrieve a bean of the specified type.- Type Parameters:
T
- The type of the bean.- Parameters:
type
- The class/type of the bean to retrieve.- Returns:
- An instance of the requested bean or throw NoSuchBeanException
-
getBean
Retrieve a bean of the specified type and name.- Type Parameters:
T
- The type of the bean.- Parameters:
type
- The class/type of the bean to retrieve.name
- The name of the bean to retrieve.- Returns:
- An instance of the requested bean or throw NoSuchBeanException
-
getBeans
Retrieve a map of beans of the specified type, where the key is the bean name and the value is the bean instance.- Type Parameters:
T
- The type of the beans.- Parameters:
type
- The class/type of the beans to retrieve.- Returns:
- A map containing bean names as keys and corresponding bean instances as values or throw NoSuchBeanException
-
getAllBeans
Retrieve a map containing all registered beans, where the key is the bean name and the value is the bean instance.- Type Parameters:
T
- The type of the beans.- Returns:
- A map containing all registered bean names as keys and corresponding bean instances as values.
-
close
void close()Closes the container.This method is typically called when the container is being shut down to allow beans to perform necessary cleanup operations or release resources before being destroyed.
-