SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI 
Mario-Leander Reimer 
mario-leander.reimer@qaware.de 
QAware
2| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
This talkwill … 
Give a brief overview of the system’s architecture 
Try to explain the rationale behind the migration 
Outline differences and similarities between both technologies 
Show patternsandstrategiesused during the migration to translate the different concepts 
Discuss implications on the system’s architecture 
Highlight problems, challenges and lessons learned
3| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
A<<Application Cluster>> AIR LoaderMechanicA<<System>> AIR CentralA<<Subsystem>> MaintenanceA<<System>> AIR RepositoryI<<Subsystem>> Apache SolrA<<Client>> AIR ClientI<<Subsystem>> .NET WPFA<<Subsystem>> Solr ExtensionsA<<Subsystem>> DefectsA<<Subsystem>> Flat RatesA<<Subsystem>> Service BulletinsServiceTechnicianA<<Ext. System>> 3rd Party ApplicationA<<Subsystem>> AIR Fork DLLA<<Subsystem>> AIR Call DLLLaunchI<<Subsystem>> Spring FrameworkI<<Subsystem>> JEE 5A<<System>> AIR ControlI<<Subsystem>> JenkinsA<<Subsystem>> DocumentsA<<Subsystem>> VehiclesA<<Subsystem>> MeasuresBackend Databasesand SystemsA<<Subsystem>> Repair OverviewA<<Subsystem>> MasterdataA<<Subsystem>> JSF Web UIA<<Subsystem>> REST APIIndependentWorkshopA<<Client>> BrowserSearch andDisplayA<<Ext. System>> 3rd Party iOS AppA<<Subsystem>> AIR iOS LibA<<Subsystem>> DefectsA<<Subsystem>> Flat RatesA<<Subsystem>> Service BulletinsI<<Subsystem>> Spring FrameworkA<<Subsystem>> DocumentsA<<Subsystem>> PartsA<<Subsystem>> WS ClientsA<<Subsystem>> File StorageA<<Subsystem>> Solr AccessA<<Subsystem>> ProtocollA<<Subsystem>> WatchlistA<<Subsystem>> MasterdataA<<Subsystem>> RetrofitsAIR DBDocumentStorageA<<Ext. System>> AIR BusI<<Ext. System>> Backend SystemsQueryA<<Subsystem>> VehiclesExecuteLoad400 GBSolr IndexA<<Subsystem>> Maintenance
4| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Whywouldyouwanttomigratea stableandrunningsystem? 
The shortanswer: IT governance. 
The longanswer: 
JEE nowprovidesthesame functionalityandisa standard 
Easy andcostefficientmigrationtofutureJEE versions 
Lowercostsforweb infrastructureandapplicationoperations 
Easy applicationmaintenanceby*-shorecompanies 
Noadditional vendorsupportrequired, noadditional costs
5| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer
6| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Annotation basedwiringofcomponentsusingconstructorinjection
7| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
UsageofcustomSpring annotationsformoreexpressiveness
8| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
XML basedwiringofcomponentsforSpring specificbeansandmorecomplexcomponents
9| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
FactoryBeanstobuildbeaninstanceswithregularJava code
10| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Usageofpropertyplaceholdersupporttoinjectconfigurationvalues
11| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Implementation ofAspectJbasedproxiesforcrosscuttingconcerns
12| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
ProgrammaticbeanlookupusingtheRegistry patternandtheApplicationContext
13| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
UsageofSpring beanprofilesforenvironmentspecificbeanconfigurations
14| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Spring XML namespacesforsyntacticsugar
15| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Unit andmoduletestsheavilyuseandrelyon theSpring Testing framework
16| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Wewerefacedwithmorequestionsthanwehadanswersfor 
How to migrate basic annotation based bean wiring? 
How to migrate XML based bean wiring and factory beans? 
How to migrate Spring property placeholder support? 
How to migrate AspectJ based AOP proxies? 
How to migrate programmatic bean lookups? 
How to migrate Spring bean profiles? 
How to migrate custom Spring XML namespaces? 
How to migrate code that is built against Spring APIs? 
How to migrate unit test based on Spring Test?
17| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer
18| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer
19| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
All new Java EE 7 Maven Coordinates
20| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Individual Mavenmodulesasmainunitofmigration 
ReplaceSpring annotationsandwiringswithCDI equivalent 
ReplaceXML contextdefinitionswithbeans.xml 
Optional: adjustcomponentstobenefitfromCDI 
Find and/orbuildsubstitutesforSpring specificfeatures 
Adjustunitandintegrationtests
21| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Basic Spring toCDI annotationmigrationisstraightforward, withsubtledifferences 
Caution: Spring andCDI havea different defaultscope! 
CDI usesclientproxiesper default(exceptfor@Dependent), in Spring youhavetodo thisexplicitly. 
This mightinfluenceyourwiringstyle. Becarefulwithfinal. 
Spring Annotation 
CDI Annotation 
@Component(„myBean“) 
 
