JAVA EE 6 Best Practices for Migrating Spring to WTF ?!?

Slides:



Advertisements
Similar presentations
Java EE - Introduction -
Advertisements

Question examples. Session 1 Objectives Why certify? Positioning of the non-technical version What is Java? Key advantages of Java Java Applications vs.
ISE 390 Dynamic Web Development Java EE Web Applications.
Spring, Hibernate and Web Services 13 th September 2014.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
1.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.Public 1 Testing Java EE Applications using Arquillian Reza Rahman Java EE/GlassFish.
E-business Architecture.NET vs J2EE Judith Molka-Danielsen Feb.27, 2004.
© Internna Technologies 1 IWebMvc Features, Possibilities & Goals.
The Spring Framework: A brief introduction to Inversion of Control James Brundege
Intro to Spring CJUG - January What is Spring? “The Spring framework provides central transaction control of various objects.” This means that any.
Using Third-Party Frameworks in Building Blocks™ David Ashman Principal Architect, Product Development.
The Spring Framework A quick overview. The Spring Framework 1. Spring principles: IoC 2. Spring principles: AOP 3. A handful of services 4. A MVC framework.
Spring Roo CS476 Aleksey Bukin Peter Lew. What is Roo? Productivity tool Allows for easy creation of Enterprise Java applications Runs alongside existing.
CIS 764 Kansas State University
Introduction to JPA Java Persistence API Introduction to JPA.
Hibernatification! Roadmap for Migrating from Plain Old SQL on JDBC to JPA on Hibernate Duke Banerjee Senior Developer, DrillingInfo.com.
Introduction to the JBoss Presented by: Hao Shi. Agenda Application Servers What is JBoss JBoss features Architecture of JBoss Installation and running.
Java Server Faces St. Louis JavaSIG June 8, 2006 Jay Meyer, Harpoon Technologies.
2007 JavaOne SM Conference | Session BOF-4181 | BOF-4181 Migrating a Spring/Hibernate Application to Java Platform, Enterprise Edition (Java EE) 5 Adrian.
NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework.
Introduction to the Spring Framework By: Nigusse A. Duguma Kansas State university Department of Computer Science Nov 20, 2007.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Java Servlets CS-422. Application Mapping Your servlet application will be mapped to a directory structure: –“myapp” maps to some directory C:/docs/apps/myapp.
Office 365 Platform Flexible Tools Understand different provisioning options and their advantages and disadvantages…
OpusCollege and the use of Spring and iBatis
Dependency Injection in Action Jan Västernäs. CADEC2006, DI, Slide 2 Copyright 2006, Callista Enterprise AB Agenda (DI=Dependency Injection) Background.
JBoss at Work JAW Motors Application Chapter 1-3 Jeff Schmitt October 9, 2006.
Text 16 de mayo de 2009 Spring Framework Part I. Dependency Injection Buenos Aires, May 2009.
Opus College - overview. OpusCollege - background First project: ICT Capacity Building Mozambican Higher Education Institutions Partners: RUG Groningen,
Cloud Computing Computer Science Innovations, LLC.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Introduction to Web Dimitar Nenchev Ivan Nakov
1 Apache TomEE // JavaEE Web Profile on Tomcat Jonathan #TomEE.
JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006.
Spring Framework. About spring Spring is the most popular application development framework for enterprise Java. Millions of developers around the world.
Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
Jonathan Gallimore | Tomitribe Cluster your application with JCache and CDI.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Enterprise JavaBeans 3.0. What is EJB 3.0 -Reusable server-side component framework-technology -Designed to support building demanding enterprise – level.
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
By Srinivas Mahakud Java Persistence API JPA. Review Topics: Introduction what is the JPA? What is the JPA contains of? Why developers should Create the.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
.  A reference model developed for an important use case (Air Job) including UI widgets, controllers, services and DAOs.  After full requirement analysis.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions and Spring MVC Buenos Aires, June 2009.
Google Code Libraries Dima Ionut Daniel. Contents What is Google Code? LDAPBeans Object-ldap-mapping Ldap-ODM Bug4j jOOR Rapa jongo Conclusion Bibliography.
Test Java EE applications with Arquillian Ivan St. Ivanov.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
1.Education Overview JAVA EE 6 Technologies
Deploying Elastic Java EE Microservices in the Cloud with Docker
Apache TomEE Tomcat with a kick. Apache TomEE: Overview ● Java EE 6 Web Profile certification in progress ● Apache TomEE Includes support for: ● Servlet.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
CS520 Web Programming Spring – Inversion of Control Chengyu Sun California State University, Los Angeles.
The Holmes Platform and Applications
J2EE Lecture 6: Spring – IoC and Dependency Injection
Java EE, Microservices, Microprofile and Playing a little mix & match
Introduction to J2EE Architecture
Java EE Overview The problem Java Enterprise Edition attempts to solve: maximize the use of Java technologies by providing a suite of Java technology specifications.
Intro to Spring CJUG - January 2013.
ISE 390 Dynamic Web Development
Java EE Overview The problem Java Enterprise Edition attempts to solve: maximize the use of Java technologies by providing a suite of Java technology specifications.
The Model Layer What is Model?
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Enterprise Java Beans.
CS4961 Software Design Laboratory Understand Aquila Backend
Presentation transcript:

