hybrid webinar

51
Hybrid Apps @artursignell VP of R&D @joonaslehtinen Founder & CEO

Upload: joonas-lehtinen

Post on 10-May-2015

609 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Hybrid webinar

HybridApps@artursignell VP of R&D

@joonaslehtinen Founder & CEO

Page 2: Hybrid webinar

WarningJust an idea - not a proven best practice

Page 3: Hybrid webinar

Hybrid?

Page 4: Hybrid webinar

Web application layers

Backend server

Web server

Commu- nication

JavaScript

Page 5: Hybrid webinar

Web application layers

Backend server

Web server

Commu- nication

JavaScript

Client-side UI

Page 6: Hybrid webinar

Web application layers

Backend server

Web server

Commu- nication

JavaScript

Server-side UI Automated

Page 7: Hybrid webinar

Web application layers

JavaScriptJava to

JavaScriptWeb

serverBackend

serverCommu- nication

requiredrequiredJS required required

Page 8: Hybrid webinar

Web application layers

JavaScriptJava to

JavaScriptWeb

serverBackend

serverCommu- nication

required optionalrequired

GW

T

requiredrequiredJS

requiredrequired

required required

Client-side UI

Page 9: Hybrid webinar

Web application layers

JavaScriptJava to

JavaScriptWeb

serverBackend

server

required optional optionalrequired

Commu- nication

optional

Vaadin

required optionalrequired

GW

T

requiredrequiredJS

requiredrequired

required required

Client-side UIServer-side UI &

Page 10: Hybrid webinar

Web application layers

JavaScriptJava to

JavaScriptWeb

serverBackend

server

required optional optionalrequired

Commu- nication

optional

Vaadin

required optionalrequired

GW

T

requiredrequiredJS

requiredrequired

required required

1 layer vs

3 layers

-50% dev. time -50% maintenance vs full control over DOM and communications

Page 11: Hybrid webinar

Server-

Client-

side

Optim

ized fo

r

Prod

uctivity

Optim

ized for

Con

trol

Page 12: Hybrid webinar

HybridArchitecture

Page 13: Hybrid webinar
Page 14: Hybrid webinar
Page 15: Hybrid webinar
Page 16: Hybrid webinar
Page 17: Hybrid webinar
Page 18: Hybrid webinar
Page 19: Hybrid webinar
Page 20: Hybrid webinar

Server-sideClient-side

Use for

• Offline!• Low latency interaction!• Maximum scalability

Use for

• Most places ( - 50% cost )!• High security!• Utilizing full Java platform

Benefits of the both sides, but adds complexity

Hybrid

Page 21: Hybrid webinar
Page 22: Hybrid webinar

http://demo.vaadin.com/parking/

Page 23: Hybrid webinar

HOW?

Page 24: Hybrid webinar

Google

http://domain.com

Web Page Title

First nameTable cell

Table cell

Phone number

Table cell

Table cell

Table cellTable cellTable cell

Table cell

Table cellTable cell

Table cellTable cell

Table cell

Table cell Table cell

Table cell

Last name

Table cellTable cell

Email address

Table cellTable cell

Far far away, behind the word mountains,

far from the countries Vokalia and

Consonantia, there live the blind texts.

Separated they live in Bookmarksgrove

right at the coast of the Semantics, a

large language ocean.

A small river named Duden flows by their

place and supplies it with the necessary

regelialia. It is a paradisematic country, in

which roasted parts of sentences fly into

your mouth.

Even the all-powerful Pointing has no

control about the blind texts it is an

almost unorthographic life One day

however a small line of blind text by the

name of Lorem Ipsum decided to leave

for the far World of Grammar. The Big

Oxmox advised her not to do so,

because there were thousands of bad

Commas.

Server-side

OfflineClient-side Vaadin-RPC

Client-side GWT-RPCServer-side

Edit Delete New

Save Cancel

First name Last name

Phone number Email address

Page 25: Hybrid webinar

https://github.com/jojule/hybrid

Page 26: Hybrid webinar

AddressbookBackend

Address Impl

Page 27: Hybrid webinar

AddressbookBackendAddress ImplBackendFrontend

Server-side!(with Vaadin)

Client-side!(with GWT-RPC)

AddressbookEditor

Page 28: Hybrid webinar

AddressbookBackendAddress ImplBackendFrontend

Server-side!(with Vaadin)

Client-side!(with GWT-RPC)

AddressbookEditor

AddressbookEditor

View

Connector

Client

Server

