0% found this document useful (0 votes)
15 views30 pages

Screenshot From 2024-05-28 16-46-45 (30 Files Merged)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views30 pages

Screenshot From 2024-05-28 16-46-45 (30 Files Merged)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

SPRING

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

The first milestone release - 1.0

October 2006 Spring2.0

November 2007 Spring2.5

December 2009 Spring3.0

December 2011 Spring3.1


BENEFITS
• Spring enables developersto develop enterprise-class applications using
POJOs.
• Spring is organized in a modular fashion.
• Spring does not reinvent thewheelinstead,it truly makes useof some of
the existing technologies.
• Testingan applicationwritten with Springis simple because environment­
dependent code is moved into this framework.
• Spring's webframework is a well-designed web MVC framework.
• Lightweight loC containerstend to be lightweight,especially when
compared to EJB containers.
• Spring provides a consistent transaction management.
SPRING 10
PLATFORM

---
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

( Beans )( Core )( Conxt

(
)
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)

implementation forweb applications. Spring's MVC framework provides a clean


separation between domainmodelcode andweb forms,and integrates withall the other
features of the SpringFramework.
• The Web-Portlet module provides the MVC implementation to be used in a portlet
environment and mirrors the functionality of Web-Serv iet module.
• The Web-Struts module contains the support classes for integratinga classic Struts
web tierwithina Springapplication.
ENVIRONMENT
SETUP
ECLIPSE
• Download Eclipse from http://www.eclipse.org/downloads

• Decompress downloaded file into the directory of your


choice (e.g."C:\Eclipse" on Windows)

• ???

• PROFIT!!!
MAVEN
INTEGRATION FOR
• Open Eclipse
ECLIPSE
• Go to Help -> Eclipse Marketplace

• Search by Maven

• Click "Install" button at "Maven Integration for Eclipse"


section

• Follow the instruction step by step


HELLO WORLD

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.

•is a concept in application development


•"don't call me,I'll call you"
•one form is Dependency Injection (DI)
I NVERSION OF
CONTR OL
Your Objects (POJOs)
Business

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
enterprise­specific 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.

A bean is an object that is instantiated,assembled,and


otherwise managed by a Spring loC container.These beans
are created with the configuration metadata that you supply to
the container,for example,in the form of XML <bean/>
definitions which you have already seen in previous chapters.
BEANS
·DEFINITION
The bean definition containsthe information called
configuration metadata which is needed for the container
to know the followings:

•How to create a bean

•Bean's lifecycle details

•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
<
>

You might also like