Package com.bobocode.bring.core
Class BringApplication
java.lang.Object
com.bobocode.bring.core.BringApplication
The
BringApplication class provides a simple entry point to initialize and run a BringApplicationContext.
It allows the user to create and configure a BringApplicationContext either by specifying a
base package for component scanning or by providing a class that contains configuration information.
The class includes two static methods, run(Class) and run(String), which both
perform the following steps:
- Create a new
BringApplicationContextinstance. - Register Bean definitions based on the provided class or base package.
- Create Bean objects.
- Invoke Bean Post Processors.
Usage examples:
// Example 1: Using a configuration class
BringApplicationContext context = BringApplication.run(MyConfigurationClass.class);
// Example 2: Using a base package for component scanning
BringApplicationContext context = BringApplication.run("com.example.myapp");
The BringApplication class is designed with a private constructor to enforce the use of
its static methods for initializing and running the application context.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor to prevent instantiation of the class. -
Method Summary
Modifier and TypeMethodDescriptionprivate static String[]basePackages(String... basePackage) static BringApplicationContextRun the Bring application context based on the provided configuration class.static BringApplicationContextRun the Bring application context based on the provided base package for component scanning.static BringApplicationContextRun the Bring application context based on the provided base package for component scanning.
-
Field Details
-
BRING_PACKAGE
- See Also:
-
-
Constructor Details
-
BringApplication
private BringApplication()Private constructor to prevent instantiation of the class. Instances of this class should be created using the static methodsrun(Class)orrun(String).
-
-
Method Details
-
run
Run the Bring application context based on the provided configuration class.- Parameters:
clazz- the class containing configuration information and annotated beans- Returns:
- the initialized
BringApplicationContextinstance - See Also:
-
run
Run the Bring application context based on the provided base package for component scanning.- Parameters:
basePackage- the base package to scan for annotated beans- Returns:
- the initialized
BringApplicationContextinstance - See Also:
-
run
Run the Bring application context based on the provided base package for component scanning.- Parameters:
basePackages- the base packages to scan for annotated beans- Returns:
- the initialized
BringApplicationContextinstance
-
basePackages
-