- Objective
- What is the spring Framework?
- Why Spring framework came out?
- What is spring architecture?
- Spring Beans
- What is dependency injection & inversion of control?
- What is aspect-oriented programming?
- Spring MVC
- Hibernate
- Resources
- grasp spring concepts
- learn the theory behind the Spring framework
- it's a web framework for building web apps using java
- released in 2004
- to solve complex configurations in a java enterprise edition that uses java enterprise beans (EJB)
- also to enhance poor performance
- create loosely coupled software
- spring introduces a layered architecture; each layer contains a set of modules (~20 modules)
- through this layered architecture spring achieved one-stop-shop philosophy
- Modules:
- Core: contains dependency injection and inversion of control which uses a factory design pattern
- Aspect-oriented programming: to remove cross-cutting concerns
- Data access: contains JDBC, ORM
- Web: contains servlets, web sockets
- Simply, a bean is a java object which is created and destroyed through spring IOC and DI
-
bean scope is responsible for deciding:
- How long will the bean live?
- How many instances will be created?
Scope Description Singleton Default scope, create one instance per Spring container Prototype Create a new instance every time the bean is requested Request Single bean instance per HTTP request Session Single bean instance per HTTP session Global-session Single bean instance per global HTTP session
- It's a process of delegating instantiation and assembling objects into:
- XML files
- XML using annotations
- other java code
- and to inject object dependencies you have to use:
- Constructor injection
- Setter injection
- it's a programming paradigm that aims to increase modularity by separating cross-cutting concerns
- Steps:
- Define point-cut (logger, security) "cross-cutting concern"
- Define those points into something called aspect
- Define configuration for each aspect (when-where you want to call this aspect)
- It's a spring framework for building web-apps by applying model-view-controller architectural style
- Separation of concerns which make your app able to:
- scale easily.
- be tested
- be developed in a fast and parallel fashion
- It's an object-relational mapping that relies on a layer in between app and database to handle conversion between tables and classes
- Java App ⇒ hibernate ⇒ JDBC ⇒ DB
- transient (un-tracked)
- persist (attached to the database so any change that happens will reflect on the database)
- detached
- removed
- Apply the same changes-operations to related entities
- Types:
- Save
- Delete
- Detach
- All
- Remove
- merge
- Eager: loads all data at once
- Lazy: loads data whenever it's required-requested