SlideShare a Scribd company logo
1 of 73
Lightweight Enterprise
Java Development using
   Spring Framework
        Oleksiy Rezchykov
         Eugene Scripnik
About us
 Software Engineers

 Working with Spring since 2006

 Pragmatic programmers

 SpringByExample.com.ua
   founders




                  SpringByExample.com.ua
                                           2
                   @ua_spring #uadevclub
Contents
 Spring origins

 IoC using Spring

 Persistence with Spring

 Declarative caching using @Cachable

 Web applications with Spring MVC

 Spring ecosystem

 Framework criticism
                     SpringByExample.com.ua
                                              3
                      @ua_spring #uadevclub
J2EE 5
Development




  SpringByExample.com.ua
                           4
   @ua_spring #uadevclub
SpringFramework
             history
 In October 2002 Rod Johnson wrote
   his famous book

 The first milestone release 1.0 -
   June 2004

 Company renamed from Interface21
   to SpringSource in 2007

 SpringSource acquired by VMWare
   in 2009

 Rod Johnson left VMWare – July
   2012
                     SpringByExample.com.ua
                                              5
                      @ua_spring #uadevclub
Inversion of Control
 Inversion of regular approach where object was
   responsible for satisfying it’s own dependencies

 Implementation of Dependency Injection

 Container instantiates and wires dependencies




                   SpringByExample.com.ua
                                                      6
                    @ua_spring #uadevclub
Injection types
 Setter injection– when you are using setter to fulfill
   bean dependency

 Constructor injection – when constructor is called to
   set-up a bean with dependencies

 Method injection




                     SpringByExample.com.ua
                                                           7
                      @ua_spring #uadevclub
Context
 An object which contains beans declarations with
   their dependencies

 BeanFactory interface implementation




                   SpringByExample.com.ua
                                                     8
                    @ua_spring #uadevclub
XML namespaces




    SpringByExample.com.ua
                             9
     @ua_spring #uadevclub
Context




SpringByExample.com.ua
                         10
 @ua_spring #uadevclub
Context usage




   SpringByExample.com.ua
                            11
    @ua_spring #uadevclub
Bean lifecycle
 Depends on scope and lazy initialization

 Main bean scopes:

 Singleton and Prototype

(Also there are multiple web scopes)




                   SpringByExample.com.ua
                                             12
                    @ua_spring #uadevclub
Bean instantiation order




        SpringByExample.com.ua
                                 13
         @ua_spring #uadevclub
Bean Post-processing
                • Bean instantiated for singletons with
    Bean
instantiation
                  eager initialization


Dependency
                • Dependencies are injected into beans
 injection



                • Bean post-processing actions
Bean post-
processing
                • You can put your custom logic in here


                         SpringByExample.com.ua
                                                          14
                          @ua_spring #uadevclub
Map, List, Set, Prop, Nul
            l




         SpringByExample.com.ua
                                  15
          @ua_spring #uadevclub
Map, List, Set, Prop, Nul
            l




         SpringByExample.com.ua
                                  16
          @ua_spring #uadevclub
Util namespace




   SpringByExample.com.ua
                            17
    @ua_spring #uadevclub
Component model




    SpringByExample.com.ua
                             18
     @ua_spring #uadevclub
@Autowired
 Spring proprietary annotation for property injection

 Supports @Qualifier to select implementation by
   name if more than one exists in context

 Has required parameter to enforce dependency
   loading




                    SpringByExample.com.ua
                                                         19
                     @ua_spring #uadevclub
@Autowired




  SpringByExample.com.ua
                           20
   @ua_spring #uadevclub
@Inject
 Context and Dependency Injection (CDI) standard
   JSR-299




                  SpringByExample.com.ua
                                                    21
                   @ua_spring #uadevclub
@Resource
 JSR 250 (Common annotations)

 Supports @PostConstruct and @PreDestroy as
  well




                 SpringByExample.com.ua
                                               22
                  @ua_spring #uadevclub
