SlideShare a Scribd company logo
2013 © Trivadis
BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN
JavaOne 2013 JavaFX / JacpFX
interaction with JSR356
WebSockets
Andy Moncsek
27. Sept. 2013
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
1
2013 © Trivadis
BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN
Andy Moncsek
Consultant for Application Devlopment (Zürich - Switzerland)
Trainer for JavaEE Assembly & Deployment
Contacts: Andy.Moncsek@Trivadis.com
Twitter: @AndyAHCP
2013 © Trivadis
AGENDA
1. Introduction
2. WebSocket (JSR-356)
 Create a simple maven WebApp
 Create a ServerEndpoint
 Create Encoder/Decoder
3. JavaFX
 Create a maven JavaFX application
 Create a JavaFX - (WebSocket) ClientEndpoint
4. JacpFX
 Create a maven JacpFX application
 Create a JacpFX - (WebSocket) ClientEndpoint
5. Conclusion
30.09.2013
JEE to the Max
3
2013 © Trivadis
Introduction
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
4
Three
Key technologies
and
only
50 min
2013 © Trivadis
Introduction - JavaFX
JavaFX is Swing in cool ![1]
since JDK1.7_u6 included in JDK
JavaFX8 in JDK8
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
5
2013 © Trivadis
Introduction - JavaFX - key features
• SceneGraph
• Contains all nodes (e.g. UI components, shapes, images, containers)
• Rendered on GPU (Prism)
• Skinnable with CSS
• Declarative UI with FXML
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
6
[2]
2013 © Trivadis
Introduction - JacpFX
JacpFX is a RCP framework on top of JavaFX
Developed since 2009 (on Swing), since 2011
on JavaFX
Currently migrated to Java8 / JavaFX8
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
7
2013 © Trivadis
Introduction - JacpFX - key features
• Simple API to create Rich Clients in MVC style with JavaFX, Spring
• Actor like component approach with component messaging
• Structure your FX application
• Less effort on threading topics
• No locking or unresponsive UI
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
8
2013 © Trivadis
Introduction - WebSocket (JSR 356)
Full duplex communication in either direction
Part of JEE7, included in GlassFish 4
Tyrus project: reference implementation
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
9
2013 © Trivadis
Introduction - WebSocket (JSR 356) - key features
• Java API for Server- and Client-Side (JEE7)
• Programmatic and annotation-based endpoints
• Support for Encoder/Decoder to map message to Java objects
• Support for @PathParam
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
10
2013 © Trivadis
WebSocket (JSR-356)
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
11
2013 © Trivadis
WebSocket (JSR-356) - maven
• Create a simple webapp with maven
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-
webapp
• Add JEE coordinates:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
That’s it!
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
12
2013 © Trivadis
WebSocket (JSR-356) - ServerEndpoint (by annotation)
30.09.2013
JEE to the Max
13
@ServerEndpoint("/chat")
public class ChatServerEndpoint {
@OnOpen
public void init(Session session) {…}
@OnMessage
public void handleMessage(Message message, Session session) {
session.getBasicRemote().sendObject(message);
}
@OnClose
…
@OnError
…
}
2013 © Trivadis
WebSocket - Encoder/Decoder
• Encoders: Java Object  Binary / Text
public class MEnc implements Encoder.Binary<Message>{
public ByteBuffer encode(Message message) {...}
}
• register: @ServerEndpoint(encoders = {MEnc.class})
• Decoders: Binary / Text Java Object
public class MessageDecoder implements Decoder.Binary<Message>{
public Message decode(ByteBuffer b) {...}
public boolean willDecode(ByteBuffer b) {...}
}
• register: @ServerEndpoint(decoders = {MessageDecoder.class})
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
14
2013 © Trivadis
JavaFX - ClientEndpoint
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
15
2013 © Trivadis
JavaFX - maven
• Maven plugin and archetype provided by community [3]
• Create a simple JavaFX app with maven:
mvn archetype:generate -DarchetypeGroupId=com.zenjava -
DarchetypeArtifactId=javafx-basic-archetype -
DarchetypeVersion=2.0.1
• Add the Tyrus (WebSocket client API) dependencies (tyrus-client &
tyrus-container-grizzly):
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
16
<dependency>
<groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-client</artifactId>
<version>1.0</version>
</dependency>
2013 © Trivadis
JavaFX - ClientEndpoint
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
17
• Annotation is the easiest way for JavaFX / ClientEndpoints
• Annotate Controls, Containers or FXML Controller
@ClientEndpoint
public class ChatView extends VBox{
@OnOpen
…
@OnClose
…
@OnError
…
@OnMessage
…
}
2013 © Trivadis
JavaFX - ClientEndpoint
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
18
• Configure a ClientEndpoint
@ClientEndpoint
public class ChatView extends VBox{
public void init() {
ClientManager client = ClientManager.createClient();
client.connectToServer(this,
ClientEndpointConfig.Builder.create(),
URI.create(“ws://host/chat“));
}
@OnOpen, @OnMessage, …
}
2013 © Trivadis
JavaFX - ClientEndpoint
DEMO
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
19
2013 © Trivadis
JavaFX - ClientEndpoint
What went wrong?
We forgot the FX application thread !!!
1. Don´t create connections on FX application thread
2. @OnOpen, @OnMessage… are NOT on FX application thread
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
20
2013 © Trivadis
JavaFX - ClientEndpoint
Use a service to create connections
private static class ConnectionService extends Service<Void>{
protected Task<Void> createTask() {
return new Task<Void>(){
ClientManager client = ClientManager.createClient();
// connect to Server
return null;
}
};
}
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
21
2013 © Trivadis
JavaFX - ClientEndpoint
Do not modify Nodes outside FX Thread!
Do this instead:
@OnMessage
public void handleChatMessage(Message message) {
Platform.runLater(()-> {
node.getChilderen().add(new Label(message.getText()));
}
);
}
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
22
2013 © Trivadis
JacpFX - ClientEndpoint
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
23
2013 © Trivadis
JacpFX - maven
• Create a sample JacpFX app with maven:
mvn archetype:generate -DarchetypeGroupId=org.jacp -
DarchetypeArtifactId=JacpFX-quickstart-archetype -
DarchetypeVersion=1.4 -
DarchetypeRepository=http://developer.ahcp.de/nexus/content/reposi
tories/jacp
• Add the Tyrus (WebSocket client API) dependencies
• Detailed documentation:
• https://code.google.com/p/jacp/wiki/Documentation
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
24
2013 © Trivadis
JacpFX - maven
• JacpFX application / messaging structure:
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
25
2013 © Trivadis
JacpFX - Endpoint
@Component(id = "id3”)
@ClientEndpoint
public class WebSocketEndpoint implements CallbackComponent {
@Resource private JACPContext context;
@PostConstruct
public void init() {
// connect to Server Endpoint
}
public Object handle(final IAction<Event, Object> arg0) {…}
@OnMessage
public void onChatMessage(Message m) {
context.getActionListener("id2”,m).performAction(null);
}
}
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
26
2013 © Trivadis
JacpFX - UI
@Component(id = "id2")
@DeclarativeView(viewLocation = "chat.fxml", executionTarget = "main")
public class ChatView implements FXComponent {
public Node handle(final IAction<Event, Object> action) {…}
public Node postHandle(Node n, IAction<Event, Object> action) {
// runs in FX application thread
if (action.isMessageType(ChatMessage.class)) {
chat.getChildren().add(arg0);
}
return null;
}
@FXML
private void handleSend(ActionEvent event) {
context.getActionListener("id3", …)
.performAction(null);
}
}
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
27
2013 © Trivadis
JacpFX - ClientEndpoint
DEMO
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
28
2013 © Trivadis
Conclusion
• JavaFX is cool… BUT
• Take care of your application structure (same as plain Swing)
• Take care of the application thread (same as every UI toolkit)
• JacpFX
• Helps to structure your application
• Avoid threading issues
• BUT… still ongoing development (target  Java8 release)
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
29
2013 © Trivadis
Conclusion
• WebSockets (JSR 356)
• WebSockets will change the internet
• Great JEE7 feature
• Easy to use
• Still some tasks to do (e.g. clustering, authentication)
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
30
2013 © Trivadis
Any Questions ?
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
31
2013 © Trivadis
BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN
Thank you.
Andy Moncsek
Mail: Andy.Moncsek@Trivadis.com
Twitter: @AndyAHCP
www.trivadis.com
30.09.2013
JEE to the Max
32
2013 © Trivadis
appendix
• [1] Slides from Michal Heinrich
(http://de.slideshare.net/michael_heinrichs/javafx-
11583106?from_search=1)
• http://jfxtras.org/
• http://fxexperience.com/controlsfx/
• [2] http://docs.oracle.com/javafx/2/architecture/jfxpub-architecture.html
• [3] http://zenjava.com/javafx/maven/
• Tyrus Project: http://java.net/projects/tyrus
• JacpFX: https://code.google.com/p/jacp/
• GlassFish 4 downloads: http://glassfish.java.net/public/downloadsindex.html
30.09.2013
JavaFX / JacpFX interaction with JSR356 WebSockets
33

More Related Content

What's hot

jRecruiter - The AJUG Job Posting Service
jRecruiter - The AJUG Job Posting ServicejRecruiter - The AJUG Job Posting Service
jRecruiter - The AJUG Job Posting Service
Gunnar Hillert
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web Framework
Will Iverson
 
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudJavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
Arun Gupta
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-on
Matt Raible
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
Matt Raible
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Arun Gupta
 
Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018
Matt Raible
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
Fred Sauer
 
Vue js and Vue Material
Vue js and Vue MaterialVue js and Vue Material
Vue js and Vue Material
Eueung Mulyana
 
Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012
Nicholas Zakas
 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
oscon2007
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.
Dragos Mihai Rusu
 
Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021
Matt Raible
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019
Matt Raible
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
Anis Ahmad
 
The State of Wicket
The State of WicketThe State of Wicket
The State of Wicket
Martijn Dashorst
 
Testing micro services using testkits
Testing micro services using testkitsTesting micro services using testkits
Testing micro services using testkits
Maxim Novak
 
Wicket Introduction
Wicket IntroductionWicket Introduction
Wicket Introduction
Eyal Golan
 
What's New in Spring 3.1
What's New in Spring 3.1What's New in Spring 3.1
What's New in Spring 3.1
Matt Raible
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
Shreedhar Ganapathy
 

What's hot (20)

jRecruiter - The AJUG Job Posting Service
jRecruiter - The AJUG Job Posting ServicejRecruiter - The AJUG Job Posting Service
jRecruiter - The AJUG Job Posting Service
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web Framework
 
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudJavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-on
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
 
Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
Vue js and Vue Material
Vue js and Vue MaterialVue js and Vue Material
Vue js and Vue Material
 
Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012
 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.
 
Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
 
The State of Wicket
The State of WicketThe State of Wicket
The State of Wicket
 
Testing micro services using testkits
Testing micro services using testkitsTesting micro services using testkits
Testing micro services using testkits
 
Wicket Introduction
Wicket IntroductionWicket Introduction
Wicket Introduction
 
What's New in Spring 3.1
What's New in Spring 3.1What's New in Spring 3.1
What's New in Spring 3.1
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 

Similar to JavaFX / JacpFX interaction with JSR356 WebSockets

Scalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyondScalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyond
Andy Moncsek
 
From Zero to Cloud in 12 Easy Factors
From Zero to Cloud in 12 Easy FactorsFrom Zero to Cloud in 12 Easy Factors
From Zero to Cloud in 12 Easy Factors
Ed King
 
Introduction to Vaadin
Introduction to VaadinIntroduction to Vaadin
Introduction to Vaadin
netomi
 
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
LogeekNightUkraine
 
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Andy Moncsek
 
Strut2-Spring-Hibernate
Strut2-Spring-HibernateStrut2-Spring-Hibernate
Strut2-Spring-Hibernate
Jay Shah
 
Struts Interview Questions
Struts Interview QuestionsStruts Interview Questions
Struts Interview Questions
jbashask
 
TDC2016SP - Construindo Microserviços usando Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring CloudTDC2016SP - Construindo Microserviços usando Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring Cloud
tdc-globalcode
 
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Matt Raible
 
Micronaut Launchpad
Micronaut LaunchpadMicronaut Launchpad
Micronaut Launchpad
Zachary Klein
 
Struts 1
Struts 1Struts 1
Struts 1
Lalit Garg
 
Microsoft, java and you!
Microsoft, java and you!Microsoft, java and you!
Microsoft, java and you!
George Adams
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
Simo Ahava
 
Considerations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke siteConsiderations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke site
Engage Software
 
five Sling features you should know
five Sling features you should knowfive Sling features you should know
five Sling features you should know
connectwebex
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021
Matt Raible
 
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Matt Raible
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
Matteo Manchi
 
Web sockets in Java
Web sockets in JavaWeb sockets in Java
Web sockets in Java
Pance Cavkovski
 
TDC 2016 - Arquitetura Java - Spring Cloud
TDC 2016 - Arquitetura Java - Spring CloudTDC 2016 - Arquitetura Java - Spring Cloud
TDC 2016 - Arquitetura Java - Spring Cloud
Claudio Eduardo de Oliveira
 

Similar to JavaFX / JacpFX interaction with JSR356 WebSockets (20)

Scalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyondScalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyond
 
From Zero to Cloud in 12 Easy Factors
From Zero to Cloud in 12 Easy FactorsFrom Zero to Cloud in 12 Easy Factors
From Zero to Cloud in 12 Easy Factors
 
Introduction to Vaadin
Introduction to VaadinIntroduction to Vaadin
Introduction to Vaadin
 
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
 
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
 
Strut2-Spring-Hibernate
Strut2-Spring-HibernateStrut2-Spring-Hibernate
Strut2-Spring-Hibernate
 
Struts Interview Questions
Struts Interview QuestionsStruts Interview Questions
Struts Interview Questions
 
TDC2016SP - Construindo Microserviços usando Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring CloudTDC2016SP - Construindo Microserviços usando Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring Cloud
 
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
 
Micronaut Launchpad
Micronaut LaunchpadMicronaut Launchpad
Micronaut Launchpad
 
Struts 1
Struts 1Struts 1
Struts 1
 
Microsoft, java and you!
Microsoft, java and you!Microsoft, java and you!
Microsoft, java and you!
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
 
Considerations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke siteConsiderations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke site
 
five Sling features you should know
five Sling features you should knowfive Sling features you should know
five Sling features you should know
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021
 
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
Web sockets in Java
Web sockets in JavaWeb sockets in Java
Web sockets in Java
 
TDC 2016 - Arquitetura Java - Spring Cloud
TDC 2016 - Arquitetura Java - Spring CloudTDC 2016 - Arquitetura Java - Spring Cloud
TDC 2016 - Arquitetura Java - Spring Cloud
 

More from Andy Moncsek

The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVMThe JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
Andy Moncsek
 
Master your java_applications_in_kubernetes
Master your java_applications_in_kubernetesMaster your java_applications_in_kubernetes
Master your java_applications_in_kubernetes
Andy Moncsek
 
Going serverless with Fn project, Fn Flow and Kubernetes
Going serverless with Fn project, Fn Flow and KubernetesGoing serverless with Fn project, Fn Flow and Kubernetes
Going serverless with Fn project, Fn Flow and Kubernetes
Andy Moncsek
 
Vert.x based microservices with vxms
Vert.x based microservices with vxmsVert.x based microservices with vxms
Vert.x based microservices with vxms
Andy Moncsek
 
Event driven microservices with vxms, hazelcast and kubernetes - muenchen
Event driven microservices with vxms, hazelcast and kubernetes - muenchenEvent driven microservices with vxms, hazelcast and kubernetes - muenchen
Event driven microservices with vxms, hazelcast and kubernetes - muenchen
Andy Moncsek
 
Event driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetesEvent driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetes
Andy Moncsek
 
autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3
Andy Moncsek
 

More from Andy Moncsek (7)

The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVMThe JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
 
Master your java_applications_in_kubernetes
Master your java_applications_in_kubernetesMaster your java_applications_in_kubernetes
Master your java_applications_in_kubernetes
 
Going serverless with Fn project, Fn Flow and Kubernetes
Going serverless with Fn project, Fn Flow and KubernetesGoing serverless with Fn project, Fn Flow and Kubernetes
Going serverless with Fn project, Fn Flow and Kubernetes
 
Vert.x based microservices with vxms
Vert.x based microservices with vxmsVert.x based microservices with vxms
Vert.x based microservices with vxms
 
Event driven microservices with vxms, hazelcast and kubernetes - muenchen
Event driven microservices with vxms, hazelcast and kubernetes - muenchenEvent driven microservices with vxms, hazelcast and kubernetes - muenchen
Event driven microservices with vxms, hazelcast and kubernetes - muenchen
 
Event driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetesEvent driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetes
 
autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3
 

Recently uploaded

Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 

Recently uploaded (20)

Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 

JavaFX / JacpFX interaction with JSR356 WebSockets

  • 1. 2013 © Trivadis BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN JavaOne 2013 JavaFX / JacpFX interaction with JSR356 WebSockets Andy Moncsek 27. Sept. 2013 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 1
  • 2. 2013 © Trivadis BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN Andy Moncsek Consultant for Application Devlopment (Zürich - Switzerland) Trainer for JavaEE Assembly & Deployment Contacts: Andy.Moncsek@Trivadis.com Twitter: @AndyAHCP
  • 3. 2013 © Trivadis AGENDA 1. Introduction 2. WebSocket (JSR-356)  Create a simple maven WebApp  Create a ServerEndpoint  Create Encoder/Decoder 3. JavaFX  Create a maven JavaFX application  Create a JavaFX - (WebSocket) ClientEndpoint 4. JacpFX  Create a maven JacpFX application  Create a JacpFX - (WebSocket) ClientEndpoint 5. Conclusion 30.09.2013 JEE to the Max 3
  • 4. 2013 © Trivadis Introduction 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 4 Three Key technologies and only 50 min
  • 5. 2013 © Trivadis Introduction - JavaFX JavaFX is Swing in cool ![1] since JDK1.7_u6 included in JDK JavaFX8 in JDK8 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 5
  • 6. 2013 © Trivadis Introduction - JavaFX - key features • SceneGraph • Contains all nodes (e.g. UI components, shapes, images, containers) • Rendered on GPU (Prism) • Skinnable with CSS • Declarative UI with FXML 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 6 [2]
  • 7. 2013 © Trivadis Introduction - JacpFX JacpFX is a RCP framework on top of JavaFX Developed since 2009 (on Swing), since 2011 on JavaFX Currently migrated to Java8 / JavaFX8 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 7
  • 8. 2013 © Trivadis Introduction - JacpFX - key features • Simple API to create Rich Clients in MVC style with JavaFX, Spring • Actor like component approach with component messaging • Structure your FX application • Less effort on threading topics • No locking or unresponsive UI 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 8
  • 9. 2013 © Trivadis Introduction - WebSocket (JSR 356) Full duplex communication in either direction Part of JEE7, included in GlassFish 4 Tyrus project: reference implementation 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 9
  • 10. 2013 © Trivadis Introduction - WebSocket (JSR 356) - key features • Java API for Server- and Client-Side (JEE7) • Programmatic and annotation-based endpoints • Support for Encoder/Decoder to map message to Java objects • Support for @PathParam 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 10
  • 11. 2013 © Trivadis WebSocket (JSR-356) 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 11
  • 12. 2013 © Trivadis WebSocket (JSR-356) - maven • Create a simple webapp with maven mvn archetype:generate -DarchetypeArtifactId=maven-archetype- webapp • Add JEE coordinates: <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> That’s it! 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 12
  • 13. 2013 © Trivadis WebSocket (JSR-356) - ServerEndpoint (by annotation) 30.09.2013 JEE to the Max 13 @ServerEndpoint("/chat") public class ChatServerEndpoint { @OnOpen public void init(Session session) {…} @OnMessage public void handleMessage(Message message, Session session) { session.getBasicRemote().sendObject(message); } @OnClose … @OnError … }
  • 14. 2013 © Trivadis WebSocket - Encoder/Decoder • Encoders: Java Object  Binary / Text public class MEnc implements Encoder.Binary<Message>{ public ByteBuffer encode(Message message) {...} } • register: @ServerEndpoint(encoders = {MEnc.class}) • Decoders: Binary / Text Java Object public class MessageDecoder implements Decoder.Binary<Message>{ public Message decode(ByteBuffer b) {...} public boolean willDecode(ByteBuffer b) {...} } • register: @ServerEndpoint(decoders = {MessageDecoder.class}) 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 14
  • 15. 2013 © Trivadis JavaFX - ClientEndpoint 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 15
  • 16. 2013 © Trivadis JavaFX - maven • Maven plugin and archetype provided by community [3] • Create a simple JavaFX app with maven: mvn archetype:generate -DarchetypeGroupId=com.zenjava - DarchetypeArtifactId=javafx-basic-archetype - DarchetypeVersion=2.0.1 • Add the Tyrus (WebSocket client API) dependencies (tyrus-client & tyrus-container-grizzly): 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 16 <dependency> <groupId>org.glassfish.tyrus</groupId> <artifactId>tyrus-client</artifactId> <version>1.0</version> </dependency>
  • 17. 2013 © Trivadis JavaFX - ClientEndpoint 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 17 • Annotation is the easiest way for JavaFX / ClientEndpoints • Annotate Controls, Containers or FXML Controller @ClientEndpoint public class ChatView extends VBox{ @OnOpen … @OnClose … @OnError … @OnMessage … }
  • 18. 2013 © Trivadis JavaFX - ClientEndpoint 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 18 • Configure a ClientEndpoint @ClientEndpoint public class ChatView extends VBox{ public void init() { ClientManager client = ClientManager.createClient(); client.connectToServer(this, ClientEndpointConfig.Builder.create(), URI.create(“ws://host/chat“)); } @OnOpen, @OnMessage, … }
  • 19. 2013 © Trivadis JavaFX - ClientEndpoint DEMO 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 19
  • 20. 2013 © Trivadis JavaFX - ClientEndpoint What went wrong? We forgot the FX application thread !!! 1. Don´t create connections on FX application thread 2. @OnOpen, @OnMessage… are NOT on FX application thread 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 20
  • 21. 2013 © Trivadis JavaFX - ClientEndpoint Use a service to create connections private static class ConnectionService extends Service<Void>{ protected Task<Void> createTask() { return new Task<Void>(){ ClientManager client = ClientManager.createClient(); // connect to Server return null; } }; } 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 21
  • 22. 2013 © Trivadis JavaFX - ClientEndpoint Do not modify Nodes outside FX Thread! Do this instead: @OnMessage public void handleChatMessage(Message message) { Platform.runLater(()-> { node.getChilderen().add(new Label(message.getText())); } ); } 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 22
  • 23. 2013 © Trivadis JacpFX - ClientEndpoint 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 23
  • 24. 2013 © Trivadis JacpFX - maven • Create a sample JacpFX app with maven: mvn archetype:generate -DarchetypeGroupId=org.jacp - DarchetypeArtifactId=JacpFX-quickstart-archetype - DarchetypeVersion=1.4 - DarchetypeRepository=http://developer.ahcp.de/nexus/content/reposi tories/jacp • Add the Tyrus (WebSocket client API) dependencies • Detailed documentation: • https://code.google.com/p/jacp/wiki/Documentation 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 24
  • 25. 2013 © Trivadis JacpFX - maven • JacpFX application / messaging structure: 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 25
  • 26. 2013 © Trivadis JacpFX - Endpoint @Component(id = "id3”) @ClientEndpoint public class WebSocketEndpoint implements CallbackComponent { @Resource private JACPContext context; @PostConstruct public void init() { // connect to Server Endpoint } public Object handle(final IAction<Event, Object> arg0) {…} @OnMessage public void onChatMessage(Message m) { context.getActionListener("id2”,m).performAction(null); } } 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 26
  • 27. 2013 © Trivadis JacpFX - UI @Component(id = "id2") @DeclarativeView(viewLocation = "chat.fxml", executionTarget = "main") public class ChatView implements FXComponent { public Node handle(final IAction<Event, Object> action) {…} public Node postHandle(Node n, IAction<Event, Object> action) { // runs in FX application thread if (action.isMessageType(ChatMessage.class)) { chat.getChildren().add(arg0); } return null; } @FXML private void handleSend(ActionEvent event) { context.getActionListener("id3", …) .performAction(null); } } 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 27
  • 28. 2013 © Trivadis JacpFX - ClientEndpoint DEMO 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 28
  • 29. 2013 © Trivadis Conclusion • JavaFX is cool… BUT • Take care of your application structure (same as plain Swing) • Take care of the application thread (same as every UI toolkit) • JacpFX • Helps to structure your application • Avoid threading issues • BUT… still ongoing development (target  Java8 release) 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 29
  • 30. 2013 © Trivadis Conclusion • WebSockets (JSR 356) • WebSockets will change the internet • Great JEE7 feature • Easy to use • Still some tasks to do (e.g. clustering, authentication) 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 30
  • 31. 2013 © Trivadis Any Questions ? 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 31
  • 32. 2013 © Trivadis BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN Thank you. Andy Moncsek Mail: Andy.Moncsek@Trivadis.com Twitter: @AndyAHCP www.trivadis.com 30.09.2013 JEE to the Max 32
  • 33. 2013 © Trivadis appendix • [1] Slides from Michal Heinrich (http://de.slideshare.net/michael_heinrichs/javafx- 11583106?from_search=1) • http://jfxtras.org/ • http://fxexperience.com/controlsfx/ • [2] http://docs.oracle.com/javafx/2/architecture/jfxpub-architecture.html • [3] http://zenjava.com/javafx/maven/ • Tyrus Project: http://java.net/projects/tyrus • JacpFX: https://code.google.com/p/jacp/ • GlassFish 4 downloads: http://glassfish.java.net/public/downloadsindex.html 30.09.2013 JavaFX / JacpFX interaction with JSR356 WebSockets 33

Editor's Notes

  1. Alle Beispiele und Tests mit GlassFish 4 promotionbuilds