SlideShare una empresa de Scribd logo
1 de 10
Descargar para leer sin conexión
Java API for
WebSockets & JSONP in JEE7
Prasanna Kumar S
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 binary
messages
● The abililty to define WebSocket protocols and content
models for an application
Heads up on JSR's
Heads up on JSR's (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.
Websocket - Server endpoint
@ServerEndpoint(value = "/HomeWS",
encoders = {DataEncoder.class},
decoders = {DataDecoder.class})
public class HomeWS {
@OnOpen
public void onOpen(Session peer) {}
@OnClose
public void onClose(Session peer) {}
@OnMessage
public void broadCastMessage(GameData figure, Session session) throws
IOException, EncodeException {
}
}
WebSocket - Server Endpoint
clients call
with this URL
Websocket - client endpoint
@ClientEndpoint(decoders = {DataDecoder.class}, encoders = {DataEncoder.class})
public class SignalChangeEndpointClient {
@OnOpen
public void onOpen(Session session) throws IOException, EncodeException {}
}
WebSocket - Client Endpoint
has no url value
public class DataDecoder implements Decoder.Text<GameData> {
@Override
public 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> {
@Override
public String encode(GameData figure) throws EncodeException {
return figure.getJson().toString();
}
}
WebSocket - Message Carriers
this code could be used with any java object to initiate a websocket message
○ EJB
○ Servlet
○ JSF handler
WebSocket - Message Sending
Client
//...
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://websocket.appserver.org/websocket"; // illustrative URL
container.connectToServer(SignalChangeEndpointClient.class, URI.create(uri));
//...
Artifacts
for the well grounded ....
Tyrus - a RI of JSR 356
http://tyrus.java.net/
for the impatient ....
GlassFish 4 (JEE7) - via Promoted builds
http://download.java.net/glassfish/4.0/promoted/
upcoming
WildFly
http://www.wildfly.org/
Questions
?
Thank you

Más contenido relacionado

Similar a Websocket,JSON in JEE7

What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0Bruno Borges
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyMohamed Taman
 
Java ee 7 New Features
Java ee 7   New FeaturesJava ee 7   New Features
Java ee 7 New FeaturesShahzad Badar
 
Jakarta EE and MicroProfile - EclipseCon 2020
Jakarta EE and MicroProfile - EclipseCon 2020Jakarta EE and MicroProfile - EclipseCon 2020
Jakarta EE and MicroProfile - EclipseCon 2020Josh Juneau
 
WebSocket JSON Hackday
WebSocket JSON HackdayWebSocket JSON Hackday
WebSocket JSON HackdaySomay Nakhal
 
Con fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhaktiCon fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhaktiBhakti Mehta
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013Alexandre Morgaut
 
Java EE 7, what's in it for me?
Java EE 7, what's in it for me?Java EE 7, what's in it for me?
Java EE 7, what's in it for me?Alex Soto
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RSFahad Golra
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
 
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
 
Ajax Frameworks in the J(2)EE Environment
Ajax Frameworks in the J(2)EE EnvironmentAjax Frameworks in the J(2)EE Environment
Ajax Frameworks in the J(2)EE Environmentstarchaser
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Hamed Hatami
 

Similar a Websocket,JSON in JEE7 (20)

What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new Strategy
 
Java ee 7 New Features
Java ee 7   New FeaturesJava ee 7   New Features
Java ee 7 New Features
 
Jakarta EE and MicroProfile - EclipseCon 2020
Jakarta EE and MicroProfile - EclipseCon 2020Jakarta EE and MicroProfile - EclipseCon 2020
Jakarta EE and MicroProfile - EclipseCon 2020
 
WebSocket JSON Hackday
WebSocket JSON HackdayWebSocket JSON Hackday
WebSocket JSON Hackday
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
Con fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhaktiCon fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhakti
 
netbeans
netbeansnetbeans
netbeans
 
netbeans
netbeansnetbeans
netbeans
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
 
Java EE 7, what's in it for me?
Java EE 7, what's in it for me?Java EE 7, what's in it for me?
Java EE 7, what's in it for me?
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Vishnu(java)
Vishnu(java)Vishnu(java)
Vishnu(java)
 
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
 
Ajax Frameworks in the J(2)EE Environment
Ajax Frameworks in the J(2)EE EnvironmentAjax Frameworks in the J(2)EE Environment
Ajax Frameworks in the J(2)EE Environment
 
Java EE 7 - Overview and Status
Java EE 7  - Overview and StatusJava EE 7  - Overview and Status
Java EE 7 - Overview and Status
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)
 

Más de PrasannaKumar Sathyanarayanan (10)

Akka introtalk HyScala DEC 2016
Akka introtalk HyScala DEC 2016Akka introtalk HyScala DEC 2016
Akka introtalk HyScala DEC 2016
 
Akka fsm presentation
Akka fsm presentationAkka fsm presentation
Akka fsm presentation
 
Cps (continuation passing style) in scala
Cps (continuation passing style) in scalaCps (continuation passing style) in scala
Cps (continuation passing style) in scala
 
Introduction to akka chense
Introduction to akka   chenseIntroduction to akka   chense
Introduction to akka chense
 
Finagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvmFinagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvm
 
Scala Introduction with play - for my CSS nerds
Scala Introduction with play - for my CSS nerdsScala Introduction with play - for my CSS nerds
Scala Introduction with play - for my CSS nerds
 
CDI in JEE6
CDI in JEE6CDI in JEE6
CDI in JEE6
 
Ejb3.1
Ejb3.1Ejb3.1
Ejb3.1
 
Producer consumerproblem
Producer consumerproblemProducer consumerproblem
Producer consumerproblem
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
 

Último

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 

Último (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 

Websocket,JSON in JEE7

  • 1. Java API for WebSockets & JSONP in JEE7 Prasanna 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 binary messages ● The abililty to define WebSocket protocols and content models for an application Heads up on JSR's
  • 3. Heads up on JSR's (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 { @OnOpen public void onOpen(Session peer) {} @OnClose public void onClose(Session peer) {} @OnMessage public void broadCastMessage(GameData figure, Session session) throws IOException, EncodeException { } } WebSocket - Server Endpoint clients call with this URL
  • 5. Websocket - client endpoint @ClientEndpoint(decoders = {DataDecoder.class}, encoders = {DataEncoder.class}) public class SignalChangeEndpointClient { @OnOpen public void onOpen(Session session) throws IOException, EncodeException {} } WebSocket - Client Endpoint has no url value
  • 6. public class DataDecoder implements Decoder.Text<GameData> { @Override public 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> { @Override public 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 handler WebSocket - Message Sending Client //... WebSocketContainer container = ContainerProvider.getWebSocketContainer(); String uri = "ws://websocket.appserver.org/websocket"; // illustrative URL container.connectToServer(SignalChangeEndpointClient.class, URI.create(uri)); //...
  • 8. Artifacts for the well grounded .... Tyrus - a RI of JSR 356 http://tyrus.java.net/ for the impatient .... GlassFish 4 (JEE7) - via Promoted builds http://download.java.net/glassfish/4.0/promoted/ upcoming WildFly http://www.wildfly.org/