SlideShare a Scribd company logo
1 of 33
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 ServiceGunnar Hillert
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web FrameworkWill 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 CloudArun 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-onMatt 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 2019Matt 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-RSArun 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 2018Matt 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-13Fred Sauer
 
Vue js and Vue Material
Vue js and Vue MaterialVue js and Vue Material
Vue js and Vue MaterialEueung Mulyana
 
Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Nicholas Zakas
 
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 2021Matt 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 2019Matt Raible
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript ApplicationAnis Ahmad
 
Testing micro services using testkits
Testing micro services using testkitsTesting micro services using testkits
Testing micro services using testkitsMaxim Novak
 
Wicket Introduction
Wicket IntroductionWicket Introduction
Wicket IntroductionEyal 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.1Matt Raible
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011Shreedhar 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 jee7andbeyondAndy 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 FactorsEd King
 
Introduction to Vaadin
Introduction to VaadinIntroduction to Vaadin
Introduction to Vaadinnetomi
 
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-HibernateJay Shah
 
Struts Interview Questions
Struts Interview QuestionsStruts Interview Questions
Struts Interview Questionsjbashask
 
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 Cloudtdc-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 2020Matt Raible
 
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 analystsSimo 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 siteEngage Software
 
five Sling features you should know
five Sling features you should knowfive Sling features you should know
five Sling features you should knowconnectwebex
 
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 2021Matt 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 2020Matt 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 applicationsMatteo Manchi
 

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 JVMAndy Moncsek
 
Master your java_applications_in_kubernetes
Master your java_applications_in_kubernetesMaster your java_applications_in_kubernetes
Master your java_applications_in_kubernetesAndy 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 KubernetesAndy Moncsek
 
Vert.x based microservices with vxms
Vert.x based microservices with vxmsVert.x based microservices with vxms
Vert.x based microservices with vxmsAndy 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 - muenchenAndy 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 kubernetesAndy Moncsek
 
autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3Andy 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

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
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
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
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
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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 ...
 
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...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

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