SlideShare una empresa de Scribd logo
1 de 72
Descargar para leer sin conexión
Bert Ertman
Fellow at Luminis in the Netherla
                                 nds
JUG Leader for NLJUG and a Java
                                  Champion
     @bertertman



Paul Bakker
Senior developer at Luminis Tech
                                nologies
     @pbakker
Who is this talk
     for?
You are using old school
Spring and wonder how to
move forward
Java EE seems to be hot again,
should you jump on this
train?
You love the J2EE Design and
Development book; but is it
still actual?
Why listen to us?


         d endless         ..worked
We’ve ha
                       extensively with
   Ja va EE vs.
                      J2EE, Spring and
      Spring
                       modern Java EE
  dis cussions...


..not employed by         ..and we’re no
  an application           Rod Johnson
   server vendor          groupies either
some disclaimers:

Not looking for another holy war
No shootout
No silver bullets
Why migrate?

                        Spring is
                       proprietary
                       technology
Upgrading from
old school Spring
 requires a lot of
  work anyway
                     Why not take it to
                      the standard?
This m ight have been competitive in the past...
But now we want THIS!
Let’s get



a couple of misunderstandings



             out of the way



          first...
Isn’t Java EE too fat?

Startup times with application deployed
  JBoss AS 7 ~2 seconds
  Glassfish V3 ~4 seconds
  Tomcat 6 + Spring ~4 seconds
Java EE 6 WAR file < 100kb
Isn’t Java EE too fat?

Startup times with application deployed
  JBoss AS 7 ~2 seconds
  Glassfish V3 ~4 seconds
                         Our favorite quote:
  Tomcat 6 + Spring ~4 seconds
Java EE 6 WAR file < 100kb in the Java EE spec
                         “Nowhere
                           does it say that Java EE
                               servers should be heavy
                                 weight and slow...”
Isn’t Java EE
  supposed to be evil?

Based on 2004 rhetorics

Ever heard of the fable of the tortoise and
the hare?
But I need dependency
         injection?

Java EE 6 introduced CDI
  More powerful,
  contextual DI model
  Makes the platform
  extensible in a
  standard way
But I must have AOP!

    Really?
You love getting
  your code all
                     Or are you just
asymmetric and
                    using AOP light
  unreadable?
                   a.k.a. Spring AOP
                     a.k.a. (Java EE)
                       Interceptors?
Can I still do unit
       testing?

It took a while to get
 there, but yes Java EE
 supports testing as well
do I need heavy tooling?
NO!

do I need heavy tooling?
Ca pabilities comparison
                               Spring                            JavaEE
Capability
  Dependency                                                            CDI
                             Spring Container
   Injection
                                                                         EJB
  Transactions               AOP / annotations

                                                                         JSF
 Web framework                Spring Web MVC

                                                                    Interceptors
       AOP             AspectJ (limited to Spring beans)


                                     JMS                             JMS / CDI
    Messaging

                                                                          JPA
    Data Access        JDBC templates / other ORM / JPA

   RESTful Web                                                         JAX-RS
                            Spring Web MVC (3.0)
     Services
                                                                    Arquillian *
 Integration testing        Spring Test framework
                                                                                              tion
                                                           * Not part of the Java EE specifica
Apparently,



it can all be done using



plain vanilla light weight



      Java EE
rm -Rf spring*
Sure it would be
fun, but not very
    realistic
We need a recipe that
 moves us forward
    step by step
Old school Spring app

lots of complex XML, no annotations
old / outdated ORM solution
  JDBC Templates, Kodo, Toplink, etc.
deprecated extension based Web MVC
(SimpleFormController, etc.)
Migration path
1. Upgrade Spring version
2.Replace old frameworks
   (ORM, web framework)
   within Spring
3.Run Spring and Java EE
   container side by side
4.Replace Spring entirely
5.Remove Spring container
Migration path
1. Upgrade Spring version
2.Replace old frameworks
   (ORM, web framework)
   within Spring
3.Run Spring and Java EE
   container side by side
4.Replace Spring entirely
5.Remove Spring container
Upgrade Spring version

Upgrade Spring runtime (replace JAR files)
No code / configuration changes
Migration path
1. Upgrade Spring version
2.Replace old frameworks
   (ORM, web framework)
   within Spring
3.Run Spring and Java EE
   container side by side