JAVA EE 6 Best Practices for Migrating Spring to WTF ?!?

Bert Ertman Fellow at Luminis in the Netherlands JUG Leader for NLJUG and a Java Champion

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? We’re not working for an application server vendor We’re no Rod Johnson groupies either We’ve worked extensively with J2EE, Spring and modern Java EE Had endless Java EE vs. Spring discussions...

Why migrate? Spring is proprietary technology Upgrading from old school Spring requires a lot of work anyway Why not take it to the standard?

Scenario A

But now we want this

Let’s get a couple of misunderstanding 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

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 need AOP! Really? You love getting your code all asymmetric and unreadable? Or are you just using AOP light a.k.a. Spring AOP a.k.a. (Java EE) Interceptors?

Do I need heavy tooling?

Capabilities comparison CapabilitySpringJavaEE Dependency InjectionSpring ContainerCDI TransactionsAOP / annotationsEJB Web frameworkSpring Web MVCJSF AOPAspectJ (limited to Spring beans)Interceptors MessagingJMSJMS / CDI Data AccessJPA / JDBC templates / other ORMJPA RESTful Web Services Spring Web MVC (3.0)JAX-RS Integration testingSpring Test frameworkArquillian * * Not part of the Java EE specification

It can all be done using plain vanilla light weight Java EE

rm -Rf spring* ?

Sure it would be fun! realistic?

Typical 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. Add Java EE code, keep old Spring code 4. Replace Spring entirely 5. Remove Spring container

Replace old frameworks within Spring presentaton layer Data / Integration layer Web MVCTasks Spring JDBC Templates business layer JMS JPA JSF Don’t touch Spring specific APIs yet Spring beans

Migration Path 1. Upgrade Spring version 2. Replace old frameworks (ORM, web framework) within Spring 3. Add Java EE code, keep old Spring code 4. Replace Spring entirely 5. Remove Spring container

myapp.war Spring container Servlet Container Spring application Spring beans TX manager AOP ORM

Java EE 6 application server CDI / EJB container myapp.war CDI beans Session beans TX manager SecurityInterceptorsJPA Java EE application

Java EE 6 application server CDI / EJB container myapp.war CDI beans Session beans TX manager SecurityInterceptorsJPA Spring container Spring beans TX manager AOP ORM Mixed

Run Spring within a Java EE container presentaton layer Data / Integration layer Spring beansTasks Spring JDBC Templates business layer JMS JPA JSF

Add Java EE code, keep old Spring code presentaton layer Data / Integration layer Spring beansTasks Spring JDBC Templates business layer JMS JPA

The Spring DAO

Spring configuration

JSF / CDI bean Here we don’t want to know about Spring

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

CDI extension example

Migration Path 1. Upgrade Spring version 2. Replace old frameworks (ORM, web framework) within Spring 3. Add Java EE code, keep old Spring code 4. Replace Spring entirely 5. Remove Spring container

Replace Spring entirely presentaton layer Data / Integration layer Spring beansTasks Spring JDBC Templates business layer JMS JPA

Replace Spring entirely presentaton layer Data / Integration layer EJB Timers business layer JPA Spring JDBC 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! EJBs are just container managed POJOs Just like Spring beans, but without the container configuration...

DAO Spring

DAO configuration

The Java EE alternative EJB

Dealing with Lazy Loading Many Spring apps use the Open- EntityManager-In-View pattern EJB has the Extended Persistence Context more explicit and more powerful

LazyInitializationException

Fixing lazy loading Keeps an EntityManager open as long a the bean exists

Template addict? What if I’m hooked to JDBC Template? Hmm, let’s start the old discussion about whether or not to use ORM phase 1: denial phase 2: eventually you will migrate ;- )

Using JDBC Template within Java EE Can be injected with simple Producer method Possible because it is not relying on Spring container some extra dependencies though

Template producer example

Migration Path 1. Upgrade Spring version 2. Replace old frameworks (ORM, web framework) within Spring 3. Add Java EE code, keep old Spring code 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 1

What about testing? Spring has always been great at testing DI makes unit testing possible Spring test framework makes testing within the Spring container possible Flexible configuration for multi- environment testing

How to test this?

Arquillian Create a micro deployment using an API Deploy to a real application server Run tests in the server

Arquillian example

Is it all worth it?

Is there life after Spring? We believe that there is always room for innovation Ideally through Open Source If it flies, bring it back to the spec!

There is more! 4-part article series on Jboss web site Step-by-step migration of Pet Clinic sample application

thank you