Resource loading and
       i18n




      SpringByExample.com.ua
                               23
       @ua_spring #uadevclub
Resource loading and
       i18n




      SpringByExample.com.ua
                               24
       @ua_spring #uadevclub
SpEl
 Stands for Spring Expression Language

 Can be used in the xml context

 Can be used in bean classes




                  SpringByExample.com.ua
                                           25
                   @ua_spring #uadevclub
SpEl




SpringByExample.com.ua
                         26
 @ua_spring #uadevclub
Java Spring Config
 @Configuration

 @Bean

 Support for Environment and Profiles




                   SpringByExample.com.ua
                                            27
                    @ua_spring #uadevclub
Java Spring Config




     SpringByExample.com.ua
                              28
      @ua_spring #uadevclub
Environment abstraction
   & context profiles
 Environment abstraction introduced in Spring 3.1

 Can be declaratively and programmatically
   configured

 Affects property resolution

 Affects bean profiles




                   SpringByExample.com.ua
                                                     29
                    @ua_spring #uadevclub
Environment abstraction
   & context profiles




        SpringByExample.com.ua
                                 30
         @ua_spring #uadevclub
AOP
A programming paradigm which allows to separate
cross-cutting concerns

Cross-cutting logic:

 Logging

 Tracing

 Security




                       SpringByExample.com.ua
                                                  31
                        @ua_spring #uadevclub
AOP
 Aspect

 Advice

 Join point

 Pointcut




               SpringByExample.com.ua
                                        32
                @ua_spring #uadevclub
AOP




SpringByExample.com.ua
                         33
 @ua_spring #uadevclub
Spring AOP
 Spring AOP defaults to using standard J2SE
   dynamic proxies for AOP proxies. This enables any
   interface (or set of interfaces) to be proxied.

 Spring AOP can also use CGLIB proxies. This is
   necessary to proxy classes, rather than interfaces

 It is good practice to program to interfaces rather
   than classes, business classes normally will
   implement one or more business interfaces.



                    SpringByExample.com.ua
                                                        34
                     @ua_spring #uadevclub
AspectJ
 Spring AOP is often uses the AspectJ declaration
   style
 AspectJ itself uses Load Time Weaving (LTW) to
   modify the bean code according to Aspect logic
 LTW could do much more than dynamic proxies but it
   is more time-consuming operation. This means that
   LTW has a performance drawback.




                 SpringByExample.com.ua
                                                       35
                  @ua_spring #uadevclub
“pure” AspectJ




   SpringByExample.com.ua
                            36
    @ua_spring #uadevclub
“pure” AspectJ




   SpringByExample.com.ua
                            37
    @ua_spring #uadevclub
Persistence with Spring
 Building DAO

 Spring Data

 Embedded Datasources

 JDBC vs ORM DAO’s

 Integration testing with Spring

 @Transactional & transactions with Spring



                    SpringByExample.com.ua
                                              38
                     @ua_spring #uadevclub
Spring supports
 JDBC

 JPA

 JDO

 Concrete ORM




                 SpringByExample.com.ua
                                          39
                  @ua_spring #uadevclub
Spring Data
 RDBMS: JPA, JDBC Extensions

 BigData: ApacheHadoop

 DataGrid: GermFire

 HTTP: REST

 Key-value stores: Redis

 Document Stores: MongoDB

 Graph Databases: Neo4j

 Column stores: Hbase

                    SpringByExample.com.ua
                                             40
                     @ua_spring #uadevclub
Persistence layer
           • Persistence service which has domain specific logic
 Service



           • Spring JDBCTemplate
           • SessionFactory, EntityManagerFactory
Repository
 (DAO)     • Redis/Mongo template



           • RDBMS (or NoSQL)
   DB




                         SpringByExample.com.ua
                                                                   41
                          @ua_spring #uadevclub
JDBCTemplate
 Useful interface

 No boilerplate code

 Exception handling




                     SpringByExample.com.ua
                                              42
                      @ua_spring #uadevclub
JDBCTemplate




   SpringByExample.com.ua
                            43
    @ua_spring #uadevclub
JDBC namespace




    SpringByExample.com.ua
                             44
     @ua_spring #uadevclub
Spring Data JPA
 CRUD




         SpringByExample.com.ua
                                  45
          @ua_spring #uadevclub
Spring Data JPA
 Query DSL




              SpringByExample.com.ua
                                       46
               @ua_spring #uadevclub
Transactions in Spring
 Support for ACID transactions

 Declarative and programmatic




                  SpringByExample.com.ua
                                           47
                   @ua_spring #uadevclub
Transaction managers
 Spring support both container managed and
   framework managed transactions

Managers:

 DataSourceTransactionManager

 HibernateTransactionManager

 JPATransactionManager

 JTATransactionManager


                  SpringByExample.com.ua
                                              48
                   @ua_spring #uadevclub
@Transactional
 Transaction propagation

 Read-only transactions

 Built using Spring AOP




                  SpringByExample.com.ua
                                           49
                   @ua_spring #uadevclub
Persistence layer testing
 Context loading in test

 Environment abstraction and profiles usage

 Transactional methods

 Embedded data source could be used




                   SpringByExample.com.ua
                                               50
                    @ua_spring #uadevclub
Persistence layer testing




         SpringByExample.com.ua
                                  51
          @ua_spring #uadevclub
@Cacheable
 One-two-three magic (not always work as expected)

 Support for JCache (JSR-107)




                  SpringByExample.com.ua
                                                      52
                   @ua_spring #uadevclub
@Cacheable
 <cache:annotation-driven> or @EnableCaching

 CacheManager instance in the context

 @Cacheable, @CachePut, @CacheEvict




                  SpringByExample.com.ua
                                                53
                   @ua_spring #uadevclub
Spring MVC
 Application context

 Dispatcher Servlet and it’s context

 Controllers and mappings

 Implementing CRUD logic

 REST

 Testing MVC



                   SpringByExample.com.ua
                                            54
                    @ua_spring #uadevclub
Application & Dispatcher
     servlet context




        SpringByExample.com.ua
                                 55
         @ua_spring #uadevclub
Front controller and
       MVC




      SpringByExample.com.ua
                               56
       @ua_spring #uadevclub
URL mappings
 @RequestMapping




               SpringByExample.com.ua
                                        57
                @ua_spring #uadevclub
View resolvers
 AbstractCachingViewResolver

 XmlViewResolver

 ResourceBundleViewResolver

 UrlBasedViewResolver

 InternalResourceViewResolver

 VelocityViewResolver / FreeMarkerViewResolver

 ContentNegotiatingViewResolver
                  SpringByExample.com.ua
                                                  58
                   @ua_spring #uadevclub
View resolvers




   SpringByExample.com.ua
                            59
    @ua_spring #uadevclub
CRUD in one place




     SpringByExample.com.ua
                              60
      @ua_spring #uadevclub
REST in Spring MVC
 Starting Spring 3.1.x

 ContentNegotiatingViewResolver

 @ResponseBody combined with produces

 @RequestBody combined with consumes




                   SpringByExample.com.ua
                                            61
                    @ua_spring #uadevclub
REST in Spring MVC




      SpringByExample.com.ua
                               62
       @ua_spring #uadevclub
Testing MVC
 Starting from Spring 3.2

 spring-test-mvc project

 Server-side Spring MVC tests

 New Spring Mocks

 Different strategies




                   SpringByExample.com.ua
                                            63
                    @ua_spring #uadevclub
Testing MVC




  SpringByExample.com.ua
                           64
   @ua_spring #uadevclub
Testing MVC




  SpringByExample.com.ua
                           65
   @ua_spring #uadevclub
Just to mention
 Type conversion

 Formatter SPI




                    SpringByExample.com.ua
                                             66
                     @ua_spring #uadevclub
Just to mention
 Type conversion

 Formatter SPI




                    SpringByExample.com.ua
                                             67
                     @ua_spring #uadevclub
Just to mention
 Flash attributes and Redirect attributes




                    SpringByExample.com.ua
                                             68
                     @ua_spring #uadevclub
Spring in 2012




   SpringByExample.com.ua
                            69
    @ua_spring #uadevclub
Just to mention
 Spring Roo

 Spring Hadoop

 Spring Android




                   SpringByExample.com.ua
                                            70
                    @ua_spring #uadevclub
Criticism
 Every tool should be used only if you could not
   solve your task without it – KISS

 When a lot of stuff come out-of-the-box it is not
   always good - YAGNI

 When something is broken it is pain in the …

 Open source but VMWare




                    SpringByExample.com.ua
                                                      71
                     @ua_spring #uadevclub
Sources
 http://static.springsource.org/spring/docs/3.1.x/sprin
   g-framework-reference/html/index.html

 https://github.com/springbyexample/spring-by-
   example

 https://github.com/mcgray/spring-vaadin

 http://rstoyanchev.github.com/spring-32-test-
   webapps/



                    SpringByExample.com.ua
                                                           72
                     @ua_spring #uadevclub
Questions?
@ua_spring


oleksiy.rezchykov@gmail.com
eugene.scripnik@gmail.com


SpringByExample.com.ua

    SpringByExample.com.ua
                             73
     @ua_spring #uadevclub

More Related Content

What's hot

Comparison of Java Web Application Frameworks
Comparison of Java Web Application FrameworksComparison of Java Web Application Frameworks
Comparison of Java Web Application FrameworksAngelin R
 
jDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring SmackdownjDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring SmackdownMert Çalışkan
 
Spring Framework
Spring FrameworkSpring Framework
Spring Frameworknomykk
 
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and WicketComparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and WicketMatt Raible
 
Web Components: The Future of Web Development is Here
Web Components: The Future of Web Development is HereWeb Components: The Future of Web Development is Here
Web Components: The Future of Web Development is HereJohn Riviello
 
Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!🎤 Hanno Embregts 🎸
 

What's hot (6)

Comparison of Java Web Application Frameworks
Comparison of Java Web Application FrameworksComparison of Java Web Application Frameworks
Comparison of Java Web Application Frameworks
 
jDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring SmackdownjDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring Smackdown
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and WicketComparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
 
Web Components: The Future of Web Development is Here
Web Components: The Future of Web Development is HereWeb Components: The Future of Web Development is Here
Web Components: The Future of Web Development is Here
 
Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!
 

Viewers also liked

Fun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBFun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBArun Gupta
 
Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Eduardo Pelegri-Llopart
 
Lightweight J2EE development using Spring
Lightweight J2EE development using SpringLightweight J2EE development using Spring
Lightweight J2EE development using Springspringbyexample
 
Java EE and Spring Side-by-Side
Java EE and Spring Side-by-SideJava EE and Spring Side-by-Side
Java EE and Spring Side-by-SideReza Rahman
 
jVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginijVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginiSchogini Systems Pvt Ltd
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafkamarius_bogoevici
 

Viewers also liked (8)

EJB 3.1 by Bert Ertman
EJB 3.1 by Bert ErtmanEJB 3.1 by Bert Ertman
EJB 3.1 by Bert Ertman
 
Fun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBFun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJB
 
Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208
 
Lightweight J2EE development using Spring
Lightweight J2EE development using SpringLightweight J2EE development using Spring
Lightweight J2EE development using Spring
 
Java EE and Spring Side-by-Side
Java EE and Spring Side-by-SideJava EE and Spring Side-by-Side
Java EE and Spring Side-by-Side
 
jVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginijVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by Schogini
 
Tu1 1 5l
Tu1 1 5lTu1 1 5l
Tu1 1 5l
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafka
 

Similar to Lightweight Java Development using the Spring Framework

Spring Fa Qs
Spring Fa QsSpring Fa Qs
Spring Fa Qsjbashask
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework Serhat Can
 
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Edureka!
 
Spring - CDI Interop
Spring - CDI InteropSpring - CDI Interop
Spring - CDI InteropRay Ploski
 
Practical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobusPractical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobusJarrod Overson
 
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Christian Catalan
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
spring framework ppt by Rohit malav
spring framework ppt by Rohit malavspring framework ppt by Rohit malav
spring framework ppt by Rohit malavRohit malav
 
Skillwise-Spring framework 1
Skillwise-Spring framework 1Skillwise-Spring framework 1
Skillwise-Spring framework 1Skillwise Group
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC frameworkMohit Gupta
 
Java spring framework
Java spring frameworkJava spring framework
Java spring frameworkRajiv Gupta
 
Introduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCIntroduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCFunnelll
 
Spring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSpring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSam Brannen
 
Full Stack Reactive with React and Spring WebFlux - PWX 2019
Full Stack Reactive with React and Spring WebFlux - PWX 2019Full Stack Reactive with React and Spring WebFlux - PWX 2019
Full Stack Reactive with React and Spring WebFlux - PWX 2019Matt Raible
 
KnowItPresentation
KnowItPresentationKnowItPresentation
KnowItPresentationChuan Su
 
Front Ends for Back End Developers - Spring I/O 2017
Front Ends for Back End Developers - Spring I/O 2017Front Ends for Back End Developers - Spring I/O 2017
Front Ends for Back End Developers - Spring I/O 2017Matt Raible
 

Similar to Lightweight Java Development using the Spring Framework (20)

Spring Fa Qs
Spring Fa QsSpring Fa Qs
Spring Fa Qs
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
 
Lo nuevo en Spring 3.0
Lo nuevo  en Spring 3.0Lo nuevo  en Spring 3.0
Lo nuevo en Spring 3.0
 
Spring - CDI Interop
Spring - CDI InteropSpring - CDI Interop
Spring - CDI Interop
 
Practical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobusPractical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobus
 
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
spring framework ppt by Rohit malav
spring framework ppt by Rohit malavspring framework ppt by Rohit malav
spring framework ppt by Rohit malav
 
Skillwise-Spring framework 1
Skillwise-Spring framework 1Skillwise-Spring framework 1
Skillwise-Spring framework 1
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
Java spring framework
Java spring frameworkJava spring framework
Java spring framework
 
Introduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCIntroduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoC
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSpring Framework 3.2 - What's New
Spring Framework 3.2 - What's New
 
Full Stack Reactive with React and Spring WebFlux - PWX 2019
Full Stack Reactive with React and Spring WebFlux - PWX 2019Full Stack Reactive with React and Spring WebFlux - PWX 2019
Full Stack Reactive with React and Spring WebFlux - PWX 2019
 
KnowItPresentation
KnowItPresentationKnowItPresentation
KnowItPresentation
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Front Ends for Back End Developers - Spring I/O 2017
Front Ends for Back End Developers - Spring I/O 2017Front Ends for Back End Developers - Spring I/O 2017
Front Ends for Back End Developers - Spring I/O 2017
 

Recently uploaded

Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