@Named(„myBean“) 
@Scope(„singleton“) 
 
@ApplicationScoped 
@Scope(„prototype“) 
 
@Dependent 
@Scope(„request“) 
 
@RequestScoped 
@Scope(„session“) 
 
@SessionScoped 
@Autowired 
 
@Inject 
Default 
Default
22| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Bothtechnologiessupport@Qualifiertodistinguishvariousimplementations 
Tip: do not use@Namedtoqualifyyourcomponentsin CDI, use 
custom@Qualifierannotationsinstead.
23| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
@Stereotype istheCDI equivalenttocustom@Componentannotations 
Tip: check the@Target annotationoftheCDI stereotype, and 
includeMETHODso itcanbeappliedto@Producesmethods.
24| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Migrate*-components.xml tobeans.xml 
Tip: useCDI 1.1 bean-discovery-mode=„annotated“ 
astheequivalenttoSpring‘scomponentscan.
25| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
XML based bean wiring as well as factory beans are migrated to Producer methods 
-Factory beanscanalso usedependencyinjection 
-Support forlifecycle 
-Constructorinjection 
-Nestedfactorybean
26| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
XML based bean wiring as well as factory beans are migrated to Producer methods
27| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
ThereisnodirectequivalenttoSpring‘s@Value(„${some.property}“) annotation
28| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Property injectionsupportforCDI usingtheDeltaSpikeConfigurationMechanism 
Tip: havea lookat Apache DeltaSpikebeforeyoustartbuilding 
yourowncustomCDI extensionsformissingfeatures.
29| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Migrating Spring AOP using @Interceptor and @InterceptorBindingannotations 
Activate aspectsandautoproxy 
relevant beans 
Pointcutforall publicmethodsin classesannotatedwith@Service 
Pointcutforall publicmethodsin classesannotatedwith@Repository
30| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Migrating Spring AOP using @Interceptor and @InterceptorBindingannotations
31| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
The CDI way for programmatic bean lookup improved our code enormously 
BeanManageristhe~ equivalenttoApplicationContext 
MigratedApplicationContextAwarestaticregistryclasstousetheBeanManagerinstead 
Advice: don‘tuseBeanManagerdirectly.It‘stoolowlevel. Don‘tusea staticregistryeither. Gruesometestability! 
Tip: ifstaticaccesstocontextualreferencesisreallyrequired, usetheDeltaSpikeBeanProviderimplementation.
32| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Are Alternatives theequivalenttoSpring‘sbeandefinitionprofiles? Almost. 
Problem: Alternatives needtobeactivatedin thebean.xml 
Not suitableforenvironmentspecific, dynamicactivation. 
Usea CDI extensiontovetoannotatedtype ifprofileisnot active. 
Alternative: UsetheDeltaSpikeProjectStagemechanism.
33| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
The migrationofourcustomSpring XML namespacesseemedtobea challenge 
Create instanceoftype FiniteStateMachinewithgivenID asbeanname 
Enumtype definitions 
Create transitioninstancewithgivenproperties 
Bean lookupbynameforactioninstancetoexecute
34| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Programmaticapproach: combineBuilderpatternwitha producermethod 
Usedfornamedaction 
beanlookup
35| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Improvedapproach: usea CDI extensiontoreadXML filesandcreateFSM beans 
Createsinstances, usestheBuilderfromfirstapproach
36| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
DirectusageofsimplifiedJMS 2.0 API insteadofSpring‘sJmsTemplate 
Sending 
Receiving
37| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
ReplacingSpring‘sTesting Framework was painfulanda lotofwork 
SpringJUnit4ClassRunnerMockitoJUnitRunner 
This workreallypaidof 
Simplifiedunittestswithbetterisolation 
decreasedexecutiontime 
Different approachesandtestrunnersforCDI testsavailable: 
JglueCDI-Unit: @RunWith(CdiRunner.class) 
DeltaSpikeTest-Control: @RunWith(CdiTestRunner.class) 
Arquillian: @RunWith(Arquillian.class) 
Testing a CDI enabledJAR in isolationiscomplexandlaborious(orjust didn‘twork)
38| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
Andtherewas a lotmorecodetomigrate 
MigratedSpring taskexecutionandschedulingfuntionalityto@AsyncmethodsorJEE7 ManagedExecutorService 
The JPA persistencecodemigrationwentsmoothly 
Migratedpersistence.xml fromJPA 1.0 to2.1 
Simple JPA unittestsusingDBUnitfortestdatasetup 
The JSF web layermigrationwas quitetedious 
Homogenizeannotationusage: replacedFacesbeanannotationswithCDI equivalent(e.g. @ManagedBean@Named) 
RemovedRegistry basedlookupofservicefacadeinstances 
Migratedandsimplifiedunittests, thisalso improvedtestquality
39| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
28 daysand300K LOC later…
40| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
28 daysand300K LOC later… 
… wehadtheAIR Central web applicationfullymigratedandrunningon Glassfishv4. 
Migration effortswereordersofmagnitudelowerthaninitiallyestimatedandanticipated! 
The standaloneAIR Loaderapplicationswerenexttomigrate: 
usingCDI fromJava SE, 
evenmorecomplexSpring XML namespace, 
comprehensiveusageofSpring JDBC.
41| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 
LessonsLearnedandResumé 
JEE7 andCDI havedefinitelycaughtupon Spring 
Therewas noSpring featurethatcouldnot bemigrated 
Someconvenienceisstill missing, but 
CDI provideslightweightandeasy touseextensionmechanisms, 
thereisgrowingsupportfromtheOpen Source community. 
Questionandrethinkestablishedpatternsandbestpractices 
More carefulwhenusingandbindingtoa specificframework
QUANTENSPRUNG DANK ANDERSDENKEN

