SlideShare una empresa de Scribd logo
1 de 25
ZK, Spring & JPA On
   Two PaaS Clouds
(Java MVVM Adventures Featuring
       Heroku & Openshift)
       Simon Massey
Overview
What is PaaS "Cloud" and why we should care?
Background to the ZkToDo2 sample app
Outline of the MVVM Pattern
Walk through of MVVM sample page (new ZK6
 features!)
Quick pass of the Spring & JPA internals
The key ingredient: maven build profiles
Live push of source to two clouds! (Fingers
  crossed!)
Clouds (In One Slide)
Clouds come "as a service" (aaS)
  Software aaS
  Infrastructure aaS
  Platform aaS
SaaS is your data on the cloud with leased
 software (they do everything)
IaaS is leased managed hardware (they can do
  the network)
PaaS is leased application/database capacity
 (they keep it running whilst you write the app)
The PaaS Proposition
Server virtualization is very mainstream. High
 density host servers reduce overheads
Failover, off-site backup, standby servers, spare
 parts, upgrades, network is divided by number
 of virtual servers
Rent a "virtual private server" (VPS) and you
 have to set it up and care for it yourself (logs
 filling up your disks?)
How do you source 0.2 system adminstrators for
 your app? And if they change jobs?
Outsource this to a PaaS provider!
The PaaS Proposition (2)
A big provider with a big server farm has
 automated deployment "elastic platform"
Need more power? "Click here Sir to approve
 the monthy credit card payments..."
Choice is a double edged sword; standardization
 is the key to maintaining a large estate of
 applications
Big cloud farms run thousands of servers and are
  evolving best practice at a high rate
Running your own servers is very last century;
 you can offload that work to the experts
Is Your PaaS RIA Friendly?
Not all PaaS clouds are AJAX friendly. Some
 assume that you are hosting a blog (i.e.
 stateless full page reload app)
Not all PaaS clouds provide a relational
 database. ZK apps tend to be data orientated
 desktop-like apps which need an RDBMS
J2EE is "complex" but PHP and Ruby are
  "simple"(??). Java sat outside the party whilst
  Ruby On Rails danced up a storm
… but now the big Rails clouds are doing Java
 and are making it look very easy!
Interlude

Code https://github.com/simbo1905/ZkToDo2
Where is it running?
Redhat Openshift zktd2-zkdemo.rhcloud.com
Heruko glowing-light-1070.herokuapp.com
(note: apps may suspend when idle so may take
  a long time to start on first hit)
What IDE, DB, etc?
The Code In Context
The "ZK ToDo 2" sample app has the same
 screen implimented three times; using MVP,
 MVC and ZK6 MVVM (aka MVB) patterns
Three ZK articles document the different patterns
 in the code MVP (2007), MVC (2009), MVVM
 (2011). MVVM article is out of date as sample
 code now does ZK6 "ZK Bind" MVVM
Sample code has moved to the zktodo2 repo on
 GitHub with an Apache2 license
The code now deploys to Heroku or Openshift
 PaaS clouds!
About The Code

The "ZkToDo2" sample app (aka zktd2) is a
 simple database CRUD app written with ZK,
 Spring and JPA
Code uses a relational DB and has configurations
 for HSQL, MySQL and PostreSQL databases
Spring instantiates the objects and wires them
 together when the ZUL page "asks for" a
 spring bean due to XML databindings
Leverages SpringMVC scopes and ZKSpring for
 elegant care free coding
The MVVM Screen....
… is all databindings!


                            Your
 ClickMe!   1               Java
                       2
ZK Web           ZK
Desktop         Bind
            4          3
Saved!                 this.msg="Saved!"
Model-View-ViewModel

 View == Web Desktop
       Binder

      <<reflection>>
                        Legend
     ViewModel         compiles to

                       command

   DomainModel            load
The ViewModel Class
[show code] org.zkforge.zktodo2.ZkToDoViewModel
Holds the List<Reminder> the user is working with
Holds the selectedItem Reminder the user is
 currently editing
Uses the ReminderService which updates the
 database
Has the add(), save(), delete() methods
Can be shared by different views
The view is active; "@bind" has AJAX updates write to
  the selectedItem Reminder