4.Replace Spring entirely
5.Remove Spring container
replace old frameworks
                                                  within Spring
presentaton
   layer



                            Web MVC

                              @AutoWired
business




                       Spring beans
 layer




                                                     Tasks

                      @AutoWired      @AutoWired
Data / Integration




                                   Spring JDBC
      layer




                     Kodo                          JMS beans
                                    Templates
replace old frameworks
                                                  within Spring
presentaton
   layer



                           Web MVC

                             @AutoWired
business




                      Spring beans
 layer




                                                     Tasks

                      @AutoWired      @AutoWired
Data / Integration




                                   Spring JDBC
      layer




                     JPA                           JMS beans
                                    Templates
replace old frameworks
                                                  within Spring
presentaton
   layer



                             JSF

                             @AutoWired
business




                      Spring beans
 layer




                                                     Tasks

                      @AutoWired      @AutoWired
Data / Integration




                                   Spring JDBC
      layer




                     JPA                           JMS beans
                                    Templates
replace old frameworks
                                                  within Spring
presentaton
   layer



                             JSF
                                                   Don’t touch Spring
                             @AutoWired             specific APIs yet
business




                      Spring beans
 layer




                                                         Tasks

                      @AutoWired      @AutoWired
Data / Integration




                                   Spring JDBC
      layer




                     JPA                              JMS beans
                                    Templates
W hat about Spring APIs we
don’t want to change yet?

   Jdbc Templates
   REST Templates
   Task Scheduling
   etc.
Migration path
1. Upgrade Spring version
2.Replace old frameworks
   (ORM, web framework)
   within Spring
3.Run Spring and Java EE
   container side by side
4.Replace Spring entirely
5.Remove Spring container
Using Spring and Java EE
      side-by-side

Disclaimer 1: this is just to give an idea, this
is not a production ready framework!


 Disclaimer 2: this is a migration path. Not
 the way you should build your next
 application...
Spring application
Servlet Container

  myapp.war
                       Spring container
    TX manager




                       ORM          Spring	
  
                                     beans
                 AOP


                                    Spring	
  
                                     beans
Java EE application
Java EE 6 application server
   CDI / EJB container

                                                  myapp.war
    TX manager




                             Interceptors
                  Security




                                            JPA
                                                  CDI	
  beans
                                                  Session	
  beans
Mixed
Java EE 6 application server

   CDI / EJB container
                                                  myapp.war
                                                   CDI	
  beans
                                                   Session	
  beans
    TX manager




                            Interceptors
                 Security




                                            JPA                   Spring


                                                   TX manager
                                                                            Spring	
  




                                                                      ORM
                                                                AOP
                                                                             beans
                                                                            Spring	
  
                                                                             beans
run Spring within
                                                    Java EE container
presentaton
   layer



                               JSF

                               @AutoWired
business




                                                        f
                     Spring beans                d stuf
 layer




                                              Ad
                                                here...
                                                              Tasks

                        @AutoWired
Data / Integration




                                     Spring JDBC
      layer




                      JPA                                   JMS beans
                                      Templates
add Java EE code
                                                    keep old Spring code
presentaton
   layer



                               JSF

                               @AutoWired
                                               @Inject
business
 layer




                     Spring beans        EJB       CDI          Tasks

                        @AutoWired                  @Inject
Data / Integration




                                     Spring JDBC
      layer




                      JPA                                     JMS beans
                                      Templates
Dependency Injection
Spring already supports
JSR-330
Use @Inject anywhere you use
@AutoWired
CDI could be almost a drop-in
replacement for Spring DI
  but opens up much more
  powerful options
Encapsulate Spring with
         CDI

 Write a CDI extension that
  bootstraps the Spring
  container
  looks up Spring Beans in the
  Spring container and
  publish in CDI context
The Spring DAO
JSF / CDI bean




                 Here we don’t
                 want to know
                 about Spring
CDI extension example




https://github.com/paulbakker/migrating-spring-to-javaee
Migration path
1. Upgrade Spring version
2.Replace old frameworks
   (ORM, web framework)
   within Spring
3.Run Spring and Java EE
   container side by side
4.Replace Spring entirely
5.Remove Spring container
presentaton
   layer
                                                entirely replace Spring

                               JSF

                               @AutoWired
                                               @Inject
business




                     Spring beans        EJB       CDI
 layer




                                                                Tasks

                        @AutoWired                  @Inject
Data / Integration




                                     Spring JDBC
      layer




                      JPA                                     JMS beans
                                      Templates
presentaton
   layer
                                            entirely replace Spring

                                 JSF

                                 @Inject
                                           @Inject
business




                           EJB             CDI             EJB Timers
 layer




                       @Inject                   @Inject
Data / Integration




                                   Spring JDBC
      layer




                     JPA                                     MDB
                                    Templates
The TX layer

Migrate Spring TX and DAOs to EJB
The TX manager is in the app server
An EJB is transactional by default
EJB has JPA integration
Come on, are you telling me EJBs are cool now?




                   You bet!

                                  Just like
   EJBs are just              Spring beans,
    container                   but without
    managed                    the container
      POJOs                   configuration
The Spring DAO
The Java EE alternative




     btw -
   this is an
     EJB! :)
Dealing with lazy loading
Many Spring apps use the Open-
EntityManager-In-View pattern
EJB has the Extended Persistence
Context
LazyInitializationException
Fixing lazy loading
Detached entities

Spring DAOs are stateless (all singletons)
Load > edit > save needs a merge
With an Extended PU we don’t
Migration path
Template addict?


Hooked to JDBC Templates!?

           Hmm, let’s start
          the old discussion
           whether or not to
              use ORM...

         Phase 1: denial

         Phase 2: migrate ;-)
Using JD BC Templates

1. Can b e injected with simple
   Producer method
2.It is n ot relying on Spring
   container
3.some extra    dependencies though
Template producer example
Migration path
1. Upgrade Spring version
2.Replace old frameworks
   (ORM, web framework)
   within Spring
3.Run Spring and Java EE
   container side by side
4.Replace Spring entirely
5.Remove Spring container
Removing Dependencies
Our classpath just has to
contain APIs, no framework
classes
From ~40 dependencies to just:
What about testing?




Spring is pretty good at this



        Java EE was not
How to test this?
CDI alternatives
What about
 JPA code?
Ar quillian

Create micro deployments
      using an API

    Run tests in real containers
Arquillian example
Wrap up
Is it all worth it?




blissful ignorance or painful reality ?!
Is there life after Spring?

 We believe that there is always
 room for innovation
   Ideally through Open Source
 When it flies, bring it back to
 the spec!
Other sessions of interest
Arquillian: The
Extendable Enterprise Test
                             Introducing Contexts and
Platform (24121)
                             Dependency Injection 1.1
Beginning Java EE 6          (22480)
(23421)
                             Java EE 6: The Cool Parts
CDI Today and Tomorrow       (21641)
(19941)
                             Java EE and Spring/MVC
Enterprise JavaBeans         Shoot-out (24161)
Technology 3.2 (23180)
                             Rethinking Best Practices
Hacking Java EE: CDI         with Java EE 6 (21622)
Extension Writing n00b to
l33t (23805)
contact us:
Bert Ertman
bert.ertman@lum
                inis.eu
Paul Bakker
paul.bakker@lum
                inis.eu

Más contenido relacionado

La actualidad más candente

Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJosh Juneau
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework tola99
 
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 Presantation Part 1-Core
Spring Framework Presantation Part 1-CoreSpring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-CoreDonald Lika
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
JavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great MatchJavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great MatchReza Rahman
 
Java EE vs Spring Framework
Java  EE vs Spring Framework Java  EE vs Spring Framework
Java EE vs Spring Framework Rohit Kelapure
 
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
 
jDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring SmackdownjDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring SmackdownMert Çalışkan
 
Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7Hirofumi Iwasaki
 
Java spring framework
Java spring frameworkJava spring framework
Java spring frameworkRajiv Gupta
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewEugene Bogaart
 
Spring Mvc,Java, Spring
Spring Mvc,Java, SpringSpring Mvc,Java, Spring
Spring Mvc,Java, Springifnu bima
 
Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Hirofumi Iwasaki
 

La actualidad más candente (18)

Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
 
Spring Framework
Spring Framework  Spring Framework
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 Presantation Part 1-Core
Spring Framework Presantation Part 1-CoreSpring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-Core
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring Framework Rohit
Spring Framework RohitSpring Framework Rohit
Spring Framework Rohit
 
JavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great MatchJavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great Match
 
Java EE vs Spring Framework
Java  EE vs Spring Framework Java  EE vs Spring Framework
Java EE vs Spring Framework
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
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
 
jDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring SmackdownjDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring Smackdown
 
Spring Framework Training Course
Spring Framework Training Course Spring Framework Training Course
Spring Framework Training Course
 
Move from J2EE to Java EE
Move from J2EE to Java EEMove from J2EE to Java EE
Move from J2EE to Java EE
 
Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7
 
Java spring framework
Java spring frameworkJava spring framework
Java spring framework
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 Overview
 
Spring Mvc,Java, Spring
Spring Mvc,Java, SpringSpring Mvc,Java, Spring
Spring Mvc,Java, Spring
 
Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8
 

Similar a JavaOne 2011: Migrating Spring Applications to Java EE 6

Enterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable ApplicationsEnterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable ApplicationsGordon Dickens
 
[S lide] java_sig-spring-framework
[S lide] java_sig-spring-framework[S lide] java_sig-spring-framework
[S lide] java_sig-spring-frameworkptlong96
 
High performance database applications with pure query and ibm data studio.ba...
High performance database applications with pure query and ibm data studio.ba...High performance database applications with pure query and ibm data studio.ba...
High performance database applications with pure query and ibm data studio.ba...Vladimir Bacvanski, PhD
 
Introduction To J Boss Seam
Introduction To J Boss SeamIntroduction To J Boss Seam
Introduction To J Boss Seamashishkulkarni
 
Summer training java
Summer training javaSummer training java
Summer training javaArshit Rai
 
The spring 32 update final
The spring 32 update finalThe spring 32 update final
The spring 32 update finalJoshua Long
 
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-finalRohit Kelapure
 
Summer training java
Summer training javaSummer training java
Summer training javaArshit Rai
 
The Complete Spring Tutorial
The Complete Spring TutorialThe Complete Spring Tutorial
The Complete Spring Tutorialcribes
 
Web Application Architecture
Web Application ArchitectureWeb Application Architecture
Web Application ArchitectureAbhishek Chikane
 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopArun Gupta
 
Course syllabus from ingenious
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingeniousColege Buz
 
Course syllabus from ingenious
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingeniousColege Buz
 
Web Applications of the future: Combining JEE6 & JavaFX
Web Applications of the future: Combining JEE6 & JavaFXWeb Applications of the future: Combining JEE6 & JavaFX
Web Applications of the future: Combining JEE6 & JavaFXPaul Bakker
 
Accelerating Development.pptx
Accelerating Development.pptxAccelerating Development.pptx
Accelerating Development.pptxUraz Pokharel
 
Java EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureJava EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureArun Gupta
 

Similar a JavaOne 2011: Migrating Spring Applications to Java EE 6 (20)

Spring Mvc
Spring MvcSpring Mvc
Spring Mvc
 
Enterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable ApplicationsEnterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable Applications
 
[S lide] java_sig-spring-framework
[S lide] java_sig-spring-framework[S lide] java_sig-spring-framework
[S lide] java_sig-spring-framework
 
High performance database applications with pure query and ibm data studio.ba...
High performance database applications with pure query and ibm data studio.ba...High performance database applications with pure query and ibm data studio.ba...
High performance database applications with pure query and ibm data studio.ba...
 
Introduction To J Boss Seam
Introduction To J Boss SeamIntroduction To J Boss Seam
Introduction To J Boss Seam
 
Summer training java
Summer training javaSummer training java
Summer training java
 
The spring 32 update final
The spring 32 update finalThe spring 32 update final
The spring 32 update final
 
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
 
Summer training java
Summer training javaSummer training java
Summer training java
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
The Complete Spring Tutorial
The Complete Spring TutorialThe Complete Spring Tutorial
The Complete Spring Tutorial
 
Java frameworks
Java frameworksJava frameworks
Java frameworks
 
Web Application Architecture
Web Application ArchitectureWeb Application Architecture
Web Application Architecture
 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 Workshop
 
Jsf 2.0 Overview
Jsf 2.0 OverviewJsf 2.0 Overview
Jsf 2.0 Overview
 
Course syllabus from ingenious
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingenious
 
Course syllabus from ingenious
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingenious
 
Web Applications of the future: Combining JEE6 & JavaFX
Web Applications of the future: Combining JEE6 & JavaFXWeb Applications of the future: Combining JEE6 & JavaFX
Web Applications of the future: Combining JEE6 & JavaFX
 
Accelerating Development.pptx
Accelerating Development.pptxAccelerating Development.pptx
Accelerating Development.pptx
 
Java EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureJava EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for future
 

Más de Bert Ertman

Microservices Gone Wrong!
Microservices Gone Wrong!Microservices Gone Wrong!
Microservices Gone Wrong!Bert Ertman
 
Serverless - The Future of the Cloud?!
Serverless - The Future of the Cloud?!Serverless - The Future of the Cloud?!
Serverless - The Future of the Cloud?!Bert Ertman
 
Microservices for Mortals
Microservices for MortalsMicroservices for Mortals
Microservices for MortalsBert Ertman
 
VJUG - Building Modular Java Applications in the Cloud Age
VJUG - Building Modular Java Applications in the Cloud AgeVJUG - Building Modular Java Applications in the Cloud Age
VJUG - Building Modular Java Applications in the Cloud AgeBert Ertman
 
Migrating from Spring Applications to Java EE 6 [CHINESE VERSION]
Migrating from Spring Applications to Java EE 6 [CHINESE VERSION]Migrating from Spring Applications to Java EE 6 [CHINESE VERSION]
Migrating from Spring Applications to Java EE 6 [CHINESE VERSION]Bert Ertman
 
Building Modular Cloud Applications in Java - Lessons Learned
Building Modular Cloud Applications in Java - Lessons LearnedBuilding Modular Cloud Applications in Java - Lessons Learned
Building Modular Cloud Applications in Java - Lessons LearnedBert Ertman
 
Modular Java EE in the Cloud
Modular Java EE in the CloudModular Java EE in the Cloud
Modular Java EE in the CloudBert Ertman
 

Más de Bert Ertman (7)

Microservices Gone Wrong!
Microservices Gone Wrong!Microservices Gone Wrong!
Microservices Gone Wrong!
 
Serverless - The Future of the Cloud?!
Serverless - The Future of the Cloud?!Serverless - The Future of the Cloud?!
Serverless - The Future of the Cloud?!
 
Microservices for Mortals
Microservices for MortalsMicroservices for Mortals
Microservices for Mortals
 
VJUG - Building Modular Java Applications in the Cloud Age
VJUG - Building Modular Java Applications in the Cloud AgeVJUG - Building Modular Java Applications in the Cloud Age
VJUG - Building Modular Java Applications in the Cloud Age
 
Migrating from Spring Applications to Java EE 6 [CHINESE VERSION]
Migrating from Spring Applications to Java EE 6 [CHINESE VERSION]Migrating from Spring Applications to Java EE 6 [CHINESE VERSION]
Migrating from Spring Applications to Java EE 6 [CHINESE VERSION]
 
Building Modular Cloud Applications in Java - Lessons Learned
Building Modular Cloud Applications in Java - Lessons LearnedBuilding Modular Cloud Applications in Java - Lessons Learned
Building Modular Cloud Applications in Java - Lessons Learned
 
Modular Java EE in the Cloud
Modular Java EE in the CloudModular Java EE in the Cloud
Modular Java EE in the Cloud
 

