Java Interview Guide: How to Build Confidence With a Solid Understanding of Core Java Principles pdfdrive com



Yüklə 0,53 Mb.
Pdf görüntüsü
səhifə35/47
tarix06.05.2023
ölçüsü0,53 Mb.
#108601
1   ...   31   32   33   34   35   36   37   38   ...   47
Java Interview Guide

The Spring Container
The Spring framework is one of the most popular extensions to the Java
language. Although the Spring library has spread into numerous domains,
the heart of the library is a dependency injection container. The Spring container
is responsible for instantiating, configuring, and injecting components (called
beans) into a running application.


Spring Configuration
The Spring container requires configuration that defines beans and their
relationship within an application. Configuration can be provided in the form
of XML, annotations, or java code. XML configuration is commonly used due
to its intuitive nature, but it’s susceptible to refactoring errors because the names
of classes and packages often change. Annotations provide an alternative
to XML, but the resulting configuration is decentralized and any changes require
modifications to the source code. Java configuration files combine the
centralized configuration of XML with the convenience of annotations, but it
lacks some of the flexibility that XML provides.


Spring Lifecycle
The Spring container begins by instantiating an ApplicationContext with
one of the available configuration options. The container instantiates all of the
beans and injects their dependencies via constructor injection, setter injection,
or reflection. Finally, the container invokes callback methods on beans that hook
into the lifecycle of the container. For example, the container will invoke the
afterPropertiesSet()
method on any bean that implements the
InitializingBean
interface.


Questions
What is the inversion of control pattern?
What is the difference between a service locator and dependency injection?
What is the difference between constructor injection and setter injection?
What is the Spring container?
What are the different ways of configuring a Spring container?
What is the lifecycle of a Spring container?



Yüklə 0,53 Mb.

Dostları ilə paylaş:
1   ...   31   32   33   34   35   36   37   38   ...   47




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin