And another thing...
Preview of JavaFX Script support in GlassFish V2 UR1 Application Clients
I have added an early, technology preview implementation of JavaFX script support to the app client container in GlassFish V2 update release 1.
Note: We may choose to provide this feature in some other way in the future. This is an early-access, technology preview feature. One goal of this early implementation was to be minimally disruptive to the existing app client container code path and public interface, including the appclient command-line syntax. Even so, the implementation is (we believe) fully functional.
How to use the feature
Using Resource Injection
Using Command-line Arguments
Other Hints
What about Java Web Start?
Tell us about your Apps
Trivial sample
You need to do these things to use this early-access feature:
The app client container (ACC) that actually runs your app client will also search the app client for an actual main class using the same Main-Class element from the manifest. The ACC will not run this class if it finds a script of that name, but it will process that class for annotations and inject any required references - to EJBs or web services, for example. This means that your JavaFX script can very easily make use of those injected references using the JavaFX script features for accessing Java classes and objects. My suggestion is to write public static convenience methods on a Java class in your app client (it could be the main class or some other class) that refer to the resources that will be injected into the main class. Then your JavaFX script can refer to those convenience methods to work with the back-end resources.
In case you need them, when launched by the ACC the JavaFX script has access to any command-line arguments specified in the launch via the JavaFX script variable
arguments:java.util.Collection
For a long time I have used a simple Java example for private testing that just displays in a list box all the command line arguments passed to appclient. Here is how I accomplished the same thing in my test JavaFX script:
ListBox {
cells : bind foreach (arg in arguments:<<java.util.Collection>>.toArray())
ListCell {
text: (String) arg
}
(JavaFX script does a really good job of encouraging the model-view-controller design approach. The "bind" concept fosters this.)
I would not assume that the order in which scripting engines are made available through the API is not predictable, so my advice is to avoid packaging scripts of different types but the same name into one same app client in the same location where they could be found by the Main-Class searching algorithm I summarized above.
You can launch your app client using the built-in Java Web Start support for app clients as well as the appclient script and still get the same JavaFX support. You don't need to do anything differently.
If you use this feature, please let us know by adding a comment to this entry - preferably with a link to some information about your app or to your app itself!
Here is the ridiculously trivial sample JavaFX script I wrote for displaying the command line arguments. (I want to post a better example that uses injected references to EJBs as I described earlier. I just have not had the time yet.) I provide the sample here as-is with no warranty and no support and no claim that it's particularly clever JavaFX script! There may well be better ways to accomplish this with JavaFX script. I do not claim to be anything close to an expert on the language. But I'm learning!
/*
* Main.fx
*/
import java.lang.System;
import javafx.ui.*;
Frame {
title: "JavaFX via GlassFish!"
width: 300
height: 250
centerOnScreen: true
content: BorderPanel {
top:
Label {
text: "Sample Application Client U/I"
font: Font {
faceName: "Arial"
size: 18
}
}
center: BorderPanel {
top: TextField {
text: "Below are the command line arguments received during launch"
editable: false
}
}
center: ListBox {
cells : bind foreach (arg in arguments:<<java.util.Collection>>.toArray())
ListCell {
text: (String) arg
}
}
}
visible: true
onClose: operation() {System.exit(0);}
}
Posted at 12:06PM Oct 03, 2007 by timq in GlassFish | Comments[4]
Today's Page Hits: 281
Good work, Tim.
Posted by Kedar Mhaswade on October 03, 2007 at 01:28 PM CDT #
What about a real life situation where firewall prevents the RMI/IIOP from working ?.
Posted by gustav trede on October 03, 2007 at 04:45 PM CDT #
Posted by Mirror on October 03, 2007 at 06:06 PM CDT #
Posted by Jean-Francois Arcand's Blog on December 19, 2007 at 05:44 PM CST #