• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
JavaOne 2011: Migrating Spring Applications to Java EE 6
 

JavaOne 2011: Migrating Spring Applications to Java EE 6

on

  • 40,694 views

The Spring Framework has no-doubt played a major role in evolving the way we write enterprise applications on the Java platform today. However, it is still a proprietary framework owned by a single ...

The Spring Framework has no-doubt played a major role in evolving the way we write enterprise applications on the Java platform today. However, it is still a proprietary framework owned by a single company. The age of having to rely on such proprietary frameworks in order to develop decent enterprise applications is now over and Java EE 6 has become an even easier way to develop enterprise applications based on standards which makes it the best choice for any enterprise application. In this session you will experience how to migrate a typical full stack Spring application to a standards based, completely portable, Java EE 6 application including integration tests.

Statistics

Views

Total Views
40,694
Views on SlideShare
30,155
Embed Views
10,539

Actions

Likes
46
Downloads
1,028
Comments
8

55 Embeds 10,539

https://blogs.oracle.com 5092
http://bertertman.wordpress.com 1709
http://java.dzone.com 965
http://howtojboss.com 852
http://mcgray.com.ua 800
http://www.jugsicilia.it 264
http://orana.info 143
http://snippetjournal.wordpress.com 135
https://twitter.com 103
http://paper.li 84
http://feedly.com 75
http://glassfish.collected.info 54
http://a0.twimg.com 38
http://www-ig-opensocial.googleusercontent.com 36
http://planet.jboss.org 34
http://localhost 26
http://us-w1.rockmelt.com 23
http://www.dcjbug.com 14
https://www.linkedin-ei.com 11
https://feedly.com 10
http://nofluffjuststuff.com 7
http://cuckoo9.okoza.com 6
http://news.google.com 5
http://www.linkedin.com 5
http://digg.com 4
http://www.feedspot.com 4
http://blogs.oracle.com 4
http://127.0.0.1 3
http://bloggers1033.rssing.com 3
http://goyim.dnsdojo.org 2
https://www.inoreader.com 2
https://si0.twimg.com 2
http://www.inoreader.com 2
https://www.newsblur.com 2
http://feedreader.com 1
https://newsblur.com 1
http://www.newsblur.com 1
http://newsblur.com 1
http://www.techgig.com 1
http://www.linkedin-ei.com 1
http://plus.url.google.com 1
https://www.linkedin.com 1
http://www.tuicool.com 1
https://twimg0-a.akamaihd.net 1
http://translate.googleusercontent.com 1
http://rss.neurozone.fr 1
http://www.365dailyjournal.com 1
http://webcache.googleusercontent.com 1
http://alltech.io 1
http://oracle.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