Data Bindings

Page load calls getReminders on toDoViewModel
 and renders each date in a list:
<window apply="org.zkoss.bind.BindComposer"
  viewModel="@id('vm') @init(toDoViewModel2)">
<listbox model="@load(vm.reminders)"
   selectedItem="@bind(vm.selectedReminder)">
<template name="model" var="reminder">
<listitem>
   <listcell label="@load(reminder.date)"/>
</listitem></template</listbox></window>
Data Bindings 2
When the user selects a different reminder in the
 list let the user edit it in the edit panel:
Date:<datebox
 value="@bind(vm.selectedReminder.date)" />
The vm.selectedReminder is refered to in
 multiple places. It is written to by the onSelect
 Event of the Listbox:
<listbox model="@load(vm.reminders)"
   selectedItem="@bind(vm.selectedReminder)">
ZKBind keeps track what it changes and reloads
 UI with changed state
Command Bindings
New in ZK6!
<button label="Save" onClick="@command('save')"/>

There is zero code to read/write data between
 screen and the JPA entites: binder is updating
 them over AJAX
save() only calls save(selectedReminder) or
  delete(selectedReminder)
The binder is a generic UI Controller
ZK Bind updates UI + Model + Entities
You just write very testable Java!
Less Boiler Plate Code
Java methods which change state have hints as
  to what to reload into the screen:
@Command
@NotifyChange({"reminders","selectedReminder"})
public void delete() { .... }

Annotations on the Reminder entity setters and
 on the ViewModel CRUD methods
Desktop "zul" is bound onto the ViewModel
Could make "admin screen" & "read-only
 screen" for the same ViewModel (else "touch
 screen" & "mouse screen")
Spring Bean XML Definitions...
ViewModel bean has "desktop" scope
   <bean id="toDoViewModel2"
     class="org.zkforge.zktodo2.ZkToDoViewModel"
     p:reminderService-ref="reminderService" scope="desktop" />
So only one bean per web desktop (you may have many
 desktops per http session)
... has singleton reminder service:
   <bean id="reminderService"
     class="org.zkforge.zktodo2.ReminderService"
p:basicDao-ref="basicDao" />
… has singleton basicDao:
   <bean id="basicDao" class="org.zkforge.zktodo2.BasicDao"/
     >
… Stable Since 2007

Same BasicDao for other patterns demo screens
These days you don't need the Spring XML.
 Spring has alternative way to specificy how to
 wire up the beans (with Java annotations)
CDI would not be hard at all (see zkcdi library)
Back-end code is "orthodox" allowing us to
 focus on the code and what's new; ZK Patterns
… and deploying onto different Clouds!
ZK Cloud "Bake Off"
Two leading cloud providers chosen scientifically
 and at random (google+beer)




Each backed by a major software company
 (Salesforce vs Redhat)
Are they opensource like ZK, do they run it well,
 and are they easy to use...?
What Do You Get?
     Feature             Heroku               Openshift

     Deploy from         Yes. Git + Maven     Yes. Git + Maven
     source?[1]
     Database?           PostgreSQL           MySQL

     Container?          Jetty7.4             JBossAS7.0
                         (embedded)           (standalone)
     Proprietary         No problems for      No problems for
     Gotchas?[2]         the sample app       the sample app

[1] With Git you commit locally and "push" all the commits to one or
   more repos. One remote repo is the cloud; it compiles+deploys
[2] ”Can I move my production app at any time to my own servers?”
The Maven Build Profiles
Develop and debug on the jetty-maven-plugin ”mvn
 jetty:run” then deploy to JBoss, Weblogic,
 Websphere or Tomcat when it is ready to user test
When in JUnit or debugging (jetty:run) Spring is
 configured to setup the resources (datasource, jms)
To run in JBossAS7 Spring is configured to pull in the
  platform resources (jndi-datasource, jndi-jms)
Maven build profiles swap the Spring configuration based on
 a "-P" parameter using webapp "overlays"
Write once deploy to any cloud:
   mvn -P "openshift" package
   mvn -P "cloudX" package
Live Deploy Demo
This could be wishful thinking...!
[p.s. All went well, we committed a change to the
  screen locally and with a single command
  deployed to each of the two cloud services]