Contenu connexe

Tendances

ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
Masatoshi Tada
 
3D描画基礎知識
3D描画基礎知識3D描画基礎知識
3D描画基礎知識
AimingStudy
 
Spring Bootで変わる Javaアプリ開発! #jsug
Spring Bootで変わる Javaアプリ開発! #jsugSpring Bootで変わる Javaアプリ開発! #jsug
Spring Bootで変わる Javaアプリ開発! #jsug
Toshiaki Maki
 

Tendances (20)

Ansible ネットワーク自動化チュートリアル (JANOG42)
Ansible ネットワーク自動化チュートリアル (JANOG42)Ansible ネットワーク自動化チュートリアル (JANOG42)
Ansible ネットワーク自動化チュートリアル (JANOG42)
 
JDK 16 で導入された JEP 396 にご注意!! (JJUG CCC 2021 Spring)
JDK 16 で導入された JEP 396 にご注意!! (JJUG CCC 2021 Spring)JDK 16 で導入された JEP 396 にご注意!! (JJUG CCC 2021 Spring)
JDK 16 で導入された JEP 396 にご注意!! (JJUG CCC 2021 Spring)
 
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
 
Springを何となく使ってる人が抑えるべきポイント
Springを何となく使ってる人が抑えるべきポイントSpringを何となく使ってる人が抑えるべきポイント
Springを何となく使ってる人が抑えるべきポイント
 
基本設計+詳細設計の書き方 社内勉強会0304
基本設計+詳細設計の書き方 社内勉強会0304基本設計+詳細設計の書き方 社内勉強会0304
基本設計+詳細設計の書き方 社内勉強会0304
 
JUnit実践入門 xUnitTestPatternsで学ぶユニットテスト
JUnit実践入門 xUnitTestPatternsで学ぶユニットテストJUnit実践入門 xUnitTestPatternsで学ぶユニットテスト
JUnit実践入門 xUnitTestPatternsで学ぶユニットテスト
 
Spring Bootをはじめる時にやるべき10のこと
Spring Bootをはじめる時にやるべき10のことSpring Bootをはじめる時にやるべき10のこと
Spring Bootをはじめる時にやるべき10のこと
 
【TECH×GAME COLLEGE#28】形から入ったドメイン駆動設計によるゲーム開発の光と闇
【TECH×GAME COLLEGE#28】形から入ったドメイン駆動設計によるゲーム開発の光と闇【TECH×GAME COLLEGE#28】形から入ったドメイン駆動設計によるゲーム開発の光と闇
【TECH×GAME COLLEGE#28】形から入ったドメイン駆動設計によるゲーム開発の光と闇
 
3D描画基礎知識
3D描画基礎知識3D描画基礎知識
3D描画基礎知識
 
Spring Fest 2018 Spring Bootで作るRESTful Web Service
Spring Fest 2018 Spring Bootで作るRESTful Web ServiceSpring Fest 2018 Spring Bootで作るRESTful Web Service
Spring Fest 2018 Spring Bootで作るRESTful Web Service
 
REST API のコツ
REST API のコツREST API のコツ
REST API のコツ
 
これから始めるSpringのwebアプリケーション
これから始めるSpringのwebアプリケーションこれから始めるSpringのwebアプリケーション
これから始めるSpringのwebアプリケーション
 
2018/1/30 Django勉強会
2018/1/30 Django勉強会2018/1/30 Django勉強会
2018/1/30 Django勉強会
 
Spring Bootで変わる Javaアプリ開発! #jsug
Spring Bootで変わる Javaアプリ開発! #jsugSpring Bootで変わる Javaアプリ開発! #jsug
Spring Bootで変わる Javaアプリ開発! #jsug
 
Diapositivas Spring Framework- Javier Oliver Fulguera
Diapositivas Spring Framework-  Javier Oliver FulgueraDiapositivas Spring Framework-  Javier Oliver Fulguera
Diapositivas Spring Framework- Javier Oliver Fulguera
 
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
 