Último

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Último (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

JavaOne 2011: Migrating Spring Applications to Java EE 6

  • 1.
  • 2. Bert Ertman Fellow at Luminis in the Netherla nds JUG Leader for NLJUG and a Java Champion @bertertman Paul Bakker Senior developer at Luminis Tech nologies @pbakker
  • 3. Who is this talk for? You are using old school Spring and wonder how to move forward Java EE seems to be hot again, should you jump on this train? You love the J2EE Design and Development book; but is it still actual?
  • 4. Why listen to us? d endless ..worked We’ve ha extensively with Ja va EE vs. J2EE, Spring and Spring modern Java EE dis cussions... ..not employed by ..and we’re no an application Rod Johnson server vendor groupies either
  • 5. some disclaimers: Not looking for another holy war No shootout No silver bullets
  • 6. Why migrate? Spring is proprietary technology Upgrading from old school Spring requires a lot of work anyway Why not take it to the standard?
  • 7. This m ight have been competitive in the past...
  • 8. But now we want THIS!
  • 9. Let’s get a couple of misunderstandings out of the way first...
  • 10. Isn’t Java EE too fat? Startup times with application deployed JBoss AS 7 ~2 seconds Glassfish V3 ~4 seconds Tomcat 6 + Spring ~4 seconds Java EE 6 WAR file < 100kb
  • 11. Isn’t Java EE too fat? Startup times with application deployed JBoss AS 7 ~2 seconds Glassfish V3 ~4 seconds Our favorite quote: Tomcat 6 + Spring ~4 seconds Java EE 6 WAR file < 100kb in the Java EE spec “Nowhere does it say that Java EE servers should be heavy weight and slow...”
  • 12. Isn’t Java EE supposed to be evil? Based on 2004 rhetorics Ever heard of the fable of the tortoise and the hare?
  • 13. But I need dependency injection? Java EE 6 introduced CDI More powerful, contextual DI model Makes the platform extensible in a standard way
  • 14. But I must have AOP! Really? You love getting your code all Or are you just asymmetric and using AOP light unreadable? a.k.a. Spring AOP a.k.a. (Java EE) Interceptors?
  • 15. Can I still do unit testing? It took a while to get there, but yes Java EE supports testing as well
  • 16. do I need heavy tooling?
  • 17. NO! do I need heavy tooling?
  • 18. Ca pabilities comparison Spring JavaEE Capability Dependency CDI Spring Container Injection EJB Transactions AOP / annotations JSF Web framework Spring Web MVC Interceptors AOP AspectJ (limited to Spring beans) JMS JMS / CDI Messaging JPA Data Access JDBC templates / other ORM / JPA RESTful Web JAX-RS Spring Web MVC (3.0) Services Arquillian * Integration testing Spring Test framework tion * Not part of the Java EE specifica
  • 19. Apparently, it can all be done using plain vanilla light weight Java EE
  • 21. Sure it would be fun, but not very realistic
  • 22. We need a recipe that moves us forward step by step
  • 23. Old school Spring app lots of complex XML, no annotations old / outdated ORM solution JDBC Templates, Kodo, Toplink, etc. deprecated extension based Web MVC (SimpleFormController, etc.)
  • 24. Migration path 1. Upgrade Spring version 2.Replace old frameworks (ORM, web framework) within Spring 3.Run Spring and Java EE container side by side 4.Replace Spring entirely 5.Remove Spring container
  • 25. Migration path 1. Upgrade Spring version 2.Replace old frameworks (ORM, web framework) within Spring 3.Run Spring and Java EE container side by side 4.Replace Spring entirely 5.Remove Spring container
  • 26. Upgrade Spring version Upgrade Spring runtime (replace JAR files) No code / configuration changes
  • 27. Migration path 1. Upgrade Spring version 2.Replace old frameworks (ORM, web framework) within Spring 3.Run Spring and Java EE container side by side 4.Replace Spring entirely 5.Remove Spring container
  • 28. replace old frameworks within Spring presentaton layer Web MVC @AutoWired business Spring beans layer Tasks @AutoWired @AutoWired Data / Integration Spring JDBC layer Kodo JMS beans Templates
  • 29. replace old frameworks within Spring presentaton layer Web MVC @AutoWired business Spring beans layer Tasks @AutoWired @AutoWired Data / Integration Spring JDBC layer JPA JMS beans Templates
  • 30. replace old frameworks within Spring presentaton layer JSF @AutoWired business Spring beans layer Tasks @AutoWired @AutoWired Data / Integration Spring JDBC layer JPA JMS beans Templates
  • 31. replace old frameworks within Spring presentaton layer JSF Don’t touch Spring @AutoWired specific APIs yet business Spring beans layer Tasks @AutoWired @AutoWired Data / Integration Spring JDBC layer JPA JMS beans Templates
  • 32. W hat about Spring APIs we don’t want to change yet? Jdbc Templates REST Templates Task Scheduling etc.
  • 33. Migration path 1. Upgrade Spring version 2.Replace old frameworks (ORM, web framework) within Spring 3.Run Spring and Java EE container side by side 4.Replace Spring entirely 5.Remove Spring container
  • 34. Using Spring and Java EE side-by-side Disclaimer 1: this is just to give an idea, this is not a production ready framework! Disclaimer 2: this is a migration path. Not the way you should build your next application...
  • 35. Spring application Servlet Container myapp.war Spring container TX manager ORM Spring   beans AOP Spring   beans
  • 36. Java EE application Java EE 6 application server CDI / EJB container myapp.war TX manager Interceptors Security JPA CDI  beans Session  beans
  • 37. Mixed Java EE 6 application server CDI / EJB container myapp.war CDI  beans Session  beans TX manager Interceptors Security JPA Spring TX manager Spring   ORM AOP beans Spring   beans
  • 38. run Spring within Java EE container presentaton layer JSF @AutoWired business f Spring beans d stuf layer Ad here... Tasks @AutoWired Data / Integration Spring JDBC layer JPA JMS beans Templates
  • 39. add Java EE code keep old Spring code presentaton layer JSF @AutoWired @Inject business layer Spring beans EJB CDI Tasks @AutoWired @Inject Data / Integration Spring JDBC layer JPA JMS beans Templates
  • 40. Dependency Injection Spring already supports JSR-330 Use @Inject anywhere you use @AutoWired CDI could be almost a drop-in replacement for Spring DI but opens up much more powerful options
  • 41. Encapsulate Spring with CDI Write a CDI extension that bootstraps the Spring container looks up Spring Beans in the Spring container and publish in CDI context
  • 43. JSF / CDI bean Here we don’t want to know about Spring
  • 45. Migration path 1. Upgrade Spring version 2.Replace old frameworks (ORM, web framework) within Spring 3.Run Spring and Java EE container side by side 4.Replace Spring entirely 5.Remove Spring container
  • 46. presentaton layer entirely replace Spring JSF @AutoWired @Inject business Spring beans EJB CDI layer Tasks @AutoWired @Inject Data / Integration Spring JDBC layer JPA JMS beans Templates
  • 47. presentaton layer entirely replace Spring JSF @Inject @Inject business EJB CDI EJB Timers layer @Inject @Inject Data / Integration Spring JDBC layer JPA MDB Templates
  • 48. The TX layer Migrate Spring TX and DAOs to EJB The TX manager is in the app server An EJB is transactional by default EJB has JPA integration
  • 49. Come on, are you telling me EJBs are cool now? You bet! Just like EJBs are just Spring beans, container but without managed the container POJOs configuration
  • 51. The Java EE alternative btw - this is an EJB! :)
  • 52. Dealing with lazy loading Many Spring apps use the Open- EntityManager-In-View pattern EJB has the Extended Persistence Context
  • 55. Detached entities Spring DAOs are stateless (all singletons) Load > edit > save needs a merge With an Extended PU we don’t
  • 57. Template addict? Hooked to JDBC Templates!? Hmm, let’s start the old discussion whether or not to use ORM... Phase 1: denial Phase 2: migrate ;-)
  • 58. Using JD BC Templates 1. Can b e injected with simple Producer method 2.It is n ot relying on Spring container 3.some extra dependencies though
  • 60. Migration path 1. Upgrade Spring version 2.Replace old frameworks (ORM, web framework) within Spring 3.Run Spring and Java EE container side by side 4.Replace Spring entirely 5.Remove Spring container
  • 61. Removing Dependencies Our classpath just has to contain APIs, no framework classes From ~40 dependencies to just:
  • 62. What about testing? Spring is pretty good at this Java EE was not
  • 63. How to test this?
  • 65. What about JPA code?
  • 66. Ar quillian Create micro deployments using an API Run tests in real containers
  • 69. Is it all worth it? blissful ignorance or painful reality ?!
  • 70. Is there life after Spring? We believe that there is always room for innovation Ideally through Open Source When it flies, bring it back to the spec!
  • 71. Other sessions of interest Arquillian: The Extendable Enterprise Test Introducing Contexts and Platform (24121) Dependency Injection 1.1 Beginning Java EE 6 (22480) (23421) Java EE 6: The Cool Parts CDI Today and Tomorrow (21641) (19941) Java EE and Spring/MVC Enterprise JavaBeans Shoot-out (24161) Technology 3.2 (23180) Rethinking Best Practices Hacking Java EE: CDI with Java EE 6 (21622) Extension Writing n00b to l33t (23805)
  • 72. contact us: Bert Ertman bert.ertman@lum inis.eu Paul Bakker paul.bakker@lum inis.eu