… And The Winner Is ...?




Both clouds are lightening fast for ZK AJAX!
Both have fully opensourced stacks!
Both are oh-so-easy-to-use
References

The code https://github.com/simbo1905/ZkToDo2
ZK6 MVVM introduction Hello ZK MVVM
MVC article Desktop MVC Patterns ZK, Spring & JPA
Original MVP article
 SmallTalks 2008 Best MVC Patterns
Book on how to build a layered domain model with
 Spring POJOs In Action
Martin Fowler GUI Patterns pages UI Architectures
Josh Smith's inspirational Microsoft .Net MVVM Article

Más contenido relacionado

La actualidad más candente

Windows Azure for .NET Developers
Windows Azure for .NET DevelopersWindows Azure for .NET Developers
Windows Azure for .NET Developersllangit
 
Java on Windows Azure
Java on Windows AzureJava on Windows Azure
Java on Windows AzureDavid Chou
 
Microsoft Database Options
Microsoft Database OptionsMicrosoft Database Options
Microsoft Database OptionsDavid Chou
 
Migrating Existing ASP.NET Web Applications to Microsoft Azure
Migrating Existing ASP.NET Web Applications to Microsoft AzureMigrating Existing ASP.NET Web Applications to Microsoft Azure
Migrating Existing ASP.NET Web Applications to Microsoft AzureIlyas F ☁☁☁
 
Architecting For The Windows Azure Platform
Architecting For The Windows Azure PlatformArchitecting For The Windows Azure Platform
Architecting For The Windows Azure PlatformDavid Chou
 
Azure - Data Platform
Azure - Data PlatformAzure - Data Platform
Azure - Data Platformgiventocode
 
Microsoft SQL Licensing Workshop - Software ONE
Microsoft SQL Licensing Workshop - Software ONEMicrosoft SQL Licensing Workshop - Software ONE
Microsoft SQL Licensing Workshop - Software ONEDigicomp Academy AG
 
Microsoft SQL Azure - Building Applications Using SQL Azure Presentation
Microsoft SQL Azure - Building Applications Using SQL Azure PresentationMicrosoft SQL Azure - Building Applications Using SQL Azure Presentation
Microsoft SQL Azure - Building Applications Using SQL Azure PresentationMicrosoft Private Cloud
 
Data Platform Overview
Data Platform OverviewData Platform Overview
Data Platform OverviewHamid J. Fard
 
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarGeek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarIDERA Software
 
Azure Data platform
Azure Data platformAzure Data platform
Azure Data platformMostafa
 
Creation of cloud application using microsoft azure by vaishali sahare [katkar]
Creation of cloud application using microsoft azure by vaishali sahare [katkar]Creation of cloud application using microsoft azure by vaishali sahare [katkar]
Creation of cloud application using microsoft azure by vaishali sahare [katkar]vaishalisahare123
 
Azure Cloud Dev Camp - Introduction
Azure Cloud Dev Camp - IntroductionAzure Cloud Dev Camp - Introduction
Azure Cloud Dev Camp - Introductiongiventocode
 
Understanding the Windows Azure Platform - Dec 2010
Understanding the Windows Azure Platform - Dec 2010Understanding the Windows Azure Platform - Dec 2010
Understanding the Windows Azure Platform - Dec 2010DavidGristwood
 
Leveraging azure and cello for delivering highly scalable multi tenant
Leveraging azure and cello for delivering highly scalable multi tenantLeveraging azure and cello for delivering highly scalable multi tenant
Leveraging azure and cello for delivering highly scalable multi tenantkanimozhin
 
Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978
Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978
Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978David Chou
 
ArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudMicrosoft ArcReady
 
Architecting Cloudy Applications
Architecting Cloudy ApplicationsArchitecting Cloudy Applications
Architecting Cloudy ApplicationsDavid Chou
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionArun Gupta
 

La actualidad más candente (20)

Windows Azure for .NET Developers
Windows Azure for .NET DevelopersWindows Azure for .NET Developers
Windows Azure for .NET Developers
 
Java on Windows Azure
Java on Windows AzureJava on Windows Azure
Java on Windows Azure
 
SQL Azure
SQL AzureSQL Azure
SQL Azure
 
Microsoft Database Options
Microsoft Database OptionsMicrosoft Database Options
Microsoft Database Options
 
Migrating Existing ASP.NET Web Applications to Microsoft Azure
Migrating Existing ASP.NET Web Applications to Microsoft AzureMigrating Existing ASP.NET Web Applications to Microsoft Azure
Migrating Existing ASP.NET Web Applications to Microsoft Azure
 
Architecting For The Windows Azure Platform
Architecting For The Windows Azure PlatformArchitecting For The Windows Azure Platform
Architecting For The Windows Azure Platform
 
Azure - Data Platform
Azure - Data PlatformAzure - Data Platform
Azure - Data Platform
 
Microsoft SQL Licensing Workshop - Software ONE
Microsoft SQL Licensing Workshop - Software ONEMicrosoft SQL Licensing Workshop - Software ONE
Microsoft SQL Licensing Workshop - Software ONE
 
Microsoft SQL Azure - Building Applications Using SQL Azure Presentation
Microsoft SQL Azure - Building Applications Using SQL Azure PresentationMicrosoft SQL Azure - Building Applications Using SQL Azure Presentation
Microsoft SQL Azure - Building Applications Using SQL Azure Presentation
 
Data Platform Overview
Data Platform OverviewData Platform Overview
Data Platform Overview
 
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarGeek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
 
Azure Data platform
Azure Data platformAzure Data platform
Azure Data platform
 
Creation of cloud application using microsoft azure by vaishali sahare [katkar]
Creation of cloud application using microsoft azure by vaishali sahare [katkar]Creation of cloud application using microsoft azure by vaishali sahare [katkar]
Creation of cloud application using microsoft azure by vaishali sahare [katkar]
 
Azure Cloud Dev Camp - Introduction
Azure Cloud Dev Camp - IntroductionAzure Cloud Dev Camp - Introduction
Azure Cloud Dev Camp - Introduction
 
Understanding the Windows Azure Platform - Dec 2010
Understanding the Windows Azure Platform - Dec 2010Understanding the Windows Azure Platform - Dec 2010
Understanding the Windows Azure Platform - Dec 2010
 
Leveraging azure and cello for delivering highly scalable multi tenant
Leveraging azure and cello for delivering highly scalable multi tenantLeveraging azure and cello for delivering highly scalable multi tenant
Leveraging azure and cello for delivering highly scalable multi tenant
 
Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978
Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978
Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978
 
ArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudArcReady - Architecting For The Cloud
ArcReady - Architecting For The Cloud
 
Architecting Cloudy Applications
Architecting Cloudy ApplicationsArchitecting Cloudy Applications
Architecting Cloudy Applications
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
 

Destacado

Tema 2 implementar el demo zk
Tema 2   implementar el demo zkTema 2   implementar el demo zk
Tema 2 implementar el demo zkGiovanni Flores
 
Design Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-BinderDesign Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-BinderSimon Massey
 
Tema 1 mi primera aplicacion zk con netbeans y rem
Tema 1   mi primera aplicacion zk con netbeans y remTema 1   mi primera aplicacion zk con netbeans y rem
Tema 1 mi primera aplicacion zk con netbeans y remGiovanni Flores
 
戦略テーマ設定シート
戦略テーマ設定シート戦略テーマ設定シート
戦略テーマ設定シートMaki Omori
 
Happily Ever After (Part 1)
Happily  Ever  After (Part 1)Happily  Ever  After (Part 1)
Happily Ever After (Part 1)Go4God
 
Single-chromosome transcriptional profiling reveals chromosomal gene expressi...
Single-chromosome transcriptional profiling reveals chromosomal gene expressi...Single-chromosome transcriptional profiling reveals chromosomal gene expressi...
Single-chromosome transcriptional profiling reveals chromosomal gene expressi...Marshall Levesque
 
Accelerating Innovation with Spark-(Beth Smith, IBM)
Accelerating Innovation with Spark-(Beth Smith, IBM)Accelerating Innovation with Spark-(Beth Smith, IBM)
Accelerating Innovation with Spark-(Beth Smith, IBM)Spark Summit
 
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...creativecrowdsourcingleaks
 