.NET 7 での ASP.NET Core Blazor の新機能ピックアップ
.NET 7 での ASP.NET Core Blazor の新機能ピックアップ.NET 7 での ASP.NET Core Blazor の新機能ピックアップ
.NET 7 での ASP.NET Core Blazor の新機能ピックアップ
 
Java Tutorial:Learn Java in 06:00:00
Java Tutorial:Learn Java in 06:00:00Java Tutorial:Learn Java in 06:00:00
Java Tutorial:Learn Java in 06:00:00
 
継続使用と新規追加したRedmine Plugin
継続使用と新規追加したRedmine Plugin継続使用と新規追加したRedmine Plugin
継続使用と新規追加したRedmine Plugin
 
Upgrade to 3.1 Planning.pdf
Upgrade to 3.1 Planning.pdfUpgrade to 3.1 Planning.pdf
Upgrade to 3.1 Planning.pdf
 

Similaire à Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI

cuttingEdgepresentation0318
cuttingEdgepresentation0318cuttingEdgepresentation0318
cuttingEdgepresentation0318
Hongbiao Chen
 
Mufeedh_3 .10 Years Exp_Java
Mufeedh_3 .10 Years Exp_JavaMufeedh_3 .10 Years Exp_Java
Mufeedh_3 .10 Years Exp_Java
Mufeedh Mufi
 

Similaire à Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI (20)

Mastering spring 5.0 - By SADIK SAID
Mastering spring 5.0 - By SADIK SAIDMastering spring 5.0 - By SADIK SAID
Mastering spring 5.0 - By SADIK SAID
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
 
cuttingEdgepresentation0318
cuttingEdgepresentation0318cuttingEdgepresentation0318
cuttingEdgepresentation0318
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
 
Microservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloudMicroservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloud
 
Resume amrit
Resume amritResume amrit
Resume amrit
 
Spring tutorials
Spring tutorialsSpring tutorials
Spring tutorials
 
Sai_Resume
Sai_ResumeSai_Resume
Sai_Resume
 
Migrating Monoliths to Microservices -- M3
Migrating Monoliths to Microservices -- M3Migrating Monoliths to Microservices -- M3
Migrating Monoliths to Microservices -- M3
 
Mufeedh_3 .10 Years Exp_Java
Mufeedh_3 .10 Years Exp_JavaMufeedh_3 .10 Years Exp_Java
Mufeedh_3 .10 Years Exp_Java
 
Resume
ResumeResume
Resume
 
Spring learning path
Spring learning pathSpring learning path
Spring learning path
 
Web 2.0 Development with IBM DB2
Web 2.0 Development with IBM DB2Web 2.0 Development with IBM DB2
Web 2.0 Development with IBM DB2
 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
java web framework standard.20180412
java web framework standard.20180412java web framework standard.20180412
java web framework standard.20180412
 
Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and concepts
 
Prakash Singh Resume.docx
Prakash Singh Resume.docxPrakash Singh Resume.docx
Prakash Singh Resume.docx
 
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...
 

Plus de Mario-Leander Reimer

Steinzeit war gestern! Die vielfältigen Wege der Cloud-nativen Evolution
Steinzeit war gestern! Die vielfältigen Wege der Cloud-nativen EvolutionSteinzeit war gestern! Die vielfältigen Wege der Cloud-nativen Evolution
Steinzeit war gestern! Die vielfältigen Wege der Cloud-nativen Evolution
Mario-Leander Reimer
 

Plus de Mario-Leander Reimer (20)

Steinzeit war gestern! Vielfältige Wege der Cloud-nativen Evolution.
Steinzeit war gestern! Vielfältige Wege der Cloud-nativen Evolution.Steinzeit war gestern! Vielfältige Wege der Cloud-nativen Evolution.
Steinzeit war gestern! Vielfältige Wege der Cloud-nativen Evolution.
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
 
Steinzeit war gestern! Die vielfältigen Wege der Cloud-nativen Evolution
Steinzeit war gestern! Die vielfältigen Wege der Cloud-nativen EvolutionSteinzeit war gestern! Die vielfältigen Wege der Cloud-nativen Evolution
Steinzeit war gestern! Die vielfältigen Wege der Cloud-nativen Evolution
 
Everything-as-code: DevOps und Continuous Delivery aus Sicht des Entwicklers....
Everything-as-code: DevOps und Continuous Delivery aus Sicht des Entwicklers....Everything-as-code: DevOps und Continuous Delivery aus Sicht des Entwicklers....
Everything-as-code: DevOps und Continuous Delivery aus Sicht des Entwicklers....
 
Das kleine Einmaleins der sicheren Architektur @heise_devSec
Das kleine Einmaleins der sicheren Architektur @heise_devSecDas kleine Einmaleins der sicheren Architektur @heise_devSec
Das kleine Einmaleins der sicheren Architektur @heise_devSec
 
Polyglot Adventures for the Modern Java Developer #javaone2017
Polyglot Adventures for the Modern Java Developer #javaone2017Polyglot Adventures for the Modern Java Developer #javaone2017
Polyglot Adventures for the Modern Java Developer #javaone2017
 
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2day
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2dayElegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2day
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2day
 
