SlideShare uma empresa Scribd logo
1 de 23
Criando uma aplicação
HTML5 com Java EE 7 e
WebSockets
Bruno Borges
Principal Product Manager
Java Evangelist
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3
• Java Evangelist
• Orale Product Manager
• Entusiasta JavaFX e IoT
• Onde me encontrar
• @brunoborges
• plus.google.com/+BrunoBorges
Bruno Borges
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4
Ascenção do Javascript
• O debate cliente ‘leve’ vs cliente ‘pesado’ é antigo...
• Frameworks web server-side mandaram por um tempo (Struts, Spring
MVC, JSF)
• Ajax foi uma mudança suave para o client-side (GWT, Vaadin)
• Rich clients estão voltando voltaram, graças ao Javascript/HTML5
• Motores Javascript melhoraram muito (V8, SpiderMonkey, Nashorn)
• Melhores ferramentas (jQuery, MV* frameworks, Chrome, Firefox, JavaFX)
• Melhores padrões (CSS3, HTML5, WebSockets, Web Components)
Clientes ricos HTML5
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5
Arquitetura Rich Client
• Similar a arquiteturas cliente/servidor
• Cliente responsável pela UI, input, validacao, lógica e estado
• Server responsável pela lógica de negócio, modelo de domínio, persistência
• Web/HTTP é a cola que conecta client e server
• Protocolos de comunicacao comuns
• REST na maioria dos casos
• WebSocket quando precisa de comunicacao full-duplex
• Ferramentas Javascript suportam REST muito bem, mas ainda não WebSocket
• O formato comum (talvez ideal?) de troca de dados é JSON
• Java EE é uma ótima plataforma server-side para esta arquitetura
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.6
Java EE + Javascript
Plataforma server-side para suportar apps ricas HTML5/Javascript
Servlet
EJB 3 CDI
BeanValidation
JavaScript/HTML5
JAX-RS WebSockets JSON-P JAXB
JPA JMS JTA JCA
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7
JAX-RS
• API de desenvolvimento REST para Java
• Servidor e Client
• Orientada a Annotations, declarativa
• @Path, @GET, @POST, @PUT, @DELETE, @PathParam, @QueryPara
m, @Produces, @Consumes
• Plugável e extensível
• Providers, filters, interceptors
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8
JAX-RS
@Path("/atm/{cardId}")
public class AtmService {
@GET
@Path("/balance")
@Produces("text/plain")
public String balance(
@PathParam("cardId") String card,
@QueryParam("pin") String pin) {
return Double.toString(getBalance(card, pin));
}
Exemplo 1
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9
JAX-RS
@POST
@Path("/withdrawal")
@Consumes("text/plain")
@Produces("application/json")
public Money withdraw(
@PathParam("card") String card,
@QueryParam("pin") String pin,
String amount) {
return getMoney(card, pin, amount);
}
}
Exemplo 2
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.10
Java API for WebSockets
JSR 356
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.11
Java API for WebSockets
• Protocolo HTTP é half-duplex
• Gambiarras
• Polling
• Long polling
• Streaming
• WebSocket resolve o problema de uma vez por todas
• Full-duplex
JSR 356
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.12
Java API for WebSockets
• API declarativa de alto nivel para WebSockets
• Client e server-side
• Pequena e simples, mas completa
• @ServerEndpoint, @OnOpen, @OnClose, @OnMessage, @OnError, Ses
sion, Remote
• Plugável e extensível
• Encoders, decoders, sub-protocols
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.13
Java API for WebSockets
@ServerEndpoint("/chat")
public class ChatBean {
Set<Session> peers = Collections.synchronizedSet(…);
@OnOpen
public void onOpen(Session peer) {
peers.add(peer);
}
@OnClose
public void onClose(Session peer) {
peers.remove(peer);
}
Exemplo 1
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14
Java API for WebSockets
@OnMessage
public void message(String message, Session client) {
peers.forEach(
p -> p.getRemote().sendObject(message)
);
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15
Javascript Movers and Shakers
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16
Projeto Avatar
• Javascript framework da Oracle
• Javascript no client e no server-side
• Nashorn/JDK8
• Utiliza algumas capacidades do Java EE
• Roda no GlassFish, e em breve no WebLogic também
• Suporte já integrado para REST, WebSocket, Server-Sent Events
(SSE)
• Suporte a PhoneGap
• Versão 1.0 já disponível. Bom momento para participar!
avatar.java.net
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17
Projetos no NetBeans
• Twitter Bootstrap
• HTML5 Boilerplate
• Initializr
• AngularJS
• Mobile Boilerplate
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18
Demo
•github.com/brunoborges/javaee-javascript
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19
Conclusão
• Cientes JavaScript/HTML5 conquistando desenvolvedores
• Comunicacao entre cliente e servidor em JSON via REST ou WebSocket
• Java EE funciona muito bem como um backend para clientes ricos
Javascript, especialmente com JAX-RS e a Java API para WebSockets, e
JSON-P
• JavaScript framework da Oracle – Projeto Avatar
• Você opde usar o código de demonstracão para comecar a explorar estas
idéias
• E o mais importante, divirta-se programando! :-)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20
• glassfish.org
• Java EE 7
• Suporte a JDK 8
• Projeto Avatar
GlassFish Nightly Builds
GlassFish 4.0.1
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21
Para saber mais
• Java EE Tutorials
• http://docs.oracle.com/javaee/7/tutorial/doc/home.htm
• Outras páginas para iniciar os estudos
• http://docs.oracle.com/javaee/7/firstcup/doc/home.htm
• https://glassfish.java.net/hol/
• https://java.net/projects/cargotracker/
• Java EE 7 Transparent Expert Groups
• http://javaee-spec.java.net
• The Aquarium (blog Java EE da Oracle)
• http://blogs.oracle.com/theaquarium
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23
The preceding is intended to outline our general product direction. It is intended
for information purposes only, and may not be incorporated into any contract.
It is not a commitment to deliver any material, code, or functionality, and should
not be relied upon in making purchasing decisions. The
development, release, and timing of any features or functionality described for
Oracle’s products remains at the sole discretion of Oracle.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25

Mais conteúdo relacionado

Mais procurados

Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur! Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
David Delabassee
 

Mais procurados (17)

Java EE 7 overview
Java EE 7 overviewJava EE 7 overview
Java EE 7 overview
 
Java EE 7 - Overview and Status
Java EE 7  - Overview and StatusJava EE 7  - Overview and Status
Java EE 7 - Overview and Status
 
What's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and BeyondWhat's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and Beyond
 
CON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To YouCON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To You
 
Websocket 1.0
Websocket 1.0Websocket 1.0
Websocket 1.0
 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
 
Java Summit Chennai: JAX-RS 2.0
Java Summit Chennai: JAX-RS 2.0Java Summit Chennai: JAX-RS 2.0
Java Summit Chennai: JAX-RS 2.0
 
Finally, EE Security API JSR 375
Finally, EE Security API JSR 375Finally, EE Security API JSR 375
Finally, EE Security API JSR 375
 
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
 
'JMS @ Data Grid? Hacking the Glassfish messaging for fun & profit'
'JMS @ Data Grid? Hacking the Glassfish messaging for fun & profit' 'JMS @ Data Grid? Hacking the Glassfish messaging for fun & profit'
'JMS @ Data Grid? Hacking the Glassfish messaging for fun & profit'
 
Java EE 7 and HTML5: Developing for the Cloud
Java EE 7 and HTML5: Developing for the CloudJava EE 7 and HTML5: Developing for the Cloud
Java EE 7 and HTML5: Developing for the Cloud
 
Java EE 8: On the Horizon
Java EE 8:  On the HorizonJava EE 8:  On the Horizon
Java EE 8: On the Horizon
 
'New JMS features in GlassFish 4.0' by Nigel Deakin
'New JMS features in GlassFish 4.0' by Nigel Deakin'New JMS features in GlassFish 4.0' by Nigel Deakin
'New JMS features in GlassFish 4.0' by Nigel Deakin
 
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur! Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
 
Building Java Desktop Apps with JavaFX 8 and Java EE 7
Building Java Desktop Apps with JavaFX 8 and Java EE 7Building Java Desktop Apps with JavaFX 8 and Java EE 7
Building Java Desktop Apps with JavaFX 8 and Java EE 7
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0
 
JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?
 

Semelhante a Construindo aplicações com HTML5, WebSockets, e Java EE 7

Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
David Delabassee
 
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014
David Delabassee
 
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
Project Avatar (Lyon JUG & Alpes JUG  - March 2014)Project Avatar (Lyon JUG & Alpes JUG  - March 2014)
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
David Delabassee
 

Semelhante a Construindo aplicações com HTML5, WebSockets, e Java EE 7 (20)

Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
 
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014
 
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
Project Avatar (Lyon JUG & Alpes JUG  - March 2014)Project Avatar (Lyon JUG & Alpes JUG  - March 2014)
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
 
Avatar 2.0
Avatar 2.0Avatar 2.0
Avatar 2.0
 
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouHTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
 
RESTful Services and Distributed OSGi - 04/2009
RESTful Services and Distributed OSGi - 04/2009RESTful Services and Distributed OSGi - 04/2009
RESTful Services and Distributed OSGi - 04/2009
 
Server Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David DelabasseeServer Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David Delabassee
 
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
 
WebSocket Perspectives and Vision for the Future
WebSocket Perspectives and Vision for the FutureWebSocket Perspectives and Vision for the Future
WebSocket Perspectives and Vision for the Future
 
Getting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
Getting Started with WebSocket and Server-Sent Events using Java by Arun GuptaGetting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
Getting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
 
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
 
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
 
Java API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and updateJava API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and update
 
Imworld.ro
Imworld.roImworld.ro
Imworld.ro
 
10 Building Blocks for Enterprise JavaScript
10 Building Blocks for Enterprise JavaScript10 Building Blocks for Enterprise JavaScript
10 Building Blocks for Enterprise JavaScript
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_davidd
 
Session at Oredev 2016.
Session at Oredev 2016.Session at Oredev 2016.
Session at Oredev 2016.
 
JavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great MatchJavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great Match
 
Varun-CV-J
Varun-CV-JVarun-CV-J
Varun-CV-J
 
Slovenian Oracle User Group
Slovenian Oracle User GroupSlovenian Oracle User Group
Slovenian Oracle User Group
 

Mais de Bruno Borges

Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Bruno Borges
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Bruno Borges
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Bruno Borges
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Bruno Borges
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Bruno Borges
 

Mais de Bruno Borges (20)

Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless Computing
 
Visual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersVisual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring Developers
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure Cloud
 
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na Nuvem
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The Cloud
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFX
 
Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
 
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
 
Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the Cloud
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
 
Integrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsIntegrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSockets
 

Último

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
giselly40
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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...
 
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...
 

Construindo aplicações com HTML5, WebSockets, e Java EE 7