Revolutionizing Heathcare and Wellness Management through Systems P4 Medicine
Revolutionizing Heathcare and Wellness Management through Systems P4 MedicineRevolutionizing Heathcare and Wellness Management through Systems P4 Medicine
Revolutionizing Heathcare and Wellness Management through Systems P4 Medicinebrnbarcelona
 
Mobile AirPlan 1-pager
Mobile AirPlan 1-pagerMobile AirPlan 1-pager
Mobile AirPlan 1-pagerDMI
 
Personal branding project
Personal branding projectPersonal branding project
Personal branding projecttali92
 
Industrial Ecology KIGAM CSIRO
Industrial Ecology KIGAM CSIROIndustrial Ecology KIGAM CSIRO
Industrial Ecology KIGAM CSIRODario Aguilar
 
M C Squared - New Project Brochure
M C Squared - New Project BrochureM C Squared - New Project Brochure
M C Squared - New Project BrochureMCSquaredProject
 

Destacado (20)

Tema 2 implementar el demo zk
Tema 2   implementar el demo zkTema 2   implementar el demo zk
Tema 2 implementar el demo zk
 
Design Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-BinderDesign Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-Binder
 
Tema 1 mi primera aplicacion zk con netbeans y rem
Tema 1   mi primera aplicacion zk con netbeans y remTema 1   mi primera aplicacion zk con netbeans y rem
Tema 1 mi primera aplicacion zk con netbeans y rem
 
Giới thiệu zk framework
Giới thiệu  zk frameworkGiới thiệu  zk framework
Giới thiệu zk framework
 
ZK framework
ZK frameworkZK framework
ZK framework
 
Huong dan dung index_oracle
Huong dan dung index_oracleHuong dan dung index_oracle
Huong dan dung index_oracle
 
戦略テーマ設定シート
戦略テーマ設定シート戦略テーマ設定シート
戦略テーマ設定シート
 
Happily Ever After (Part 1)
Happily  Ever  After (Part 1)Happily  Ever  After (Part 1)
Happily Ever After (Part 1)
 
Single-chromosome transcriptional profiling reveals chromosomal gene expressi...
Single-chromosome transcriptional profiling reveals chromosomal gene expressi...Single-chromosome transcriptional profiling reveals chromosomal gene expressi...
Single-chromosome transcriptional profiling reveals chromosomal gene expressi...
 
Zaragoza Turismo 36
Zaragoza Turismo 36Zaragoza Turismo 36
Zaragoza Turismo 36
 
Accelerating Innovation with Spark-(Beth Smith, IBM)
Accelerating Innovation with Spark-(Beth Smith, IBM)Accelerating Innovation with Spark-(Beth Smith, IBM)
Accelerating Innovation with Spark-(Beth Smith, IBM)
 
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
 
Intervencion con Mis Padres...
Intervencion con Mis Padres...Intervencion con Mis Padres...
Intervencion con Mis Padres...
 
Zaragoza Turismo 35
Zaragoza Turismo 35Zaragoza Turismo 35
Zaragoza Turismo 35
 
Revolutionizing Heathcare and Wellness Management through Systems P4 Medicine
Revolutionizing Heathcare and Wellness Management through Systems P4 MedicineRevolutionizing Heathcare and Wellness Management through Systems P4 Medicine
Revolutionizing Heathcare and Wellness Management through Systems P4 Medicine
 
Mobile AirPlan 1-pager
Mobile AirPlan 1-pagerMobile AirPlan 1-pager
Mobile AirPlan 1-pager
 
Personal branding project
Personal branding projectPersonal branding project
Personal branding project
 
Industrial Ecology KIGAM CSIRO
Industrial Ecology KIGAM CSIROIndustrial Ecology KIGAM CSIRO
Industrial Ecology KIGAM CSIRO
 
M C Squared - New Project Brochure
M C Squared - New Project BrochureM C Squared - New Project Brochure
M C Squared - New Project Brochure
 
Zaragoza Turismo 26
Zaragoza Turismo 26Zaragoza Turismo 26
Zaragoza Turismo 26
 

Similar a ZK MVVM, Spring & JPA On Two PaaS Clouds

Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJSMeteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJSJulio Antonio Mendonça de Marins
 
