SPRING OOF Flashcards
what is spring?
an app framework which focuses on concept of inversion of control containers. essentially a lightweight, integrated framework that can be used for developing enterprise applications in java
spring modules
context, AOP, DAO, JDBC, ORM, web module, MVC
spring context
for dependency injection
spring AOP
for aspect oriented programming
spring DAO
for database operations using DAO pattern
spring JDBC
for JDBC and DataSource support
spring ORM
for ORM tools support such as Hibernate
spring Web Module
for creating web apps
spring MVC
Model-View-Controller implementations for creating web applications, web services, etc.
what does core container focus on
spring beans, core, context, SpEL
important annotations in spring configuration
@required, @autowired, @qualifier, @resource, @postconstruct, @predestroy
bean
an object that is instantiated, assembled, and MANAGED BY SPRING IOC CONTAINTER
what are 5 scopes of bean
singleton, prototype, request, session, global-session
bean class
has attributes and getter/setter methods
singleton
only single object by default
prototype
every time you make a new object it will be new and different
request
1 object for entire request
session
1 object for entire request
global-session
1 object for entire global session
how is bean added to spring application?
use bean tag in XML where you add id attribute then value
dispatcherservlet
front controller in spring mvc app as it loads spring bean config file and initializes all the beans that have been configured
contextloaderlistener
listener to start up and shut down WebApplicationContext in spring root
constructor injection
inject dependency through constructor. no partial injection. doesn’t override setter property. creates new instance if any modification occurs. better for too many properties
setter injection
inject dependency through a setter method. partial injection. overrides the constructor property if both are defined. doesn’t create new instance if you change property value. better for few properties