  • 1. Criando uma aplicação HTML5 com Java EE 7 e WebSockets Bruno Borges Principal Product Manager Java Evangelist
  • 2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3 • Java Evangelist • Orale Product Manager • Entusiasta JavaFX e IoT • Onde me encontrar • @brunoborges • plus.google.com/+BrunoBorges Bruno Borges
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4 Ascenção do Javascript • O debate cliente ‘leve’ vs cliente ‘pesado’ é antigo... • Frameworks web server-side mandaram por um tempo (Struts, Spring MVC, JSF) • Ajax foi uma mudança suave para o client-side (GWT, Vaadin) • Rich clients estão voltando voltaram, graças ao Javascript/HTML5 • Motores Javascript melhoraram muito (V8, SpiderMonkey, Nashorn) • Melhores ferramentas (jQuery, MV* frameworks, Chrome, Firefox, JavaFX) • Melhores padrões (CSS3, HTML5, WebSockets, Web Components) Clientes ricos HTML5
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5 Arquitetura Rich Client • Similar a arquiteturas cliente/servidor • Cliente responsável pela UI, input, validacao, lógica e estado • Server responsável pela lógica de negócio, modelo de domínio, persistência • Web/HTTP é a cola que conecta client e server • Protocolos de comunicacao comuns • REST na maioria dos casos • WebSocket quando precisa de comunicacao full-duplex • Ferramentas Javascript suportam REST muito bem, mas ainda não WebSocket • O formato comum (talvez ideal?) de troca de dados é JSON • Java EE é uma ótima plataforma server-side para esta arquitetura
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.6 Java EE + Javascript Plataforma server-side para suportar apps ricas HTML5/Javascript Servlet EJB 3 CDI BeanValidation JavaScript/HTML5 JAX-RS WebSockets JSON-P JAXB JPA JMS JTA JCA
  • 6. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7 JAX-RS • API de desenvolvimento REST para Java • Servidor e Client • Orientada a Annotations, declarativa • @Path, @GET, @POST, @PUT, @DELETE, @PathParam, @QueryPara m, @Produces, @Consumes • Plugável e extensível • Providers, filters, interceptors
  • 7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8 JAX-RS @Path("/atm/{cardId}") public class AtmService { @GET @Path("/balance") @Produces("text/plain") public String balance( @PathParam("cardId") String card, @QueryParam("pin") String pin) { return Double.toString(getBalance(card, pin)); } Exemplo 1
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9 JAX-RS @POST @Path("/withdrawal") @Consumes("text/plain") @Produces("application/json") public Money withdraw( @PathParam("card") String card, @QueryParam("pin") String pin, String amount) { return getMoney(card, pin, amount); } } Exemplo 2
  • 9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.10 Java API for WebSockets JSR 356
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.11 Java API for WebSockets • Protocolo HTTP é half-duplex • Gambiarras • Polling • Long polling • Streaming • WebSocket resolve o problema de uma vez por todas • Full-duplex JSR 356
  • 11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.12 Java API for WebSockets • API declarativa de alto nivel para WebSockets • Client e server-side • Pequena e simples, mas completa • @ServerEndpoint, @OnOpen, @OnClose, @OnMessage, @OnError, Ses sion, Remote • Plugável e extensível • Encoders, decoders, sub-protocols
  • 12. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.13 Java API for WebSockets @ServerEndpoint("/chat") public class ChatBean { Set<Session> peers = Collections.synchronizedSet(…); @OnOpen public void onOpen(Session peer) { peers.add(peer); } @OnClose public void onClose(Session peer) { peers.remove(peer); } Exemplo 1
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14 Java API for WebSockets @OnMessage public void message(String message, Session client) { peers.forEach( p -> p.getRemote().sendObject(message) ); }
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15 Javascript Movers and Shakers
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16 Projeto Avatar • Javascript framework da Oracle • Javascript no client e no server-side • Nashorn/JDK8 • Utiliza algumas capacidades do Java EE • Roda no GlassFish, e em breve no WebLogic também • Suporte já integrado para REST, WebSocket, Server-Sent Events (SSE) • Suporte a PhoneGap • Versão 1.0 já disponível. Bom momento para participar! avatar.java.net
  • 16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17 Projetos no NetBeans • Twitter Bootstrap • HTML5 Boilerplate • Initializr • AngularJS • Mobile Boilerplate
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18 Demo •github.com/brunoborges/javaee-javascript
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19 Conclusão • Cientes JavaScript/HTML5 conquistando desenvolvedores • Comunicacao entre cliente e servidor em JSON via REST ou WebSocket • Java EE funciona muito bem como um backend para clientes ricos Javascript, especialmente com JAX-RS e a Java API para WebSockets, e JSON-P • JavaScript framework da Oracle – Projeto Avatar • Você opde usar o código de demonstracão para comecar a explorar estas idéias • E o mais importante, divirta-se programando! :-)
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20 • glassfish.org • Java EE 7 • Suporte a JDK 8 • Projeto Avatar GlassFish Nightly Builds GlassFish 4.0.1
  • 20. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21 Para saber mais • Java EE Tutorials • http://docs.oracle.com/javaee/7/tutorial/doc/home.htm • Outras páginas para iniciar os estudos • http://docs.oracle.com/javaee/7/firstcup/doc/home.htm • https://glassfish.java.net/hol/ • https://java.net/projects/cargotracker/ • Java EE 7 Transparent Expert Groups • http://javaee-spec.java.net • The Aquarium (blog Java EE da Oracle) • http://blogs.oracle.com/theaquarium
  • 21. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23 The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24
  • 23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25

Notas do Editor

  1. Richer clients clearly better at some thingsHighly dynamic, interactive interfacesComplex, feature-rich UIs“Single page applications” (“Applets” )But perhaps not a panaceaHeavily form/workflow driven applicationsServer-side rendering still a better bet for performance/reliability?JavaScript/HTML development is not without it’s pains…Server-side frameworks are a strong incumbentCo-existence in the short and long term?Islands of rich client functionality within server-centric UIs?Different strokes for different folks?