WAD - WaveMaker tutorial
WAD - WaveMaker tutorial WAD - WaveMaker tutorial
WAD - WaveMaker tutorial marina2207
 
WaveMaker tutorial with Flash
WaveMaker tutorial with FlashWaveMaker tutorial with Flash
WaveMaker tutorial with Flashmarina2207
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)Daniel Bryant
 
Cloud computing - an insight into "how does it really work ?"
Cloud computing - an insight into "how does it really work ?" Cloud computing - an insight into "how does it really work ?"
Cloud computing - an insight into "how does it really work ?" Tikal Knowledge
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN StackRob Davarnia
 
D. Andreadis, Red Hat: Concepts and technical overview of Quarkus
D. Andreadis, Red Hat: Concepts and technical overview of QuarkusD. Andreadis, Red Hat: Concepts and technical overview of Quarkus
D. Andreadis, Red Hat: Concepts and technical overview of QuarkusUni Systems S.M.S.A.
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Arun Gupta
 
JavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureJavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureSasha Goldshtein
 
2013 05-multicloud-paas-interop-scenarios-fia-dublin
2013 05-multicloud-paas-interop-scenarios-fia-dublin2013 05-multicloud-paas-interop-scenarios-fia-dublin
2013 05-multicloud-paas-interop-scenarios-fia-dublinAlex Heneveld
 
Hidden pearls for High-Performance-Persistence
Hidden pearls for High-Performance-PersistenceHidden pearls for High-Performance-Persistence
Hidden pearls for High-Performance-PersistenceSven Ruppert
 
Dockerization of Azure Platform
Dockerization of Azure PlatformDockerization of Azure Platform
Dockerization of Azure Platformnirajrules
 
Cloud State of the Union for Java Developers
Cloud State of the Union for Java DevelopersCloud State of the Union for Java Developers
Cloud State of the Union for Java DevelopersBurr Sutter
 
Slide 1
Slide 1Slide 1
Slide 1butest
 

Similar a ZK MVVM, Spring & JPA On Two PaaS Clouds (20)

Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJSMeteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
 
WAD - WaveMaker tutorial
WAD - WaveMaker tutorial WAD - WaveMaker tutorial
WAD - WaveMaker tutorial
 
WaveMaker tutorial with Flash
WaveMaker tutorial with FlashWaveMaker tutorial with Flash
WaveMaker tutorial with Flash
 
Node js
Node jsNode js
Node js
 
WaveMaker Presentation
WaveMaker PresentationWaveMaker Presentation
WaveMaker Presentation
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
 
Cloud computing - an insight into "how does it really work ?"
Cloud computing - an insight into "how does it really work ?" Cloud computing - an insight into "how does it really work ?"
Cloud computing - an insight into "how does it really work ?"
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
D. Andreadis, Red Hat: Concepts and technical overview of Quarkus
D. Andreadis, Red Hat: Concepts and technical overview of QuarkusD. Andreadis, Red Hat: Concepts and technical overview of Quarkus
D. Andreadis, Red Hat: Concepts and technical overview of Quarkus
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010
 
JavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureJavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows Azure
 
2013 05-multicloud-paas-interop-scenarios-fia-dublin
2013 05-multicloud-paas-interop-scenarios-fia-dublin2013 05-multicloud-paas-interop-scenarios-fia-dublin
2013 05-multicloud-paas-interop-scenarios-fia-dublin
 
Hidden pearls for High-Performance-Persistence
Hidden pearls for High-Performance-PersistenceHidden pearls for High-Performance-Persistence
Hidden pearls for High-Performance-Persistence
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Dockerization of Azure Platform
Dockerization of Azure PlatformDockerization of Azure Platform
Dockerization of Azure Platform
 
Cloud State of the Union for Java Developers
Cloud State of the Union for Java DevelopersCloud State of the Union for Java Developers
Cloud State of the Union for Java Developers
 
Play framework
Play frameworkPlay framework
Play framework
 
Slide 1
Slide 1Slide 1
Slide 1
 
Cloudy Ajax 08 10
Cloudy Ajax 08 10Cloudy Ajax 08 10
Cloudy Ajax 08 10
 

