Screenshot From 2024-05-28 16-46-45 (30 Files Merged)
Screenshot From 2024-05-28 16-46-45 (30 Files Merged)
FRAMEWOR K
TUTORIAL
AGENDA
1.Overview
2.Spring 10 Platform
3.Spring Framework
4.Environment Setup
5.Inversion of Control
6.Dependency injection
7.SpringWeb MVC
Framework 8.Spring Security
OVERVIEW
Springis the most popular application development frameworkfor
enterprise Java.Millions of developers aroundthe world use Spring
Framework to create high performing,easily testable,reusable code.
October 2002 The first version was released
June 2003 The framework was first released under the Apache 2.0 license March 2004
---
RelM!O.,I
00.A
-- RPl.it•on;il
No"
SPRING 10
Spring
PLATFORM ·CORE
Provides core support for dependency
Framework injection,transaction management,web apps,
data access,messaging and more.
Spring Protects your application with
Security comprehensive and extensible
authentication and authorization support.
Groovy Brings high-productivity dynamic
language features to the JVM.
Reacto A foundation for reactive fast
r data applications on the JVM.
SPRING 10
PLATFORM ·DATA
Spring 10 addresses modern data landscape -whether it
be document,graph,key-value,relational,or simply
unstructured files.
SPRING 10
PLATFORM
Integratio Channels,Adapters,Filters,Transforme
n ·WORKLOADS
rs
Batc Jobs,Steps,
h Readers,Writers
Big Ingestion,Export,
data Orchestration,Hadoop
Web Controllers,
REST,WebSocket
SPRING
FRAMEWOR K
Spring is the most popular application development framework
for enterprise Java.
The core features of the Spring Framework can be used in
developing any Java application, but there are extensions for
buildingweb applications on top of the Java EE platform.
Springenables you to build applications from "plainold Java
objects" (POJOs) and to apply enterprise services non-
invasively to POJOs. This capability applies to the Java SE
programming model and to full and partial Java EE.
SPRING FRAMEWOR K
·COMPONENTS
Spring FratnllWOllc
Runtime
Data Access/Integration Web
( JDBC ) B RB
(---=:-!
L::_j
(. Tranaec:tlone
0 L.:::_j L..:::_j
.)
( AOP )( Aepecte ) ( lnetrumentatk>n )
Core Container
(
)
SPRING FRAMEWOR K
• The
·CORE CONTAINER
module provides the fundamental parts of the framework,
Core
includingthe loC and Dependency Injectionfeatures.
• The Bean module provides BeanFactory which is a sophisticated
implementation of thefactory pattern.
• The Context module builds on the solid base provided by the Core
and Beans modules and it is a mediumto access any objects
defined and configured.
• The Expression Language module provides a powerful expression
language for querying and manipulatingan object graph at runtime.
SPRING FRAMEWOR
K ·DATA ACCESS
• The JDBC module provides a JDBC-abstraction layerthat removes
the need to do tedious JDBC related coding.
• The ORM module provides integration layers for popular object
relational mappingAPls,including JPA,JDO,Hibernate,and iBatis.
• The OXM module provides an abstraction layer that supports
Object/XML mapping implementations for JAXB, Castor,XMLBeans,
JiBX and XStream.
• The Java MessagingService JMS module contains features for
producingand consuming messages.
• The Transaction modulesupports programmatic and declarative
transactionmanagement for classes that implement special
interfaces andforall your POJOs.
SPRING
FRAMEWORK ·WEB
• Spring's Web module provides basic web-oriented integration features such as
multipart file-upload functionality andthe initialization of the loC containerusingservlet
listeners and aweb-oriented application context.
• The Web-Servlet module contains Spring's model-view-cont roller (MVC)
• ???
• PROFIT!!!
MAVEN
INTEGRATION FOR
• Open Eclipse
ECLIPSE
• Go to Help -> Eclipse Marketplace
• Search by Maven
httRs://github.com/soaserele/sRring-tutorial/tree/master/hello
I NVERSION OF
CONTR OL
Inversion of control (loC) is a programming technique inwhich
object coupling is bound at runtime by an assembler object
and is typically not known at compiletime using static
analysis.In order for the assembler to bind objects to one
another,the objects must possess compatible abstractions.
The Spring
Container
Configuration
Metadata
produces
Fully
configured system
Ready for
Use
I NVERSION OF
CONTR OL
The Springcontainer is at the core of the Spring Framework.
The Springcontainer uses dependency injection (DI) to
manage the components that make upan application.
The container will create the objects, wire them together,
configurethem, and manage their complete lifecycle from
creation till destruction.
The container gets its instructions onwhat objects to
instantiate,configure,and assemble by readingconfiguration
metadata provided.The configuration metadata can be
represented either by XML, Java annotations, or Java code.
DEPENDENCY
INJECTION
• Spring BeanFactory Container
CONTAINERS
This is the simplest container providing basic support for DI.There are
a number of implementations of the BeanFactory interface that come
supplied straight out-of-the-box with Spring.The most commonly
used BeanFactory implementation is the XmlBeanFactory class.
• SpringApplicationContext Container
The ApplicationContext includes all functionality of the BeanFactory,it
is generally recommended overthe BeanFactory.It adds more
enterprisespecific functionality such as the ability to resolve textual
messages from a properties file andthe ability to publish application
events to interested event listeners.
CONTAINER S
EXAMPLE
htt12s://github.com/soaserele/s12ring-tutorial/tree/master
/beanfactocv.
BEANS
BEANS
The objects that form the backbone of your application and
that are managed by the Spring loC container are called
beans.
•Bean's dependencies
BEANS
Property
·DEFINITIO
Description
class* NThe bean class to be used to create the
bean.
name The unique bean identifier.
scope The scope of the objects created from a
particular bean definition.
autowiring Used to specify autowire mode for a bean
mode definition
lazy- Tells the loC container to create a bean
IllMade with Sldes.com initialization instance when it is first requested,rather
<
>
BEANS
Propert
·DEFINITIO
Descriptio
y
constructor N
n
Used to inject the dependencies into
arg the class througha class constructor
properties Used to inject the dependencies into
the class throughsetter methods
,,.
..
BEANS
Propert
·DEFINITIO
Descriptio
y
initialization Nn
A callback to becalledjust after all
method necessary properties on the bean have
been set by the container.
destruction A callback to be used when the
method container containing the bean is
destroyed.
,,.
..
BEAN
DEFINITION
EXAMPLE
htt12s://github.com/soaserele/s12ring-tutorial/tree/master/ ,,.
beandef
..
BEANS
Scop
·SCOPES
Descriptio
e n
singleton This scopes the bean definition to a single
instance per Spring loC container
(default).
prototype This scopes a single bean definition to have
any number of object instances.
request This scopes a bean definition to an
* HTTP
request.
session This scopes a bean definition to an
* HTTP.
session.
II Made with Sldes.com global- This scopes a bean definition to a global
HTTP
<
>