File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JavaFX and the fly likes Embedding Jetty inside a JavaFX app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Embedding Jetty inside a JavaFX app" Watch "Embedding Jetty inside a JavaFX app" New topic
Author

Embedding Jetty inside a JavaFX app

andrew ennamorato
Ranch Hand

Joined: Oct 03, 2007
Posts: 100
Is this even possible?

Here's why I ask: PubSubHubbub (or PuSH) is a fairly new take on making RSS/Atom syndication more real-time. The problem is, there aren't a lot of Atom/RSS readers that support receiving updates via push.
The easiest/simpler (smarter?) thing to do would be to have a server receive the pushes, then a JavaFX client that just makes ajax-y calls to the server and updates as items come in. But is there any way to make a JavaFX app/applet (still not familiar with the terminology of JavaFX) a "server" by embedding something like Jetty? The other major pitfall is NATing, but again, don't know enough JavaFX to know if that is even possible.

Maybe a better question is - what's the best way to communicate between a JavaFX app and a server? HTTP calls from JavaFX to server only? Or is there any sort of "receive" mechanism that can be used in JavaFX?
Stephen Chin
author
Greenhorn

Joined: Aug 30, 2009
Posts: 9
Andrew,

Very interesting question.

On the simple, firewall-safe side of things, JavaFX comes with an HttpRequest mechanism that could be used together with a server that supports HTTP server push in order to do notification from server to client.

On the complicated, but very powerful side of things, you could do a full HTTP server like you suggested. JavaFX applications can take full advantage of any existing Java libraries (even a full http server like Jetty), so it is conceivable you could spawn a whole client-side server for bi-directional messaging. At least two caveats with going down a path like this are that you may run into firewall issues on the client, and will need to have a signed application to get permission to start a ServerSocket.


--Steve
book: http://projavafx.com/
blog: http://steveonjava.com/
andrew ennamorato
Ranch Hand

Joined: Oct 03, 2007
Posts: 100
Stephen,

Thanks for the reply and answers.

You're absolutely right - firewalls and other issues would be a bit of a nightmare (if not showstopper), but I may have a workaround (private closed networks can be useful at times). Really just need to sit down and look at the JavaFX and Java library integration - does Pro JavaFX cover any of that? Some of the other JavaFX books seem to be mostly focused on JavaFX (and rightly slow), but not necessarily how it interacts with Java.
Stephen Chin
author
Greenhorn

Joined: Aug 30, 2009
Posts: 9
Andrew,

Weiqi has a whole section in Chapter 4 dedicated to Java and JavaFX interoperability, which you will definitely find useful. It is really pretty transparent to call Java and use Java data types, including arrays and lists. Also, by using Java interfaces you can have your JavaFX and Java classes extend the same class hierarchy, making the integration even more seamless.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Embedding Jetty inside a JavaFX app