Último

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Último (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

ZK MVVM, Spring & JPA On Two PaaS Clouds

  • 1. ZK, Spring & JPA On Two PaaS Clouds (Java MVVM Adventures Featuring Heroku & Openshift) Simon Massey
  • 2. Overview What is PaaS "Cloud" and why we should care? Background to the ZkToDo2 sample app Outline of the MVVM Pattern Walk through of MVVM sample page (new ZK6 features!) Quick pass of the Spring & JPA internals The key ingredient: maven build profiles Live push of source to two clouds! (Fingers crossed!)
  • 3. Clouds (In One Slide) Clouds come "as a service" (aaS) Software aaS Infrastructure aaS Platform aaS SaaS is your data on the cloud with leased software (they do everything) IaaS is leased managed hardware (they can do the network) PaaS is leased application/database capacity (they keep it running whilst you write the app)
  • 4. The PaaS Proposition Server virtualization is very mainstream. High density host servers reduce overheads Failover, off-site backup, standby servers, spare parts, upgrades, network is divided by number of virtual servers Rent a "virtual private server" (VPS) and you have to set it up and care for it yourself (logs filling up your disks?) How do you source 0.2 system adminstrators for your app? And if they change jobs? Outsource this to a PaaS provider!
  • 5. The PaaS Proposition (2) A big provider with a big server farm has automated deployment "elastic platform" Need more power? "Click here Sir to approve the monthy credit card payments..." Choice is a double edged sword; standardization is the key to maintaining a large estate of applications Big cloud farms run thousands of servers and are evolving best practice at a high rate Running your own servers is very last century; you can offload that work to the experts
  • 6. Is Your PaaS RIA Friendly? Not all PaaS clouds are AJAX friendly. Some assume that you are hosting a blog (i.e. stateless full page reload app) Not all PaaS clouds provide a relational database. ZK apps tend to be data orientated desktop-like apps which need an RDBMS J2EE is "complex" but PHP and Ruby are "simple"(??). Java sat outside the party whilst Ruby On Rails danced up a storm … but now the big Rails clouds are doing Java and are making it look very easy!
  • 7. Interlude Code https://github.com/simbo1905/ZkToDo2 Where is it running? Redhat Openshift zktd2-zkdemo.rhcloud.com Heruko glowing-light-1070.herokuapp.com (note: apps may suspend when idle so may take a long time to start on first hit) What IDE, DB, etc?
  • 8. The Code In Context The "ZK ToDo 2" sample app has the same screen implimented three times; using MVP, MVC and ZK6 MVVM (aka MVB) patterns Three ZK articles document the different patterns in the code MVP (2007), MVC (2009), MVVM (2011). MVVM article is out of date as sample code now does ZK6 "ZK Bind" MVVM Sample code has moved to the zktodo2 repo on GitHub with an Apache2 license The code now deploys to Heroku or Openshift PaaS clouds!
  • 9. About The Code The "ZkToDo2" sample app (aka zktd2) is a simple database CRUD app written with ZK, Spring and JPA Code uses a relational DB and has configurations for HSQL, MySQL and PostreSQL databases Spring instantiates the objects and wires them together when the ZUL page "asks for" a spring bean due to XML databindings Leverages SpringMVC scopes and ZKSpring for elegant care free coding
  • 11. … is all databindings! Your ClickMe! 1 Java 2 ZK Web ZK Desktop Bind 4 3 Saved! this.msg="Saved!"
  • 12. Model-View-ViewModel View == Web Desktop Binder <<reflection>> Legend ViewModel compiles to command DomainModel load
  • 13. The ViewModel Class [show code] org.zkforge.zktodo2.ZkToDoViewModel Holds the List<Reminder> the user is working with Holds the selectedItem Reminder the user is currently editing Uses the ReminderService which updates the database Has the add(), save(), delete() methods Can be shared by different views The view is active; "@bind" has AJAX updates write to the selectedItem Reminder
  • 14. Data Bindings Page load calls getReminders on toDoViewModel and renders each date in a list: <window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init(toDoViewModel2)"> <listbox model="@load(vm.reminders)" selectedItem="@bind(vm.selectedReminder)"> <template name="model" var="reminder"> <listitem> <listcell label="@load(reminder.date)"/> </listitem></template</listbox></window>
  • 15. Data Bindings 2 When the user selects a different reminder in the list let the user edit it in the edit panel: Date:<datebox value="@bind(vm.selectedReminder.date)" /> The vm.selectedReminder is refered to in multiple places. It is written to by the onSelect Event of the Listbox: <listbox model="@load(vm.reminders)" selectedItem="@bind(vm.selectedReminder)"> ZKBind keeps track what it changes and reloads UI with changed state
  • 16. Command Bindings New in ZK6! <button label="Save" onClick="@command('save')"/> There is zero code to read/write data between screen and the JPA entites: binder is updating them over AJAX save() only calls save(selectedReminder) or delete(selectedReminder) The binder is a generic UI Controller ZK Bind updates UI + Model + Entities You just write very testable Java!
  • 17. Less Boiler Plate Code Java methods which change state have hints as to what to reload into the screen: @Command @NotifyChange({"reminders","selectedReminder"}) public void delete() { .... } Annotations on the Reminder entity setters and on the ViewModel CRUD methods Desktop "zul" is bound onto the ViewModel Could make "admin screen" & "read-only screen" for the same ViewModel (else "touch screen" & "mouse screen")
  • 18. Spring Bean XML Definitions... ViewModel bean has "desktop" scope <bean id="toDoViewModel2" class="org.zkforge.zktodo2.ZkToDoViewModel" p:reminderService-ref="reminderService" scope="desktop" /> So only one bean per web desktop (you may have many desktops per http session) ... has singleton reminder service: <bean id="reminderService" class="org.zkforge.zktodo2.ReminderService" p:basicDao-ref="basicDao" /> … has singleton basicDao: <bean id="basicDao" class="org.zkforge.zktodo2.BasicDao"/ >
  • 19. … Stable Since 2007 Same BasicDao for other patterns demo screens These days you don't need the Spring XML. Spring has alternative way to specificy how to wire up the beans (with Java annotations) CDI would not be hard at all (see zkcdi library) Back-end code is "orthodox" allowing us to focus on the code and what's new; ZK Patterns … and deploying onto different Clouds!
  • 20. ZK Cloud "Bake Off" Two leading cloud providers chosen scientifically and at random (google+beer) Each backed by a major software company (Salesforce vs Redhat) Are they opensource like ZK, do they run it well, and are they easy to use...?
  • 21. What Do You Get? Feature Heroku Openshift Deploy from Yes. Git + Maven Yes. Git + Maven source?[1] Database? PostgreSQL MySQL Container? Jetty7.4 JBossAS7.0 (embedded) (standalone) Proprietary No problems for No problems for Gotchas?[2] the sample app the sample app [1] With Git you commit locally and "push" all the commits to one or more repos. One remote repo is the cloud; it compiles+deploys [2] ”Can I move my production app at any time to my own servers?”
  • 22. The Maven Build Profiles Develop and debug on the jetty-maven-plugin ”mvn jetty:run” then deploy to JBoss, Weblogic, Websphere or Tomcat when it is ready to user test When in JUnit or debugging (jetty:run) Spring is configured to setup the resources (datasource, jms) To run in JBossAS7 Spring is configured to pull in the platform resources (jndi-datasource, jndi-jms) Maven build profiles swap the Spring configuration based on a "-P" parameter using webapp "overlays" Write once deploy to any cloud: mvn -P "openshift" package mvn -P "cloudX" package
  • 23. Live Deploy Demo This could be wishful thinking...! [p.s. All went well, we committed a change to the screen locally and with a single command deployed to each of the two cloud services]
  • 24. … And The Winner Is ...? Both clouds are lightening fast for ZK AJAX! Both have fully opensourced stacks! Both are oh-so-easy-to-use
  • 25. References The code https://github.com/simbo1905/ZkToDo2 ZK6 MVVM introduction Hello ZK MVVM MVC article Desktop MVC Patterns ZK, Spring & JPA Original MVP article SmallTalks 2008 Best MVC Patterns Book on how to build a layered domain model with Spring POJOs In Action Martin Fowler GUI Patterns pages UI Architectures Josh Smith's inspirational Microsoft .Net MVVM Article