Your SlideShare is downloading. ×
0
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Websocket,JSON in JEE7
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Websocket,JSON in JEE7

1,498

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,498
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Java API forWebSockets & JSONP in JEE7Prasanna Kumar S
  • 2. JSR 356 - Java API for Websocket● Creating WebSocket Java components to handle bi-directional WebSocket conversations● Initiating and intercepting WebSocket events● Creation and consumption of WebSocket text and binarymessages● The abililty to define WebSocket protocols and contentmodels for an applicationHeads up on JSRs
  • 3. Heads up on JSRs (Contd.)JSR 353 - JAva API for JSON processing● Produce and consume JSON text in a streaming fashion● Build a Java object model for JSON text using API classes● Binding of JSON text to Java objects and vice versa.
  • 4. Websocket - Server endpoint@ServerEndpoint(value = "/HomeWS",encoders = {DataEncoder.class},decoders = {DataDecoder.class})public class HomeWS {@OnOpenpublic void onOpen(Session peer) {}@OnClosepublic void onClose(Session peer) {}@OnMessagepublic void broadCastMessage(GameData figure, Session session) throwsIOException, EncodeException {}}WebSocket - Server Endpointclients callwith this URL
  • 5. Websocket - client endpoint@ClientEndpoint(decoders = {DataDecoder.class}, encoders = {DataEncoder.class})public class SignalChangeEndpointClient {@OnOpenpublic void onOpen(Session session) throws IOException, EncodeException {}}WebSocket - Client Endpointhas no url value
  • 6. public class DataDecoder implements Decoder.Text<GameData> {@Overridepublic GameData decode(String string) throws DecodeException {JsonObject jsonObject = Json.createReader(new StringReader(string)).readObject();return new GameData(jsonObject);}}public class DataEncoder implements Encoder.Text<GameData> {@Overridepublic String encode(GameData figure) throws EncodeException {return figure.getJson().toString();}}WebSocket - Message Carriers
  • 7. this code could be used with any java object to initiate a websocket message○ EJB○ Servlet○ JSF handlerWebSocket - Message SendingClient//...WebSocketContainer container = ContainerProvider.getWebSocketContainer();String uri = "ws://websocket.appserver.org/websocket"; // illustrative URLcontainer.connectToServer(SignalChangeEndpointClient.class, URI.create(uri));//...
  • 8. Artifactsfor the well grounded ....Tyrus - a RI of JSR 356http://tyrus.java.net/for the impatient ....GlassFish 4 (JEE7) - via Promoted buildshttp://download.java.net/glassfish/4.0/promoted/upcomingWildFlyhttp://www.wildfly.org/
  • 9. Questions?
  • 10. Thank you

×