Cloud-native .NET-Microservices mit Kubernetes @BASTAcon
Cloud-native .NET-Microservices mit Kubernetes @BASTAconCloud-native .NET-Microservices mit Kubernetes @BASTAcon
Cloud-native .NET-Microservices mit Kubernetes @BASTAcon
 
A Hitchhiker’s Guide to the Cloud Native Stack. #DevoxxPL
A Hitchhiker’s Guide to the Cloud Native Stack. #DevoxxPLA Hitchhiker’s Guide to the Cloud Native Stack. #DevoxxPL
A Hitchhiker’s Guide to the Cloud Native Stack. #DevoxxPL
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPL
 
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
 
Per Anhalter durch den Cloud Native Stack. #SEACONHH
Per Anhalter durch den Cloud Native Stack. #SEACONHHPer Anhalter durch den Cloud Native Stack. #SEACONHH
Per Anhalter durch den Cloud Native Stack. #SEACONHH
 
Everything-as-code. Ein polyglottes Abenteuer. #jax2017
Everything-as-code. Ein polyglottes Abenteuer. #jax2017Everything-as-code. Ein polyglottes Abenteuer. #jax2017
Everything-as-code. Ein polyglottes Abenteuer. #jax2017
 
Everything-as-code. Eine vielsprachige Reise. #javaland
Everything-as-code. Eine vielsprachige Reise. #javalandEverything-as-code. Eine vielsprachige Reise. #javaland
Everything-as-code. Eine vielsprachige Reise. #javaland
 
Everything as-code. Polyglotte Entwicklung in der Praxis. #oop2017
Everything as-code. Polyglotte Entwicklung in der Praxis. #oop2017Everything as-code. Polyglotte Entwicklung in der Praxis. #oop2017
Everything as-code. Polyglotte Entwicklung in der Praxis. #oop2017
 
Per Anhalter durch den Cloud Native Stack (Extended Edition) #oop2017
Per Anhalter durch den Cloud Native Stack (Extended Edition) #oop2017Per Anhalter durch den Cloud Native Stack (Extended Edition) #oop2017
Per Anhalter durch den Cloud Native Stack (Extended Edition) #oop2017
 
Der Cloud Native Stack in a Nutshell. #CloudExpoEurope
Der Cloud Native Stack in a Nutshell. #CloudExpoEuropeDer Cloud Native Stack in a Nutshell. #CloudExpoEurope
Der Cloud Native Stack in a Nutshell. #CloudExpoEurope
 
A Hitchhiker’s Guide to the Cloud Native Stack. #ContainerConf
A Hitchhiker’s Guide to the Cloud Native Stack. #ContainerConfA Hitchhiker’s Guide to the Cloud Native Stack. #ContainerConf
A Hitchhiker’s Guide to the Cloud Native Stack. #ContainerConf
 
Secure Architecture and Programming 101
Secure Architecture and Programming 101Secure Architecture and Programming 101
Secure Architecture and Programming 101
 
Automotive Information Research driven by Apache Solr
Automotive Information Research driven by Apache SolrAutomotive Information Research driven by Apache Solr
Automotive Information Research driven by Apache Solr
 