create

place

Page 29: Hybrid webinar

AddressbookBackendAddress ImplBackendFrontend

Server-side!(with Vaadin)

Client-side!(with GWT-RPC)

AddressbookEditor

AddressbookEditor

RPCServlet ServiceView

Connector

Client

Server

create

place

implements

Page 30: Hybrid webinar

AddressbookBackendAddress ImplBackendFrontend

Server-side!(with Vaadin)

Client-side!(with GWT-RPC)

AddressbookEditor

AddressbookEditor

RPCServlet Service

ServiceAsync

View

Connector

Client

Server

Proxy(generated)

create

place

implements

implements

equal

Page 31: Hybrid webinar

Estimating Complexity

Page 32: Hybrid webinar

Server-sideClient-side

1 class !

190 LOC

4 classes 2 interfaces ~ 500 LOC 3X

Page 33: Hybrid webinar

Vaadin RPC State

Page 34: Hybrid webinar

server

client

Component

Widget

Connector

RPC

State

Demo

Page 35: Hybrid webinar

public interface ButtonRpc extends ServerRpc { public void click(MouseEventDetails details); }

private ButtonRpc rpc = RpcProxy.create(ButtonRpc.class, this); !public void onClick(ClickEvent event) { rpc.click( new MouseEventDetails(event)); }

serverclient

private ButtonRpc rpc = new ButtonRpc() { public void click( MouseEventDetails details) { // do stuff } }; !public Button() { registerRpc(rpc); }

Demo

Page 36: Hybrid webinar

AddressbookBackendAddress ImplBackendFrontend

Client-side!(with Conntector)

Client-side!(with GWT-RPC)

AddressbookEditor

RPCServlet Service

ServiceAsync

View

Client

Serverplace

implements

equal

View

place & !serve

AddressbookEditor

StateServer!RPC

Client!RPC

Connector Proxy(generated)

createimplementsConnector

create

Page 37: Hybrid webinar

PUSH

Page 38: Hybrid webinar

Offline

Page 39: Hybrid webinar

<html manifest="hybrid.appcache">

!

!

<inherits name="com.vaadin.Vaadin" /> <entry-point class="example.client.OfflineEntry"/> !

!

rootPanel.add(new AddressbookEditor());

Offline BootstrapCACHE MANIFEST!!CACHE:!offline.html!VAADIN/vaadinBootstrap.js!VAADIN/themes/hybrid/favicon.ico!VAADIN/themes/hybrid/styles.css!VAADIN/widgetsets/or…t.nocache.js!VAADIN/widgetsets/or…ear.cache.gif!!NETWORK:!*

widgetset

ApplicationConfiguration.onModuleLoad()

Page 40: Hybrid webinar

Offline Detection

Offline Mode !/offline.html

Online Mode !/

window.navigator.onLine

redirect

Page 41: Hybrid webinar

com.google.gwt.storage.client.Storage

!

queueOperation("{\"op\": \"delete\", \"id\": " + id + "}"); Storage.getSessionStorageIfSupported() .setItem(KEY, pendingCommandsJSON)

!

purgeQueue() serverRpc.deleteAddress(id);

Local Storage & Synchronization

When offline

Back online

Page 42: Hybrid webinar

AddressbookBackendAddress ImplBackendFrontend

Offline!(with Conntector)

Client

Server

View

place & !serve

AddressbookEditor

StateServer!RPC

Client!RPC

create OfflineDetector

DataStore

offline.html

Connector !!

localStorage

cache manifest

Page 43: Hybrid webinar

at least 2Xclient-side

> 5Xserver-side

• Client-side UI needed as a basis

• Offline detection

• Offline bootstrap

• Local storage database

• 2-way data synchronization (app specific)

• Modification logs

• Sharding logic

Estimating Complexity

Page 44: Hybrid webinar

Use Offline only when really

really needed

Page 45: Hybrid webinar

State today

Page 46: Hybrid webinar

WarningJust an idea - not a proven best practice

Page 47: Hybrid webinar

GWT += Server-Side !

GWT += Push !

Server-Side += Offline !

Optimize Server-Side

?

Page 48: Hybrid webinar

Client-side Widget API !

Tutorials !

Unified Themeing !

Offline Detection !

Manifest generation

!

Page 49: Hybrid webinar

https://github.com/jojule/hybrid

Page 50: Hybrid webinar

VaadinTouchKit

Page 51: Hybrid webinar

? @vaadin @artursignell

@joonaslehtinen