SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebSockets: Realtime Em Um Mundo Conectado 
Bruno Borges 
Principal Product Manager 
Oracle Latin America 
Agosto, 2014
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Speaker 
•Bruno Borges 
–Principal Product Manager, Java Evangelist 
–Oracle Latin America 
–@brunoborges 
–bruno.borges@oracle.com
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebSocket Overview
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebSocket Overview 
The WebSocket API in HTML5 
•Enables use of WebSocket in HTML5/web applications 
•Open/Close connections 
•Send/Receive messages 
•Fully asynchronous 
•Event driven, listen and respond to events
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebSocket Overview 
Browser Support for WebSocket API 
•Broad base of support for WebSocket in modern browsers 
•Firefox 28+, Chrome 33+, Safari 7+, IE 10+ 
•Including mobile browsers 
http://caniuse.com/#search=websocket
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebSocket Overview 
Common Use Cases 
•Time critical data delivery 
–Stocking monitoring, trading 
–Ticket reservation, seat selection 
•Applications that require true bi-directional exchanges with low latency 
–IoT control systems, gaming, gambling 
•High levels of interactivity 
–Chat systems, online sales engagement tools, support systems for trouble shooting 
•High throughput applications
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
The WebSocket Protocol (RFC 6455) 
Protocol Overview 
•Defines handshake and data transfer 
•Introduces new URI schemes 
–ws-URI = “ws:” “//” host [:port] path [ “?” query ] 
–wss-URI = “wss:” “//” host [:port] path [ “?” query ] 
–# MUST be escaped as %23 (URI fragments are meaningless) 
•Imposes an Origin Security Model 
•Supports extensibility 
–Tunnel other protocol by supporting sub-protocols, extend protocol features by supporting extensions
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
The WebSocket Protocol 
Opening Handshake 
WebLogic Server 12.1.3 
HTTP
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
The WebSocket Protocol 
Protocol Upgrade 
WebLogic Server 12.1.3 
WebSocket
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
The WebSocket Protocol 
Keep Alive: Ping and Pong 
Ping Frame 
Pong Frame 
Ping Frame 
Pong Frame 
WebLogic Server 12.1.3
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
The WebSocket Protocol 
Closing Handshake 
WebLogic Server 12.1.3 
Close Frame 
Data Frame 
Data Frame 
Data Frame 
Close Frame
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Developing WebSocket Applications using the Java Standard
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
The Java Standard for WebSocket Applications 
•Java community proposed and developed a specification and standard API for using WebSocket with the Java platform 
–Many companies and individuals represented 
–Oracle specification lead, developer of reference implementation with Project Tyrus 
•JSR-356 
–Specification finalized and approved May 2013 
–Included in Java EE 7 specification 
•Integrated into WebLogic Server 12.1.3
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Core Concepts 
Endpoint 
A websocket endpoint is a Java component that represents one side of a sequence of websocket interactions between two connected peers 
Connection 
A websocket connection is the networking connection between the two endpoints which are interacting using the websocket protocol 
Peer 
A websocket peer is used to represent the another participant of the websocket interactions with the endpoint 
Session 
A websocket session is used to represent a sequence of websocket interactions between an endpoint and a single peer 
Client Endpoints and Server Endpoints 
A client endpoint is an endpoint that initiates a connection to a peer but does not accept new ones 
A server endpoint is an endpoint that accepts websocket connections from peers but does not initiate connections to peers.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
•Creating a WebSocket requires a Java class that acts as an Endpoint 
–Participate in lifecycle: establish connections with peers, handle errors, close connections 
–Send and receive messages 
•Endpoints can be created from: 
–Annotation based approach using WebSocket Annotations, @ServerEndpoint 
–Programmatic API where Java class extends WebSocket API class 
•Endpoints can be defined as: 
–Clients which connect to one server only at a time 
–Servers which many clients can connect to at any time
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Annotated ServerEndpoint Example 
import javax.websocket.OnMessage; 
import javax.websocket.server.ServerEndpoint; 
@ServerEndpoint("/echo") 
public class EchoServer { 
@OnMessage 
public String echo(String incomingMessage) { 
return String.format( 
"I got this (%s) message so I am sending it back!”, incomingMessage); 
} 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Annotated ServerEndpoint Example 
@ServerEndpoint("/echo") 
public class EchoServer { 
@OnMessage 
public void onMessage(Session session, String message) { 
session.getOpenSessions() .forEach(s -> s.getBasicRemote().sendText(message)); 
} 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Annotated Path Parameter Example 
@ServerEndpoint("/users/{username}") 
public class UserEndpoint { 
@OnMessage 
public String handle(String message, @PathParam("username") String user) { 
return “message “ + message + “ from user “ + user; 
} 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Programmatic Endpoint Example 
public class ProgrammaticEchoServer extends Endpoint { 
@Override 
public void onOpen(final Session session, EndpointConfig endpointConfig) { 
mySession.addMessageHandler(new MessageHandler.Whole<String>() { 
public void onMessage(String text) { 
try { 
mySession.getBasicRemote() .sendText(“I got this (“ + text + “)” + “so I am sending it back !”); 
} catch (IOException ioe) { } 
} 
}); 
} 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Annotated ClientEndpoint Example 
import java.io.IOException; 
import javax.websocket.*; 
@ClientEndpoint 
public class HelloClient { 
@OnOpen 
public void init(Session session) { 
try { 
session.getBasicRemote().sendText("Hello you !"); 
} catch (IOException ioe) { 
// error 
} 
} 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Programmatic ClientEndpoint Example 
public class HelloClient extends Endpoint { 
@Override 
public void onOpen(Session session, EndpointConfig EndpointConfig) { 
try { 
session.getBasicRemote().sendText("Hello you !"); 
} catch (IOException e) { 
// error 
} 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Responding to Lifecycle Events 
Annotation 
Programmatic API 
Open Event 
@OnOpen 
public void onOpen(Session session, EndpointConfig config) 
Message Event 
@OnMessage 
•Create instance of relevant javax.websocket.MessageHandler 
•Register with Session 
Error Event 
@OnError 
public void onError(Session session, Throwable throwable) 
Close Event 
@OnClose 
public void onClose(Session session, CloseReason reason)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Receiving Message from Peers 
•Annotate a suitable method with @OnMessage 
•Implement an appropriate MessageHandler interface 
•Add it to the Session 
@OnMessage 
Void handleText(String message) 
@OnMessage 
public void handlePartialText( String message, boolean isLast) 
SimpleHandler implements MessageHandler.Whole<String> { ... } 
session.addMessageHandler( 
new SimpleHandler());
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Receiving Message from Peer with @OnMessage 
Message Type 
Annotated Method Form 
Text 
public void handleText(String message) 
public void handleReader(Reader r) 
public void handleTextPieces(String message, boolean isLast) 
Binary 
public void handleBinary(ByteBuffer bytebuf) 
public void handleStream(InputStream is) 
public void handleBinaryPieces(ByteBuffer bytebuf, boolean isLast) 
Any Object 
public void handleObject(CustomObject co)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Receiving Message Programmatically from Peers 
Message Type 
Message Handler Interface 
Text 
MessageHandler.Whole<String> 
MessageHandler.Whole<Reader> 
MessageHandler.Partial<String> 
Binary 
MessageHandler.Whole<ByteBuffer> 
MessageHandler.Partial<ByteBuffer> 
MessageHandler.Whole<InputStream> 
Any Object 
MessageHandler.Whole<CustomObject>
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Sending Messages to Peers 
Return a value from the @OnMessage method 
•Access the RemoteEndpoint interface from the Session object 
•Call the relevant send method 
@OnMessage public String echoToUppercase(String msg) { return msg.toUpperCase(); } 
RemoteEndpoint remote = session.getBasicRemote(); 
remote.sendText(“This is a txt message”);
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Asynchronous and Synchronous Sending Modes 
Mode 
Usage 
Interface and Method 
Synchronous 
•Most commonly use mode 
•Send methods block until transmission of message is complete 
RemoteEndpoint.Basic 
void sendText(String message) 
Asynchronous 
•Send methods return immediately before transmission 
•Future and Callback options for completion handling 
RemoteEndpoint.Async 
Future sendText(String message) 
void sendText(String message, SendHandler handler)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Example Encoder 
public class AuctionMessageEncoder implements Encoder.Text<AuctionMessage> { 
@Override 
public String encode(AuctionMessage object) throws EncodeException { 
JsonObject json = null; 
switch (object.getType()) { 
case AuctionMessage.AUCTION_TIME_RESPONSE: 
json = Json.createObjectBuilder() 
.add("type", object.getType()) 
.add("communicationId", object.getCommunicationId()) 
.add("data", (int) object.getData()).build(); 
break; 
} 
return json.toString(); 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Example Decoder 
public class AuctionMessageDecoder implements Decoder.Text<AuctionMessage> { 
@Override 
public AuctionMessage decode(String s) { 
JsonReader jsonReader = Json.createReader(new StringReader(s)); 
JsonObject json = jsonReader.readObject(); 
return new AuctionMessage(json.getString("type"), 
json.getString("communicationId"), json.getString("data")); 
} 
@Override 
public boolean willDecode(String s) { 
return s.contains(AuctionMessage.BID_REQUEST) 
|| s.contains(AuctionMessage.AUCTION_LIST_REQUEST) 
|| s.contains(AuctionMessage.LOGIN_REQUEST)); 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Configuring Encoders and Decoders 
•Annotation 
•Specify encoder and decoder values on @ServerEndpoint 
•Programmatic 
•Add encoder/decoder classes to ServerEndpointConfig object 
@ServerEndpoint( decoders = { AuctionMessageDecoder.class }, encoders = { AuctionMessageEncoder.class } 
) 
List<Encoder> encoders = new List<>(); 
encoders.add(AuctionMessageEncoder.class); 
encoders.add(AuctionMessageDecoder.class); 
ServerEndpointConfig config = ServerEndpointConfig.Builder 
.create(AuctionEndpoint.class, "/bids”) 
.encoders(encoders) 
.build();
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Securing WebSocket Applications
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Security 
•Based on the Servlet model 
–WebSocket Endpoints are considered resources via their uri 
•So one can 
–Require users be authenticated to access a WebSocket endpoint 
–Limit access to a WebSocket endpoint 
•to certain users, via role mapping 
•to an encrypted protocol (wss://)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.0 
Example secured configuration in web.xml 
<security-constraint> 
<web-resource-collection> 
<web-resource-name>Secure Customer WebSocket Endpoint</web-resource-name> 
<url-pattern>/customer/feed</url-pattern> 
<http-method>GET</http-method> 
</web-resource-collection> 
<auth-constraint> 
<role-name>CUSTOMERS</role-name> 
</auth-constraint> 
<user-data-constraint> 
<transport-guarantee>CONFIDENTIAL</transport-guarantee> 
</user-data-constraint> 
</security-constraint> 
<login-config> <auth-method>BASIC</auth-method> </login-config> <security-role> <role-name>CUSTOMERS</role-name> </security-role>
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Tyrus – Reference Implementation 
•Official Page 
–http://tyrus.java.net 
•User Guide (1.8) 
–https://tyrus.java.net/documentation/1.8/user-guide.html 
•Used by 
–GlassFish 4.0+ 
–WebLogic 12c (12.1.3+)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Java EE 7 WebSocket API in WebLogic 12.1.3
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebLogic Server 12.1.3 Mobile, Developer Productivity 
WLS 12.1.3 
Clients 
HTML5 clients 
ADF Mobile 
Proxies 
OTD 
Apache 
OHS 
Web Sockets (JSR 356) 
TopLink Data Services 
Server-Sent Events 
JAX-RS 2.0 
WebSocket Emulation 
WebSocket Emulation 
JAX-RS 2.0, WebSocket 1.0 JSON Programming API JPA 2.1 
Server-Sent Events 
WebSocket Emulation 
JPA-RS 
JPA 
Change Notification 
Database 
JSON Programming API 
HTTP/S, JSON/XML 
WebSocket, Server-Sent Events, Long polling 
Java EE 7 
APIs 
Additional WebLogic Value-Add 
Oracle Confidential – Internal/Restricted/Highly Restricted 
37
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebSocket Protocol Fallback 
Enabling WebSocket Use Across All Environments
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Happy HTML5 WebSockets 
●HTML5 and the Java API for WebSocket 
●Enables lots of new opportunities for developing highly interactive applications and rich user experiences 
•Lightweight, fast, easy to program 
•Standardizing across the industry 
●But ... 
●WebSockets are not universally supported across all current environments 
●Most browsers support HTML5 and WebSockets - but - not all of them 
●Firewalls or proxy servers may block the required frames and protocol
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebSocket Fallback 
•Provides a behind-the-scenes fallback mechanism to emulate the WebSocket transport behavior 
•Server side with an adapter to handle HTTP Long Polling for WebSocket messages when required 
•Client side with JavaScript library - orasocket.js 
●Developers 
●Use the Java API for WebSocket to developer your application, enable fallback via web.xml context-param 
●Use the HTML5 JavaScript WebSocket API on the client, Include OraSocket.js on client pages 
●Same codebase for native WebSocket Protocol and fallback 
●Transparent runtime behavior
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Configure Web Applications for WebSockets Fallback Support 
•Import orasocket.js in HTML 
•Modify web.xml 
<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.0"> 
<context-param> 
<description>Enable fallback mechanism</description> 
<param-name>com.oracle.tyrus.fallback.enabled</param-name> 
<param-value>true</param-value> 
</context-param> 
</web-app>
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WebSocket Connections with Fallback 
Composed 
Framed 
Sent 
// JS Client ws = new WebSocket(“ws://” + uri); ws.onmessage = function (evt) { … }; ws.open = function(evt) { ... } ws.onerror = function (evt) { ... } 
Dispatcher 
<html> 
<head> 
<link rel="stylesheet" href="css/ style.css" type="text/css"/> 
<script type="text/javascript” src="js/orasocket.js"></script> 
<script type="text/javascript” src="js/app_code.js"> 
... 
</html> 
WebSocket 
HTTP Long Poll 
Other ... 
Received 
De-framed 
Read 
Dispatcher 
@ServerEndpoint(value = "/customer/{id}") 
public class SuperSocketDemo { 
@OnOpen 
public void hello(Session remote) { ... } 
@OnMessage 
public void handleMessage( String message, @PathParam(“id") String userName, Session session) { ... } 
@OnClose 
public void bye(Session remote) { ... } 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR 356 WebSockets API 1.1 
Maintenance Release
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
MessageHandler with Lambda Expression 
•MessageHandler 
–Interface with one method only: onMessage(T message) 
–Should work as Lambda expression, right? 
•Session.addMessageHandler(MessageHandler) 
–Doesn’t work with Lambda Expressions because the required Generic type in MessageHandler can’t be extracted, for mapping reasons 
•New methods added to javax.websocket.Session 
–public <T> void addMessageHandler(Class<T> clazz, MessageHandler.Whole<T> handler); 
–public <T> void addMessageHandler(Class<T> clazz, MessageHandler.Partial<T> handler); 
•GlassFish 4.1 includes the fix 
WEBSOCKET_SPEC-226
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.1 
Programmatic Endpoint Example 
public class ProgrammaticEchoServer extends Endpoint { 
public void onOpen(final Session session) { 
session.addMessageHandler(new MessageHandler.Whole<String>() { 
public void onMessage(String text) { 
session.getBasicRemote() .sendText(“Got this: “ + text); 
}}); 
} 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
JSR-356: Java API for WebSocket 1.1 
Programmatic Endpoint Example 
public class ProgrammaticEchoServer extends Endpoint { 
public void onOpen(final Session session) { 
session.addMessageHandler( String.class, msg -> session.getBasicRemote() .sendText(“Got this: “ + msg)); 
} 
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Weitere ähnliche Inhalte

Was ist angesagt?

How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesHow to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesPavel Bucek
 
WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015Pavel Bucek
 
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 JavaFXBruno Borges
 
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 CloudBruno Borges
 
Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015Edward Burns
 
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and More
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and MorePolyglot! A Lightweight Cloud Platform for Java SE, Node, and More
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and MoreShaun Smith
 
JavaOne 2014 BOF4241 What's Next for JSF?
JavaOne 2014 BOF4241 What's Next for JSF?JavaOne 2014 BOF4241 What's Next for JSF?
JavaOne 2014 BOF4241 What's Next for JSF?Edward Burns
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the CloudShaun Smith
 
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 YouEdward Burns
 
Oracle Cloud에서 애플리케이션을 개발하고 테스트하는 손쉬운 방법
Oracle Cloud에서 애플리케이션을 개발하고 테스트하는 손쉬운 방법Oracle Cloud에서 애플리케이션을 개발하고 테스트하는 손쉬운 방법
Oracle Cloud에서 애플리케이션을 개발하고 테스트하는 손쉬운 방법Mee Nam Lee
 
Oracle Fusion Middleware provisioning with Puppet
Oracle Fusion Middleware provisioning with PuppetOracle Fusion Middleware provisioning with Puppet
Oracle Fusion Middleware provisioning with PuppetEdwin Biemond
 
Web protocols for java developers
Web protocols for java developersWeb protocols for java developers
Web protocols for java developersPavel Bucek
 
Oracle REST Data Services
Oracle REST Data ServicesOracle REST Data Services
Oracle REST Data ServicesChris Muir
 
Provisioning with Oracle Cloud Stack Manager
Provisioning with Oracle Cloud Stack ManagerProvisioning with Oracle Cloud Stack Manager
Provisioning with Oracle Cloud Stack ManagerSimon Haslam
 
Down-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEDown-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEReza Rahman
 
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5Shaun Smith
 

Was ist angesagt? (20)

How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesHow to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based Microservices
 
WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015
 
JavaCro'15 - Managing Java at Scale Security and Compatibility Applications -...
JavaCro'15 - Managing Java at Scale Security and Compatibility Applications -...JavaCro'15 - Managing Java at Scale Security and Compatibility Applications -...
JavaCro'15 - Managing Java at Scale Security and Compatibility Applications -...
 
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
 
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
 
Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015
 
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and More
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and MorePolyglot! A Lightweight Cloud Platform for Java SE, Node, and More
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and More
 
JavaOne 2014 BOF4241 What's Next for JSF?
JavaOne 2014 BOF4241 What's Next for JSF?JavaOne 2014 BOF4241 What's Next for JSF?
JavaOne 2014 BOF4241 What's Next for JSF?
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the Cloud
 
JavaCro'15 - Oracle Java Cloud Service Java PaaS - Duško Vukmanović
JavaCro'15 - Oracle Java Cloud Service  Java PaaS - Duško VukmanovićJavaCro'15 - Oracle Java Cloud Service  Java PaaS - Duško Vukmanović
JavaCro'15 - Oracle Java Cloud Service Java PaaS - Duško Vukmanović
 
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
 
Oracle Cloud에서 애플리케이션을 개발하고 테스트하는 손쉬운 방법
Oracle Cloud에서 애플리케이션을 개발하고 테스트하는 손쉬운 방법Oracle Cloud에서 애플리케이션을 개발하고 테스트하는 손쉬운 방법
Oracle Cloud에서 애플리케이션을 개발하고 테스트하는 손쉬운 방법
 
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
 
Oracle Fusion Middleware provisioning with Puppet
Oracle Fusion Middleware provisioning with PuppetOracle Fusion Middleware provisioning with Puppet
Oracle Fusion Middleware provisioning with Puppet
 
MVC 1.0 / JSR 371
MVC 1.0 / JSR 371MVC 1.0 / JSR 371
MVC 1.0 / JSR 371
 
Web protocols for java developers
Web protocols for java developersWeb protocols for java developers
Web protocols for java developers
 
Oracle REST Data Services
Oracle REST Data ServicesOracle REST Data Services
Oracle REST Data Services
 
Provisioning with Oracle Cloud Stack Manager
Provisioning with Oracle Cloud Stack ManagerProvisioning with Oracle Cloud Stack Manager
Provisioning with Oracle Cloud Stack Manager
 
Down-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEDown-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EE
 
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
 

Ähnlich wie WebSockets - Realtime em Mundo Conectado

What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)Pavel Bucek
 
Getting Started with WebSocket and Server-Sent Events in Java
Getting Started with WebSocket and Server-Sent Events in JavaGetting Started with WebSocket and Server-Sent Events in Java
Getting Started with WebSocket and Server-Sent Events in JavaArun Gupta
 
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 GuptaCodemotion
 
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 jaxconf
 
Kick Start your Application Development and Management Strategy
Kick Start your Application Development and Management Strategy Kick Start your Application Development and Management Strategy
Kick Start your Application Development and Management Strategy WSO2
 
Getting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsGetting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsArun 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...
Getting Started with WebSocket and Server-Sent Events using Java - Arun Gupta...jaxLondonConference
 
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected BusinessWSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected BusinessWSO2
 
Building+restful+webservice
Building+restful+webserviceBuilding+restful+webservice
Building+restful+webservicelonegunman
 
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
 
Oracle Coherence Strategy and Roadmap (OpenWorld, September 2014)
Oracle Coherence Strategy and Roadmap (OpenWorld, September 2014)Oracle Coherence Strategy and Roadmap (OpenWorld, September 2014)
Oracle Coherence Strategy and Roadmap (OpenWorld, September 2014)jeckels
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 
Http Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesHttp Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesbharathiv53
 
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 DelabasseeJAXLondon2014
 
V2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocketV2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocketbrent bucci
 

Ähnlich wie WebSockets - Realtime em Mundo Conectado (20)

What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)
 
Getting Started with WebSocket and Server-Sent Events in Java
Getting Started with WebSocket and Server-Sent Events in JavaGetting Started with WebSocket and Server-Sent Events in Java
Getting Started with WebSocket and Server-Sent Events in Java
 
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
 
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
 
JAX-RS.next
JAX-RS.nextJAX-RS.next
JAX-RS.next
 
Kick Start your Application Development and Management Strategy
Kick Start your Application Development and Management Strategy Kick Start your Application Development and Management Strategy
Kick Start your Application Development and Management Strategy
 
Getting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsGetting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent Events
 
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...
 
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected BusinessWSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
 
WSO2 AppDev platform
WSO2 AppDev platformWSO2 AppDev platform
WSO2 AppDev platform
 
Building+restful+webservice
Building+restful+webserviceBuilding+restful+webservice
Building+restful+webservice
 
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)
 
Oracle Coherence Strategy and Roadmap (OpenWorld, September 2014)
Oracle Coherence Strategy and Roadmap (OpenWorld, September 2014)Oracle Coherence Strategy and Roadmap (OpenWorld, September 2014)
Oracle Coherence Strategy and Roadmap (OpenWorld, September 2014)
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
Http Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesHttp Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responses
 
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
 
Think async
Think asyncThink async
Think async
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
V2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocketV2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocket
 
Servlets
ServletsServlets
Servlets
 

Mehr von Bruno Borges

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 KubernetesBruno Borges
 
[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 KubernetesBruno Borges
 
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 AppsBruno Borges
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless ComputingBruno Borges
 
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 DevelopersBruno Borges
 
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 CloudBruno Borges
 
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...Bruno Borges
 
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 NuvemBruno 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 NuvemBruno Borges
 
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?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
 
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]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
 
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]Bruno Borges
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the CloudBruno 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 JavaFXBruno Borges
 
The Developers Conference 2014 - Oracle Keynote
The Developers Conference 2014 - Oracle KeynoteThe Developers Conference 2014 - Oracle Keynote
The Developers Conference 2014 - Oracle KeynoteBruno Borges
 
Crie Aplicações Mobile Híbridas Escritas em Java, para iOS e Android
Crie Aplicações Mobile Híbridas Escritas em Java, para iOS e AndroidCrie Aplicações Mobile Híbridas Escritas em Java, para iOS e Android
Crie Aplicações Mobile Híbridas Escritas em Java, para iOS e AndroidBruno Borges
 
Migrando de Applets para JavaFX, e Modelos de Distribuição de Apps
Migrando de Applets para JavaFX, e Modelos de Distribuição de AppsMigrando de Applets para JavaFX, e Modelos de Distribuição de Apps
Migrando de Applets para JavaFX, e Modelos de Distribuição de AppsBruno Borges
 

Mehr von 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
 
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
 
The Developers Conference 2014 - Oracle Keynote
The Developers Conference 2014 - Oracle KeynoteThe Developers Conference 2014 - Oracle Keynote
The Developers Conference 2014 - Oracle Keynote
 
Crie Aplicações Mobile Híbridas Escritas em Java, para iOS e Android
Crie Aplicações Mobile Híbridas Escritas em Java, para iOS e AndroidCrie Aplicações Mobile Híbridas Escritas em Java, para iOS e Android
Crie Aplicações Mobile Híbridas Escritas em Java, para iOS e Android
 
Migrando de Applets para JavaFX, e Modelos de Distribuição de Apps
Migrando de Applets para JavaFX, e Modelos de Distribuição de AppsMigrando de Applets para JavaFX, e Modelos de Distribuição de Apps
Migrando de Applets para JavaFX, e Modelos de Distribuição de Apps
 

Kürzlich hochgeladen

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Kürzlich hochgeladen (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

WebSockets - Realtime em Mundo Conectado

  • 1. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebSockets: Realtime Em Um Mundo Conectado Bruno Borges Principal Product Manager Oracle Latin America Agosto, 2014
  • 2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Speaker •Bruno Borges –Principal Product Manager, Java Evangelist –Oracle Latin America –@brunoborges –bruno.borges@oracle.com
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebSocket Overview
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebSocket Overview The WebSocket API in HTML5 •Enables use of WebSocket in HTML5/web applications •Open/Close connections •Send/Receive messages •Fully asynchronous •Event driven, listen and respond to events
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebSocket Overview Browser Support for WebSocket API •Broad base of support for WebSocket in modern browsers •Firefox 28+, Chrome 33+, Safari 7+, IE 10+ •Including mobile browsers http://caniuse.com/#search=websocket
  • 6. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebSocket Overview Common Use Cases •Time critical data delivery –Stocking monitoring, trading –Ticket reservation, seat selection •Applications that require true bi-directional exchanges with low latency –IoT control systems, gaming, gambling •High levels of interactivity –Chat systems, online sales engagement tools, support systems for trouble shooting •High throughput applications
  • 7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The WebSocket Protocol (RFC 6455) Protocol Overview •Defines handshake and data transfer •Introduces new URI schemes –ws-URI = “ws:” “//” host [:port] path [ “?” query ] –wss-URI = “wss:” “//” host [:port] path [ “?” query ] –# MUST be escaped as %23 (URI fragments are meaningless) •Imposes an Origin Security Model •Supports extensibility –Tunnel other protocol by supporting sub-protocols, extend protocol features by supporting extensions
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The WebSocket Protocol Opening Handshake WebLogic Server 12.1.3 HTTP
  • 9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The WebSocket Protocol Protocol Upgrade WebLogic Server 12.1.3 WebSocket
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The WebSocket Protocol Keep Alive: Ping and Pong Ping Frame Pong Frame Ping Frame Pong Frame WebLogic Server 12.1.3
  • 11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The WebSocket Protocol Closing Handshake WebLogic Server 12.1.3 Close Frame Data Frame Data Frame Data Frame Close Frame
  • 12. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Developing WebSocket Applications using the Java Standard
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 The Java Standard for WebSocket Applications •Java community proposed and developed a specification and standard API for using WebSocket with the Java platform –Many companies and individuals represented –Oracle specification lead, developer of reference implementation with Project Tyrus •JSR-356 –Specification finalized and approved May 2013 –Included in Java EE 7 specification •Integrated into WebLogic Server 12.1.3
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Core Concepts Endpoint A websocket endpoint is a Java component that represents one side of a sequence of websocket interactions between two connected peers Connection A websocket connection is the networking connection between the two endpoints which are interacting using the websocket protocol Peer A websocket peer is used to represent the another participant of the websocket interactions with the endpoint Session A websocket session is used to represent a sequence of websocket interactions between an endpoint and a single peer Client Endpoints and Server Endpoints A client endpoint is an endpoint that initiates a connection to a peer but does not accept new ones A server endpoint is an endpoint that accepts websocket connections from peers but does not initiate connections to peers.
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 •Creating a WebSocket requires a Java class that acts as an Endpoint –Participate in lifecycle: establish connections with peers, handle errors, close connections –Send and receive messages •Endpoints can be created from: –Annotation based approach using WebSocket Annotations, @ServerEndpoint –Programmatic API where Java class extends WebSocket API class •Endpoints can be defined as: –Clients which connect to one server only at a time –Servers which many clients can connect to at any time
  • 16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Annotated ServerEndpoint Example import javax.websocket.OnMessage; import javax.websocket.server.ServerEndpoint; @ServerEndpoint("/echo") public class EchoServer { @OnMessage public String echo(String incomingMessage) { return String.format( "I got this (%s) message so I am sending it back!”, incomingMessage); } }
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Annotated ServerEndpoint Example @ServerEndpoint("/echo") public class EchoServer { @OnMessage public void onMessage(Session session, String message) { session.getOpenSessions() .forEach(s -> s.getBasicRemote().sendText(message)); } }
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Annotated Path Parameter Example @ServerEndpoint("/users/{username}") public class UserEndpoint { @OnMessage public String handle(String message, @PathParam("username") String user) { return “message “ + message + “ from user “ + user; } }
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Programmatic Endpoint Example public class ProgrammaticEchoServer extends Endpoint { @Override public void onOpen(final Session session, EndpointConfig endpointConfig) { mySession.addMessageHandler(new MessageHandler.Whole<String>() { public void onMessage(String text) { try { mySession.getBasicRemote() .sendText(“I got this (“ + text + “)” + “so I am sending it back !”); } catch (IOException ioe) { } } }); } }
  • 20. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Annotated ClientEndpoint Example import java.io.IOException; import javax.websocket.*; @ClientEndpoint public class HelloClient { @OnOpen public void init(Session session) { try { session.getBasicRemote().sendText("Hello you !"); } catch (IOException ioe) { // error } } }
  • 21. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Programmatic ClientEndpoint Example public class HelloClient extends Endpoint { @Override public void onOpen(Session session, EndpointConfig EndpointConfig) { try { session.getBasicRemote().sendText("Hello you !"); } catch (IOException e) { // error } }
  • 22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Responding to Lifecycle Events Annotation Programmatic API Open Event @OnOpen public void onOpen(Session session, EndpointConfig config) Message Event @OnMessage •Create instance of relevant javax.websocket.MessageHandler •Register with Session Error Event @OnError public void onError(Session session, Throwable throwable) Close Event @OnClose public void onClose(Session session, CloseReason reason)
  • 23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Receiving Message from Peers •Annotate a suitable method with @OnMessage •Implement an appropriate MessageHandler interface •Add it to the Session @OnMessage Void handleText(String message) @OnMessage public void handlePartialText( String message, boolean isLast) SimpleHandler implements MessageHandler.Whole<String> { ... } session.addMessageHandler( new SimpleHandler());
  • 24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Receiving Message from Peer with @OnMessage Message Type Annotated Method Form Text public void handleText(String message) public void handleReader(Reader r) public void handleTextPieces(String message, boolean isLast) Binary public void handleBinary(ByteBuffer bytebuf) public void handleStream(InputStream is) public void handleBinaryPieces(ByteBuffer bytebuf, boolean isLast) Any Object public void handleObject(CustomObject co)
  • 25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Receiving Message Programmatically from Peers Message Type Message Handler Interface Text MessageHandler.Whole<String> MessageHandler.Whole<Reader> MessageHandler.Partial<String> Binary MessageHandler.Whole<ByteBuffer> MessageHandler.Partial<ByteBuffer> MessageHandler.Whole<InputStream> Any Object MessageHandler.Whole<CustomObject>
  • 26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Sending Messages to Peers Return a value from the @OnMessage method •Access the RemoteEndpoint interface from the Session object •Call the relevant send method @OnMessage public String echoToUppercase(String msg) { return msg.toUpperCase(); } RemoteEndpoint remote = session.getBasicRemote(); remote.sendText(“This is a txt message”);
  • 27. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Asynchronous and Synchronous Sending Modes Mode Usage Interface and Method Synchronous •Most commonly use mode •Send methods block until transmission of message is complete RemoteEndpoint.Basic void sendText(String message) Asynchronous •Send methods return immediately before transmission •Future and Callback options for completion handling RemoteEndpoint.Async Future sendText(String message) void sendText(String message, SendHandler handler)
  • 28. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Example Encoder public class AuctionMessageEncoder implements Encoder.Text<AuctionMessage> { @Override public String encode(AuctionMessage object) throws EncodeException { JsonObject json = null; switch (object.getType()) { case AuctionMessage.AUCTION_TIME_RESPONSE: json = Json.createObjectBuilder() .add("type", object.getType()) .add("communicationId", object.getCommunicationId()) .add("data", (int) object.getData()).build(); break; } return json.toString(); }
  • 29. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Example Decoder public class AuctionMessageDecoder implements Decoder.Text<AuctionMessage> { @Override public AuctionMessage decode(String s) { JsonReader jsonReader = Json.createReader(new StringReader(s)); JsonObject json = jsonReader.readObject(); return new AuctionMessage(json.getString("type"), json.getString("communicationId"), json.getString("data")); } @Override public boolean willDecode(String s) { return s.contains(AuctionMessage.BID_REQUEST) || s.contains(AuctionMessage.AUCTION_LIST_REQUEST) || s.contains(AuctionMessage.LOGIN_REQUEST)); }
  • 30. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Configuring Encoders and Decoders •Annotation •Specify encoder and decoder values on @ServerEndpoint •Programmatic •Add encoder/decoder classes to ServerEndpointConfig object @ServerEndpoint( decoders = { AuctionMessageDecoder.class }, encoders = { AuctionMessageEncoder.class } ) List<Encoder> encoders = new List<>(); encoders.add(AuctionMessageEncoder.class); encoders.add(AuctionMessageDecoder.class); ServerEndpointConfig config = ServerEndpointConfig.Builder .create(AuctionEndpoint.class, "/bids”) .encoders(encoders) .build();
  • 31. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Securing WebSocket Applications
  • 32. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Security •Based on the Servlet model –WebSocket Endpoints are considered resources via their uri •So one can –Require users be authenticated to access a WebSocket endpoint –Limit access to a WebSocket endpoint •to certain users, via role mapping •to an encrypted protocol (wss://)
  • 33. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.0 Example secured configuration in web.xml <security-constraint> <web-resource-collection> <web-resource-name>Secure Customer WebSocket Endpoint</web-resource-name> <url-pattern>/customer/feed</url-pattern> <http-method>GET</http-method> </web-resource-collection> <auth-constraint> <role-name>CUSTOMERS</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> </login-config> <security-role> <role-name>CUSTOMERS</role-name> </security-role>
  • 34. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Tyrus – Reference Implementation •Official Page –http://tyrus.java.net •User Guide (1.8) –https://tyrus.java.net/documentation/1.8/user-guide.html •Used by –GlassFish 4.0+ –WebLogic 12c (12.1.3+)
  • 35. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Java EE 7 WebSocket API in WebLogic 12.1.3
  • 36. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebLogic Server 12.1.3 Mobile, Developer Productivity WLS 12.1.3 Clients HTML5 clients ADF Mobile Proxies OTD Apache OHS Web Sockets (JSR 356) TopLink Data Services Server-Sent Events JAX-RS 2.0 WebSocket Emulation WebSocket Emulation JAX-RS 2.0, WebSocket 1.0 JSON Programming API JPA 2.1 Server-Sent Events WebSocket Emulation JPA-RS JPA Change Notification Database JSON Programming API HTTP/S, JSON/XML WebSocket, Server-Sent Events, Long polling Java EE 7 APIs Additional WebLogic Value-Add Oracle Confidential – Internal/Restricted/Highly Restricted 37
  • 37. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebSocket Protocol Fallback Enabling WebSocket Use Across All Environments
  • 38. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Happy HTML5 WebSockets ●HTML5 and the Java API for WebSocket ●Enables lots of new opportunities for developing highly interactive applications and rich user experiences •Lightweight, fast, easy to program •Standardizing across the industry ●But ... ●WebSockets are not universally supported across all current environments ●Most browsers support HTML5 and WebSockets - but - not all of them ●Firewalls or proxy servers may block the required frames and protocol
  • 39. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebSocket Fallback •Provides a behind-the-scenes fallback mechanism to emulate the WebSocket transport behavior •Server side with an adapter to handle HTTP Long Polling for WebSocket messages when required •Client side with JavaScript library - orasocket.js ●Developers ●Use the Java API for WebSocket to developer your application, enable fallback via web.xml context-param ●Use the HTML5 JavaScript WebSocket API on the client, Include OraSocket.js on client pages ●Same codebase for native WebSocket Protocol and fallback ●Transparent runtime behavior
  • 40. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Configure Web Applications for WebSockets Fallback Support •Import orasocket.js in HTML •Modify web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0"> <context-param> <description>Enable fallback mechanism</description> <param-name>com.oracle.tyrus.fallback.enabled</param-name> <param-value>true</param-value> </context-param> </web-app>
  • 41. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WebSocket Connections with Fallback Composed Framed Sent // JS Client ws = new WebSocket(“ws://” + uri); ws.onmessage = function (evt) { … }; ws.open = function(evt) { ... } ws.onerror = function (evt) { ... } Dispatcher <html> <head> <link rel="stylesheet" href="css/ style.css" type="text/css"/> <script type="text/javascript” src="js/orasocket.js"></script> <script type="text/javascript” src="js/app_code.js"> ... </html> WebSocket HTTP Long Poll Other ... Received De-framed Read Dispatcher @ServerEndpoint(value = "/customer/{id}") public class SuperSocketDemo { @OnOpen public void hello(Session remote) { ... } @OnMessage public void handleMessage( String message, @PathParam(“id") String userName, Session session) { ... } @OnClose public void bye(Session remote) { ... } }
  • 42. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR 356 WebSockets API 1.1 Maintenance Release
  • 43. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MessageHandler with Lambda Expression •MessageHandler –Interface with one method only: onMessage(T message) –Should work as Lambda expression, right? •Session.addMessageHandler(MessageHandler) –Doesn’t work with Lambda Expressions because the required Generic type in MessageHandler can’t be extracted, for mapping reasons •New methods added to javax.websocket.Session –public <T> void addMessageHandler(Class<T> clazz, MessageHandler.Whole<T> handler); –public <T> void addMessageHandler(Class<T> clazz, MessageHandler.Partial<T> handler); •GlassFish 4.1 includes the fix WEBSOCKET_SPEC-226
  • 44. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.1 Programmatic Endpoint Example public class ProgrammaticEchoServer extends Endpoint { public void onOpen(final Session session) { session.addMessageHandler(new MessageHandler.Whole<String>() { public void onMessage(String text) { session.getBasicRemote() .sendText(“Got this: “ + text); }}); } }
  • 45. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | JSR-356: Java API for WebSocket 1.1 Programmatic Endpoint Example public class ProgrammaticEchoServer extends Endpoint { public void onOpen(final Session session) { session.addMessageHandler( String.class, msg -> session.getBasicRemote() .sendText(“Got this: “ + msg)); } }
  • 46. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |