Junior — Middle
What classes can you name for configuring a container?
sobes.tech AI
Answer from AI
To configure a container in Java applications, especially in the context of the Spring Framework, the following classes can be named:
- ApplicationContext — the main container interface that loads configuration and manages the lifecycle of beans.
- AnnotationConfigApplicationContext — a container configured using Java annotations.
- ClassPathXmlApplicationContext — a container that loads configuration from XML files in the classpath.
- GenericApplicationContext — a versatile container that can be configured programmatically.
In Java EE:
- ServletContext — a container for web components.
- EJB container — manages the lifecycle of Enterprise Java Beans.
Example of creating a Spring container with Java configuration:
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
MyBean bean = context.getBean(MyBean.class);
context.close();