Dernier

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Dernier (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI

  • 1. Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI Mario-Leander Reimer mario-leander.reimer@qaware.de QAware
  • 2. 2| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer This talkwill … Give a brief overview of the system’s architecture Try to explain the rationale behind the migration Outline differences and similarities between both technologies Show patternsandstrategiesused during the migration to translate the different concepts Discuss implications on the system’s architecture Highlight problems, challenges and lessons learned
  • 3. 3| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer A<<Application Cluster>> AIR LoaderMechanicA<<System>> AIR CentralA<<Subsystem>> MaintenanceA<<System>> AIR RepositoryI<<Subsystem>> Apache SolrA<<Client>> AIR ClientI<<Subsystem>> .NET WPFA<<Subsystem>> Solr ExtensionsA<<Subsystem>> DefectsA<<Subsystem>> Flat RatesA<<Subsystem>> Service BulletinsServiceTechnicianA<<Ext. System>> 3rd Party ApplicationA<<Subsystem>> AIR Fork DLLA<<Subsystem>> AIR Call DLLLaunchI<<Subsystem>> Spring FrameworkI<<Subsystem>> JEE 5A<<System>> AIR ControlI<<Subsystem>> JenkinsA<<Subsystem>> DocumentsA<<Subsystem>> VehiclesA<<Subsystem>> MeasuresBackend Databasesand SystemsA<<Subsystem>> Repair OverviewA<<Subsystem>> MasterdataA<<Subsystem>> JSF Web UIA<<Subsystem>> REST APIIndependentWorkshopA<<Client>> BrowserSearch andDisplayA<<Ext. System>> 3rd Party iOS AppA<<Subsystem>> AIR iOS LibA<<Subsystem>> DefectsA<<Subsystem>> Flat RatesA<<Subsystem>> Service BulletinsI<<Subsystem>> Spring FrameworkA<<Subsystem>> DocumentsA<<Subsystem>> PartsA<<Subsystem>> WS ClientsA<<Subsystem>> File StorageA<<Subsystem>> Solr AccessA<<Subsystem>> ProtocollA<<Subsystem>> WatchlistA<<Subsystem>> MasterdataA<<Subsystem>> RetrofitsAIR DBDocumentStorageA<<Ext. System>> AIR BusI<<Ext. System>> Backend SystemsQueryA<<Subsystem>> VehiclesExecuteLoad400 GBSolr IndexA<<Subsystem>> Maintenance
  • 4. 4| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Whywouldyouwanttomigratea stableandrunningsystem? The shortanswer: IT governance. The longanswer: JEE nowprovidesthesame functionalityandisa standard Easy andcostefficientmigrationtofutureJEE versions Lowercostsforweb infrastructureandapplicationoperations Easy applicationmaintenanceby*-shorecompanies Noadditional vendorsupportrequired, noadditional costs
  • 5. 5| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer
  • 6. 6| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Annotation basedwiringofcomponentsusingconstructorinjection
  • 7. 7| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer UsageofcustomSpring annotationsformoreexpressiveness
  • 8. 8| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer XML basedwiringofcomponentsforSpring specificbeansandmorecomplexcomponents
  • 9. 9| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer FactoryBeanstobuildbeaninstanceswithregularJava code
  • 10. 10| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Usageofpropertyplaceholdersupporttoinjectconfigurationvalues
  • 11. 11| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Implementation ofAspectJbasedproxiesforcrosscuttingconcerns
  • 12. 12| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer ProgrammaticbeanlookupusingtheRegistry patternandtheApplicationContext
  • 13. 13| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer UsageofSpring beanprofilesforenvironmentspecificbeanconfigurations
  • 14. 14| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Spring XML namespacesforsyntacticsugar
  • 15. 15| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Unit andmoduletestsheavilyuseandrelyon theSpring Testing framework
  • 16. 16| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Wewerefacedwithmorequestionsthanwehadanswersfor How to migrate basic annotation based bean wiring? How to migrate XML based bean wiring and factory beans? How to migrate Spring property placeholder support? How to migrate AspectJ based AOP proxies? How to migrate programmatic bean lookups? How to migrate Spring bean profiles? How to migrate custom Spring XML namespaces? How to migrate code that is built against Spring APIs? How to migrate unit test based on Spring Test?
  • 17. 17| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer
  • 18. 18| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer
  • 19. 19| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer All new Java EE 7 Maven Coordinates
  • 20. 20| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Individual Mavenmodulesasmainunitofmigration ReplaceSpring annotationsandwiringswithCDI equivalent ReplaceXML contextdefinitionswithbeans.xml Optional: adjustcomponentstobenefitfromCDI Find and/orbuildsubstitutesforSpring specificfeatures Adjustunitandintegrationtests
  • 21. 21| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Basic Spring toCDI annotationmigrationisstraightforward, withsubtledifferences Caution: Spring andCDI havea different defaultscope! CDI usesclientproxiesper default(exceptfor@Dependent), in Spring youhavetodo thisexplicitly. This mightinfluenceyourwiringstyle. Becarefulwithfinal. Spring Annotation CDI Annotation @Component(„myBean“)  @Named(„myBean“) @Scope(„singleton“)  @ApplicationScoped @Scope(„prototype“)  @Dependent @Scope(„request“)  @RequestScoped @Scope(„session“)  @SessionScoped @Autowired  @Inject Default Default
  • 22. 22| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Bothtechnologiessupport@Qualifiertodistinguishvariousimplementations Tip: do not use@Namedtoqualifyyourcomponentsin CDI, use custom@Qualifierannotationsinstead.
  • 23. 23| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer @Stereotype istheCDI equivalenttocustom@Componentannotations Tip: check the@Target annotationoftheCDI stereotype, and includeMETHODso itcanbeappliedto@Producesmethods.
  • 24. 24| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Migrate*-components.xml tobeans.xml Tip: useCDI 1.1 bean-discovery-mode=„annotated“ astheequivalenttoSpring‘scomponentscan.
  • 25. 25| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer XML based bean wiring as well as factory beans are migrated to Producer methods -Factory beanscanalso usedependencyinjection -Support forlifecycle -Constructorinjection -Nestedfactorybean
  • 26. 26| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer XML based bean wiring as well as factory beans are migrated to Producer methods
  • 27. 27| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer ThereisnodirectequivalenttoSpring‘s@Value(„${some.property}“) annotation
  • 28. 28| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Property injectionsupportforCDI usingtheDeltaSpikeConfigurationMechanism Tip: havea lookat Apache DeltaSpikebeforeyoustartbuilding yourowncustomCDI extensionsformissingfeatures.
  • 29. 29| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Migrating Spring AOP using @Interceptor and @InterceptorBindingannotations Activate aspectsandautoproxy relevant beans Pointcutforall publicmethodsin classesannotatedwith@Service Pointcutforall publicmethodsin classesannotatedwith@Repository
  • 30. 30| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Migrating Spring AOP using @Interceptor and @InterceptorBindingannotations
  • 31. 31| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer The CDI way for programmatic bean lookup improved our code enormously BeanManageristhe~ equivalenttoApplicationContext MigratedApplicationContextAwarestaticregistryclasstousetheBeanManagerinstead Advice: don‘tuseBeanManagerdirectly.It‘stoolowlevel. Don‘tusea staticregistryeither. Gruesometestability! Tip: ifstaticaccesstocontextualreferencesisreallyrequired, usetheDeltaSpikeBeanProviderimplementation.
  • 32. 32| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Are Alternatives theequivalenttoSpring‘sbeandefinitionprofiles? Almost. Problem: Alternatives needtobeactivatedin thebean.xml Not suitableforenvironmentspecific, dynamicactivation. Usea CDI extensiontovetoannotatedtype ifprofileisnot active. Alternative: UsetheDeltaSpikeProjectStagemechanism.
  • 33. 33| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer The migrationofourcustomSpring XML namespacesseemedtobea challenge Create instanceoftype FiniteStateMachinewithgivenID asbeanname Enumtype definitions Create transitioninstancewithgivenproperties Bean lookupbynameforactioninstancetoexecute
  • 34. 34| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Programmaticapproach: combineBuilderpatternwitha producermethod Usedfornamedaction beanlookup
  • 35. 35| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Improvedapproach: usea CDI extensiontoreadXML filesandcreateFSM beans Createsinstances, usestheBuilderfromfirstapproach
  • 36. 36| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer DirectusageofsimplifiedJMS 2.0 API insteadofSpring‘sJmsTemplate Sending Receiving
  • 37. 37| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer ReplacingSpring‘sTesting Framework was painfulanda lotofwork SpringJUnit4ClassRunnerMockitoJUnitRunner This workreallypaidof Simplifiedunittestswithbetterisolation decreasedexecutiontime Different approachesandtestrunnersforCDI testsavailable: JglueCDI-Unit: @RunWith(CdiRunner.class) DeltaSpikeTest-Control: @RunWith(CdiTestRunner.class) Arquillian: @RunWith(Arquillian.class) Testing a CDI enabledJAR in isolationiscomplexandlaborious(orjust didn‘twork)
  • 38. 38| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer Andtherewas a lotmorecodetomigrate MigratedSpring taskexecutionandschedulingfuntionalityto@AsyncmethodsorJEE7 ManagedExecutorService The JPA persistencecodemigrationwentsmoothly Migratedpersistence.xml fromJPA 1.0 to2.1 Simple JPA unittestsusingDBUnitfortestdatasetup The JSF web layermigrationwas quitetedious Homogenizeannotationusage: replacedFacesbeanannotationswithCDI equivalent(e.g. @ManagedBean@Named) RemovedRegistry basedlookupofservicefacadeinstances Migratedandsimplifiedunittests, thisalso improvedtestquality
  • 39. 39| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 28 daysand300K LOC later…
  • 40. 40| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer 28 daysand300K LOC later… … wehadtheAIR Central web applicationfullymigratedandrunningon Glassfishv4. Migration effortswereordersofmagnitudelowerthaninitiallyestimatedandanticipated! The standaloneAIR Loaderapplicationswerenexttomigrate: usingCDI fromJava SE, evenmorecomplexSpring XML namespace, comprehensiveusageofSpring JDBC.
  • 41. 41| JavaOne2014 | Migrating a JSF-based web application from Spring 3 to Java EE 7 and CDI| M.-Leander Reimer LessonsLearnedandResumé JEE7 andCDI havedefinitelycaughtupon Spring Therewas noSpring featurethatcouldnot bemigrated Someconvenienceisstill missing, but CDI provideslightweightandeasy touseextensionmechanisms, thereisgrowingsupportfromtheOpen Source community. Questionandrethinkestablishedpatternsandbestpractices More carefulwhenusingandbindingtoa specificframework

Notes de l'éditeur

  1. Detailed case study about the technology migration of a current project for a major German car manufacturer Ask audience: who uses Spring / who uses JEE? Disclaimer: No prejudice! No bashing on either technology. This talk is purely about technology.
  2. Some Facts: - Rollout since last year, by the end of this year world wide - 17250 concurrent sessions / h - Spring Framework with some JEE5 Glassfish v2 and JDK6 400K LOC, 200K Tests, 100K Generated, 100K Handwritten Good quality, good performance, good acceptance
  3. Blueprint approval required for all used open source libraries Benefit from latest bug fixes and technology improvements More efficient and faster development mit einem lachenden und einem weinenden Auge == with mixed feelings
  4. Our first reaction: no way this is possible in adequate time. This is like taking out and replacing the spine! But we were curious, it should definitely be possible.
  5. Usually only @Component is enough. You can also give your beans a name. @Scope support: singleton and prototype. Session and request also supported in combination with a webapp. Careful with injection  scoped proxies. Visibility guarantees, strong expression of dependencies
  6. More expressiveness: Custom Component annotations, like @Service or @Repository Custom Qualifiers for type safety
  7. Good old logging aspect example. measure execution times, echo parameters, start and end of invocation
  8. Service Locator pattern also called Registry
  9. An example: Spring DSL for a FiniteStateMachine. Other examples: other Spring namespaces, Mule ESB, Camel Looks fancy, but it is not really hard to implement: XSD, NamespaceHandler and BeanDefinition parser.
  10. Absolutely essential. Test basic wiring of components using mocks. Every Maven module has ist own integration test to test module wiring in isolation.
  11. You get the point. The longer you develop, the more you use technology to it‘s full potential. This is our migration agenda for the next 30 minutes.
  12. New technology and programming wouldn‘t be so much fun if it was boring and straight forward. It is those technically challanging projects that make live as a developer interesting and worthwhile. It was time to learn something new. Still unsure about the effort it would take.
  13. JEE7 Migration: Areas of Interests  a lot of congruence Spring – CDI Everything else  CDI Extensions (Deltaspike + Custom) Common Annotations Interceptors for AOP JPA Persistence JMS for Asnyc Stuff Enterprise Beans for Services (maybe) Concurrency for Replacement of Executors.* Servlets -> 3.0 with CDI Web Fragements New JSF + EL JAX-RS / JAX-WS
  14. All New Java EE 7 Maven Coordinates + 2 few more Definitely less than all the required Spring dependencies + transitive tail deps
  15. Every business component is usually composed of API, Core and UI module. Sometimes loader module. We have 100+ different Maven modules, all following the same pattern. But obviously with subtle differences in Spring API usage and wiring.
  16. No equivalent for @Scope(„globalSession“) in CDI No equivalent for @ConversationScoped in Spring Subtle differences: Default scope in Spring is Singleton, in CDI it is @Dependent In CDI you will get a client proxy, in Spring usually not. JSR-330: no @Required or @Lazy
  17. Characterize your components using stereotypes. @Component can be anything. Usually you also define the lifecycle using @Scope here also.
  18. A producer method acts as a source of objects to be injected, where: - the objects to be injected are not required to be instances of beans, - the concrete type of the objects to be injected may vary at runtime or - the objects require some custom initialization that is not performed by the bean constructor For example, producer methods let us: - expose a JPA entity as a bean, - expose any JDK class as a bean, - define multiple beans, with different scopes or initialization, for the same implementation class, or - vary the implementation of a bean type at runtime.
  19. A producer method acts as a source of objects to be injected, where: - the objects to be injected are not required to be instances of beans, - the concrete type of the objects to be injected may vary at runtime or - the objects require some custom initialization that is not performed by the bean constructor For example, producer methods let us: - expose a JPA entity as a bean, - expose any JDK class as a bean, - define multiple beans, with different scopes or initialization, for the same implementation class, or - vary the implementation of a bean type at runtime.
  20. No equivalent to Spring‘s @Value annotation in JSR-330.
  21. Tip: before you start building a CDI extension or missing feature, have a look at Apache DeltaSpike
  22. AOP as the swiss army nife for cross-cutting concerns: - Logging, security, transactions, …
  23. AOP as the swiss army nife for cross-cutting concerns: - Logging, security, transactions, …
  24. My most favourite CDI feature: programmtic bean lookup. The simplicity is just awesome. Provides all you need to get hold of desired instances. Good testability.
  25. Bean definition profiles: enhancements in Spring Framework 3.1 Don‘t forget to activate the stereotype in beans.xml Naive approach: Alternatives and stereotype activation. Better: use DeltaSpike ProjectStages. Optimal: Build a custom CDI extension.
  26. Main advantage: it‘s code. It‘s readable and testable. Slight disadvantage: does get quite long for big FSMs. Also you need to hand code it.
  27. Idea: reuse the existing XML definitions for the FSMs. Parse these configurations and build bean instances. Again, the Apache DeltaSpike project saved us a lot of work. 3h and 290 LOC, comments included. https://github.com/rmannibucau/cdi-light-config
  28. We often used Spring tests with injection and mocks. Migrated towards Mockito mocks and injection. No problem.
  29. Nothing to be scared of anymore. CDI from Java SE  DeltaSpike Core
  30. Nothing to be scared of anymore. CDI from Java SE  DeltaSpike Core
  31. http://realworldpatterns.com/ - Real world Java EE Patterns. Rethinking Best Practices. You live and learn: man lernt nie aus! Basics are easy to understand and implement. And mostly sufficient. Basics: this also applies to building Spring based applications.