18 of 8 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Great Presentation
    Indeed CDI is great. And have good design elements.
    Anyway EE worries me.
    A container? my freedom? Why cant I run my application in a main program?
    That is where Spring is great.
    Spring does not tell me to run in container X.Y.Z ...
    I can run my applications in a unit test. Limit the IOC to what I need in a situation.
    But in EE6 I cannot !!!!
    If JSR-330 was jsr-330.jar - I would be happy. But it is not. Therefore I think that the whole idea of containers implementing a stack EE6 is bad from the beginning of.
    At the end of the day JSR-330 and all the other specs loose meaning. The only meaning is EE it self. Or to be more precise the vendor that I got started with Jboss, Weblogic, Glassfish, Websphere sets the limit for my application. Not me any longer.
    I loose control I loose freedom.
    Give me my freedom back. Give me the freedom to run main()
    Are you sure you want to
    Your message goes here
    Processing…
  • GlassFish 3..1.1 actually has a startup time of 2.5 - 3 seconds, according to product management.

    http://agoncal.wordpress.com/2011/10/20/o-java-ee-6-application-servers-where-art-thou/

    Signed, Pieter (Oracle Employee)
    Are you sure you want to
    Your message goes here
    Processing…
  • @sivaprasadreddy.k
    >No matter how many fancy slides you show us, even Java EE 6 is no match for Spring...

    Care to explain why?
    Are you sure you want to
    Your message goes here
    Processing…
  • Nice presentation. Here we must get rid off Spring, the document will be helpful.
    Are you sure you want to
    Your message goes here
    Processing…
  • i have already wasted enough time on ejb n jsf...
    no matter how many fancy slides you show us ... even jee6(0) also no match for spring...
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    JavaOne 2011: Migrating Spring Applications to Java EE 6 JavaOne 2011: Migrating Spring Applications to Java EE 6 Presentation Transcript

    • Bert ErtmanFellow at Luminis in the Netherla ndsJUG Leader for NLJUG and a Java Champion @bertertmanPaul BakkerSenior developer at Luminis Tech nologies @pbakker
    • Who is this talk for?You are using old schoolSpring and wonder how tomove forwardJava EE seems to be hot again,should you jump on thistrain?You love the J2EE Design andDevelopment book; but is itstill actual?
    • Why listen to us? d endless ..workedWe’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 warNo shootoutNo silver bullets
    • Why migrate? Spring is proprietary technologyUpgrading fromold 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 geta 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 secondsJava 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 secondsJava 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 rhetoricsEver heard of the fable of the tortoise andthe 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 justasymmetric 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 JavaEECapability 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 usingplain vanilla light weight Java EE
    • rm -Rf spring*
    • Sure it would befun, but not very realistic
    • We need a recipe that moves us forward step by step
    • Old school Spring applots of complex XML, no annotationsold / outdated ORM solution JDBC Templates, Kodo, Toplink, etc.deprecated extension based Web MVC(SimpleFormController, etc.)
    • Migration path1. Upgrade Spring version2.Replace old frameworks (ORM, web framework) within Spring3.Run Spring and Java EE container side by side4.Replace Spring entirely5.Remove Spring container
    • Migration path1. Upgrade Spring version2.Replace old frameworks (ORM, web framework) within Spring3.Run Spring and Java EE container side by side4.Replace Spring entirely5.Remove Spring container
    • Upgrade Spring versionUpgrade Spring runtime (replace JAR files)No code / configuration changes
    • Migration path1. Upgrade Spring version2.Replace old frameworks (ORM, web framework) within Spring3.Run Spring and Java EE container side by side4.Replace Spring entirely5.Remove Spring container
    • replace old frameworks within Springpresentaton layer Web MVC @AutoWiredbusiness Spring beans layer Tasks @AutoWired @AutoWiredData / Integration Spring JDBC layer Kodo JMS beans Templates
    • replace old frameworks within Springpresentaton layer Web MVC @AutoWiredbusiness Spring beans layer Tasks @AutoWired @AutoWiredData / Integration Spring JDBC layer JPA JMS beans Templates
    • replace old frameworks within Springpresentaton layer JSF @AutoWiredbusiness Spring beans layer Tasks @AutoWired @AutoWiredData / Integration Spring JDBC layer JPA JMS beans Templates
    • replace old frameworks within Springpresentaton layer JSF Don’t touch Spring @AutoWired specific APIs yetbusiness Spring beans layer Tasks @AutoWired @AutoWiredData / Integration Spring JDBC layer JPA JMS beans Templates
    • W hat about Spring APIs wedon’t want to change yet? Jdbc Templates REST Templates Task Scheduling etc.
    • Migration path1. Upgrade Spring version2.Replace old frameworks (ORM, web framework) within Spring3.Run Spring and Java EE container side by side4.Replace Spring entirely5.Remove Spring container
    • Using Spring and Java EE side-by-sideDisclaimer 1: this is just to give an idea, thisis not a production ready framework! Disclaimer 2: this is a migration path. Not the way you should build your next application...
    • Spring applicationServlet Container myapp.war Spring container TX manager ORM Spring   beans AOP Spring   beans
    • Java EE applicationJava EE 6 application server CDI / EJB container myapp.war TX manager Interceptors Security JPA CDI  beans Session  beans
    • MixedJava 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 containerpresentaton layer JSF @AutoWiredbusiness f Spring beans d stuf layer Ad here... Tasks @AutoWiredData / Integration Spring JDBC layer JPA JMS beans Templates
    • add Java EE code keep old Spring codepresentaton layer JSF @AutoWired @Injectbusiness layer Spring beans EJB CDI Tasks @AutoWired @InjectData / Integration Spring JDBC layer JPA JMS beans Templates
    • Dependency InjectionSpring already supportsJSR-330Use @Inject anywhere you use@AutoWiredCDI could be almost a drop-inreplacement 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 examplehttps://github.com/paulbakker/migrating-spring-to-javaee
    • Migration path1. Upgrade Spring version2.Replace old frameworks (ORM, web framework) within Spring3.Run Spring and Java EE container side by side4.Replace Spring entirely5.Remove Spring container
    • presentaton layer entirely replace Spring JSF @AutoWired @Injectbusiness Spring beans EJB CDI layer Tasks @AutoWired @InjectData / Integration Spring JDBC layer JPA JMS beans Templates
    • presentaton layer entirely replace Spring JSF @Inject @Injectbusiness EJB CDI EJB Timers layer @Inject @InjectData / Integration Spring JDBC layer JPA MDB Templates
    • The TX layerMigrate Spring TX and DAOs to EJBThe TX manager is in the app serverAn EJB is transactional by defaultEJB 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 loadingMany Spring apps use the Open-EntityManager-In-View patternEJB has the Extended PersistenceContext
    • LazyInitializationException
    • Fixing lazy loading
    • Detached entitiesSpring DAOs are stateless (all singletons)Load > edit > save needs a mergeWith 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 Templates1. Can b e injected with simple Producer method2.It is n ot relying on Spring container3.some extra dependencies though
    • Template producer example
    • Migration path1. Upgrade Spring version2.Replace old frameworks (ORM, web framework) within Spring3.Run Spring and Java EE container side by side4.Replace Spring entirely5.Remove Spring container
    • Removing DependenciesOur classpath just has tocontain APIs, no frameworkclassesFrom ~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 quillianCreate 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 interestArquillian: TheExtendable Enterprise Test Introducing Contexts andPlatform (24121) Dependency Injection 1.1Beginning Java EE 6 (22480)(23421) Java EE 6: The Cool PartsCDI Today and Tomorrow (21641)(19941) Java EE and Spring/MVCEnterprise JavaBeans Shoot-out (24161)Technology 3.2 (23180) Rethinking Best PracticesHacking Java EE: CDI with Java EE 6 (21622)Extension Writing n00b tol33t (23805)
    • contact us:Bert Ertmanbert.ertman@lum inis.euPaul Bakkerpaul.bakker@lum inis.eu