Lightweight Java Development using the Spring Framework

  • 1. Lightweight Enterprise Java Development using Spring Framework Oleksiy Rezchykov Eugene Scripnik
  • 2. About us  Software Engineers  Working with Spring since 2006  Pragmatic programmers  SpringByExample.com.ua founders SpringByExample.com.ua 2 @ua_spring #uadevclub
  • 3. Contents  Spring origins  IoC using Spring  Persistence with Spring  Declarative caching using @Cachable  Web applications with Spring MVC  Spring ecosystem  Framework criticism SpringByExample.com.ua 3 @ua_spring #uadevclub
  • 4. J2EE 5 Development SpringByExample.com.ua 4 @ua_spring #uadevclub
  • 5. SpringFramework history  In October 2002 Rod Johnson wrote his famous book  The first milestone release 1.0 - June 2004  Company renamed from Interface21 to SpringSource in 2007  SpringSource acquired by VMWare in 2009  Rod Johnson left VMWare – July 2012 SpringByExample.com.ua 5 @ua_spring #uadevclub
  • 6. Inversion of Control  Inversion of regular approach where object was responsible for satisfying it’s own dependencies  Implementation of Dependency Injection  Container instantiates and wires dependencies SpringByExample.com.ua 6 @ua_spring #uadevclub
  • 7. Injection types  Setter injection– when you are using setter to fulfill bean dependency  Constructor injection – when constructor is called to set-up a bean with dependencies  Method injection SpringByExample.com.ua 7 @ua_spring #uadevclub
  • 8. Context  An object which contains beans declarations with their dependencies  BeanFactory interface implementation SpringByExample.com.ua 8 @ua_spring #uadevclub
  • 9. XML namespaces SpringByExample.com.ua 9 @ua_spring #uadevclub
  • 10. Context SpringByExample.com.ua 10 @ua_spring #uadevclub
  • 11. Context usage SpringByExample.com.ua 11 @ua_spring #uadevclub
  • 12. Bean lifecycle  Depends on scope and lazy initialization  Main bean scopes: Singleton and Prototype (Also there are multiple web scopes) SpringByExample.com.ua 12 @ua_spring #uadevclub
  • 13. Bean instantiation order SpringByExample.com.ua 13 @ua_spring #uadevclub
  • 14. Bean Post-processing • Bean instantiated for singletons with Bean instantiation eager initialization Dependency • Dependencies are injected into beans injection • Bean post-processing actions Bean post- processing • You can put your custom logic in here SpringByExample.com.ua 14 @ua_spring #uadevclub
  • 15. Map, List, Set, Prop, Nul l SpringByExample.com.ua 15 @ua_spring #uadevclub
  • 16. Map, List, Set, Prop, Nul l SpringByExample.com.ua 16 @ua_spring #uadevclub
  • 17. Util namespace SpringByExample.com.ua 17 @ua_spring #uadevclub
  • 18. Component model SpringByExample.com.ua 18 @ua_spring #uadevclub
  • 19. @Autowired  Spring proprietary annotation for property injection  Supports @Qualifier to select implementation by name if more than one exists in context  Has required parameter to enforce dependency loading SpringByExample.com.ua 19 @ua_spring #uadevclub
  • 20. @Autowired SpringByExample.com.ua 20 @ua_spring #uadevclub
  • 21. @Inject  Context and Dependency Injection (CDI) standard JSR-299 SpringByExample.com.ua 21 @ua_spring #uadevclub
  • 22. @Resource  JSR 250 (Common annotations)  Supports @PostConstruct and @PreDestroy as well SpringByExample.com.ua 22 @ua_spring #uadevclub
  • 23. Resource loading and i18n SpringByExample.com.ua 23 @ua_spring #uadevclub
  • 24. Resource loading and i18n SpringByExample.com.ua 24 @ua_spring #uadevclub
  • 25. SpEl  Stands for Spring Expression Language  Can be used in the xml context  Can be used in bean classes SpringByExample.com.ua 25 @ua_spring #uadevclub
  • 26. SpEl SpringByExample.com.ua 26 @ua_spring #uadevclub
  • 27. Java Spring Config  @Configuration  @Bean  Support for Environment and Profiles SpringByExample.com.ua 27 @ua_spring #uadevclub
  • 28. Java Spring Config SpringByExample.com.ua 28 @ua_spring #uadevclub
  • 29. Environment abstraction & context profiles  Environment abstraction introduced in Spring 3.1  Can be declaratively and programmatically configured  Affects property resolution  Affects bean profiles SpringByExample.com.ua 29 @ua_spring #uadevclub
  • 30. Environment abstraction & context profiles SpringByExample.com.ua 30 @ua_spring #uadevclub
  • 31. AOP A programming paradigm which allows to separate cross-cutting concerns Cross-cutting logic:  Logging  Tracing  Security SpringByExample.com.ua 31 @ua_spring #uadevclub
  • 32. AOP  Aspect  Advice  Join point  Pointcut SpringByExample.com.ua 32 @ua_spring #uadevclub
  • 33. AOP SpringByExample.com.ua 33 @ua_spring #uadevclub
  • 34. Spring AOP  Spring AOP defaults to using standard J2SE dynamic proxies for AOP proxies. This enables any interface (or set of interfaces) to be proxied.  Spring AOP can also use CGLIB proxies. This is necessary to proxy classes, rather than interfaces  It is good practice to program to interfaces rather than classes, business classes normally will implement one or more business interfaces. SpringByExample.com.ua 34 @ua_spring #uadevclub
  • 35. AspectJ  Spring AOP is often uses the AspectJ declaration style  AspectJ itself uses Load Time Weaving (LTW) to modify the bean code according to Aspect logic  LTW could do much more than dynamic proxies but it is more time-consuming operation. This means that LTW has a performance drawback. SpringByExample.com.ua 35 @ua_spring #uadevclub
  • 36. “pure” AspectJ SpringByExample.com.ua 36 @ua_spring #uadevclub
  • 37. “pure” AspectJ SpringByExample.com.ua 37 @ua_spring #uadevclub
  • 38. Persistence with Spring  Building DAO  Spring Data  Embedded Datasources  JDBC vs ORM DAO’s  Integration testing with Spring  @Transactional & transactions with Spring SpringByExample.com.ua 38 @ua_spring #uadevclub
  • 39. Spring supports  JDBC  JPA  JDO  Concrete ORM SpringByExample.com.ua 39 @ua_spring #uadevclub
  • 40. Spring Data  RDBMS: JPA, JDBC Extensions  BigData: ApacheHadoop  DataGrid: GermFire  HTTP: REST  Key-value stores: Redis  Document Stores: MongoDB  Graph Databases: Neo4j  Column stores: Hbase SpringByExample.com.ua 40 @ua_spring #uadevclub
  • 41. Persistence layer • Persistence service which has domain specific logic Service • Spring JDBCTemplate • SessionFactory, EntityManagerFactory Repository (DAO) • Redis/Mongo template • RDBMS (or NoSQL) DB SpringByExample.com.ua 41 @ua_spring #uadevclub
  • 42. JDBCTemplate  Useful interface  No boilerplate code  Exception handling SpringByExample.com.ua 42 @ua_spring #uadevclub
  • 43. JDBCTemplate SpringByExample.com.ua 43 @ua_spring #uadevclub
  • 44. JDBC namespace SpringByExample.com.ua 44 @ua_spring #uadevclub
  • 45. Spring Data JPA  CRUD SpringByExample.com.ua 45 @ua_spring #uadevclub
  • 46. Spring Data JPA  Query DSL SpringByExample.com.ua 46 @ua_spring #uadevclub
  • 47. Transactions in Spring  Support for ACID transactions  Declarative and programmatic SpringByExample.com.ua 47 @ua_spring #uadevclub
  • 48. Transaction managers  Spring support both container managed and framework managed transactions Managers:  DataSourceTransactionManager  HibernateTransactionManager  JPATransactionManager  JTATransactionManager SpringByExample.com.ua 48 @ua_spring #uadevclub
  • 49. @Transactional  Transaction propagation  Read-only transactions  Built using Spring AOP SpringByExample.com.ua 49 @ua_spring #uadevclub
  • 50. Persistence layer testing  Context loading in test  Environment abstraction and profiles usage  Transactional methods  Embedded data source could be used SpringByExample.com.ua 50 @ua_spring #uadevclub
  • 51. Persistence layer testing SpringByExample.com.ua 51 @ua_spring #uadevclub
  • 52. @Cacheable  One-two-three magic (not always work as expected)  Support for JCache (JSR-107) SpringByExample.com.ua 52 @ua_spring #uadevclub
  • 53. @Cacheable  <cache:annotation-driven> or @EnableCaching  CacheManager instance in the context  @Cacheable, @CachePut, @CacheEvict SpringByExample.com.ua 53 @ua_spring #uadevclub
  • 54. Spring MVC  Application context  Dispatcher Servlet and it’s context  Controllers and mappings  Implementing CRUD logic  REST  Testing MVC SpringByExample.com.ua 54 @ua_spring #uadevclub
  • 55. Application & Dispatcher servlet context SpringByExample.com.ua 55 @ua_spring #uadevclub
  • 56. Front controller and MVC SpringByExample.com.ua 56 @ua_spring #uadevclub
  • 57. URL mappings  @RequestMapping SpringByExample.com.ua 57 @ua_spring #uadevclub
  • 58. View resolvers  AbstractCachingViewResolver  XmlViewResolver  ResourceBundleViewResolver  UrlBasedViewResolver  InternalResourceViewResolver  VelocityViewResolver / FreeMarkerViewResolver  ContentNegotiatingViewResolver SpringByExample.com.ua 58 @ua_spring #uadevclub
  • 59. View resolvers SpringByExample.com.ua 59 @ua_spring #uadevclub
  • 60. CRUD in one place SpringByExample.com.ua 60 @ua_spring #uadevclub
  • 61. REST in Spring MVC  Starting Spring 3.1.x  ContentNegotiatingViewResolver  @ResponseBody combined with produces  @RequestBody combined with consumes SpringByExample.com.ua 61 @ua_spring #uadevclub
  • 62. REST in Spring MVC SpringByExample.com.ua 62 @ua_spring #uadevclub
  • 63. Testing MVC  Starting from Spring 3.2  spring-test-mvc project  Server-side Spring MVC tests  New Spring Mocks  Different strategies SpringByExample.com.ua 63 @ua_spring #uadevclub
  • 64. Testing MVC SpringByExample.com.ua 64 @ua_spring #uadevclub
  • 65. Testing MVC SpringByExample.com.ua 65 @ua_spring #uadevclub
  • 66. Just to mention  Type conversion  Formatter SPI SpringByExample.com.ua 66 @ua_spring #uadevclub
  • 67. Just to mention  Type conversion  Formatter SPI SpringByExample.com.ua 67 @ua_spring #uadevclub
  • 68. Just to mention  Flash attributes and Redirect attributes SpringByExample.com.ua 68 @ua_spring #uadevclub
  • 69. Spring in 2012 SpringByExample.com.ua 69 @ua_spring #uadevclub
  • 70. Just to mention  Spring Roo  Spring Hadoop  Spring Android SpringByExample.com.ua 70 @ua_spring #uadevclub
  • 71. Criticism  Every tool should be used only if you could not solve your task without it – KISS  When a lot of stuff come out-of-the-box it is not always good - YAGNI  When something is broken it is pain in the …  Open source but VMWare SpringByExample.com.ua 71 @ua_spring #uadevclub
  • 72. Sources  http://static.springsource.org/spring/docs/3.1.x/sprin g-framework-reference/html/index.html  https://github.com/springbyexample/spring-by- example  https://github.com/mcgray/spring-vaadin  http://rstoyanchev.github.com/spring-32-test- webapps/ SpringByExample.com.ua 72 @ua_spring #uadevclub

Editor's Notes

  1. EJB 2x, Containers set-up, Spec immaturity
  2. Bean tag attrubutes: id vs namep&amp; c context
  3. Bean tag attrubutes: id vs namep&amp; c context Constur-argClasspath*:, file:,url:
  4. Java code example of context usageBean overriding (id)
  5. toString()
  6. Locale resolver
  7. Locale resolver
  8. Spring Vaadin integration
  9. Spring Vaadin integration
  10. Polyglot persistence
  11. Some words about JDBC
  12. Some words about JDBC