<?xml version="1.0" encoding="UTF-8" standalone="yes"?><feed xmlns="http://www.w3.org/2005/Atom"><title>Johan's blog</title><id>http://lodgon.com/feedid-31</id><updated>2010-07-30T15:36:32.635+02:00</updated><link href="http://s2.lodgon.com/lodgonweb/servlet/rss?id=31&amp;type=blog" rel="self"/><entry><title>JavaFX Open Source</title><link href="http://blogs.lodgon.com/johan/JavaFX_Open_Source" rel="alternate"/><author><name>johan</name></author><summary type="html">I signed the &lt;a href="http://steveonjava.com/javafx-petition/"&gt;petition to Open Source the JavaFX Platform&lt;/a&gt;. I think the benefits of Open Sourcing
JavaFX can be huge, both for Oracle and the JavaFX community.
The example of Glassfish, where the open community-approach leads to
high quality software while still allowing a commercial
model, can be followed by JavaFX.
</summary><content type="html">I signed the &lt;a href="http://steveonjava.com/javafx-petition/"&gt;petition to Open Source the JavaFX Platform&lt;/a&gt;. I think the benefits of Open Sourcing
JavaFX can be huge, both for Oracle and the JavaFX community.
The example of Glassfish, where the open community-approach leads to
high quality software while still allowing a commercial
model, can be followed by JavaFX.
&lt;p&gt;
First of all, I should stress that I'm not in a position to dictate what
Oracle should or should not do with JavaFX. They inherited the platform
through their acquisition of Sun, and they have spent lots of resources in
JavaFX.
The idea of the petition is rather to convince Oracle that it would be
in the best interest of Oracle, the JavaFX developers and the Internet
in general to open-source the JavaFX platform.
&lt;p&gt;
The ideas behind JavaFX are great: use the power, the maturity and the
availability of the Java platform to create a client-side language that
allows the rapid creation of highly interactive and rich client applications,
that run on all Java-based systems. At this moment, JavaFX is the only
RIA platform that is entirely based on the Java platform.
&lt;br/&gt;
I see a growing interest from Java Enterprise developers in client-side
development and vice versa. Without JavaFX, these Java (Enterprise)
developers have to choose between a non-Java based RIA or a few
thousands specific web-based frameworks for their client development.
With JavaFX, it becomes much easier for them to create rich and interactive
client-applications.
&lt;p&gt;
JavaFX entered the RIA market pretty late. Competition from Flex and
Silverlight was already on the market, attracting developers and companies.
In order for JavaFX to be successful, time to market is a crucial factor.
&lt;p&gt;
The JavaFX platform specification is already pretty ok, but the runtime
ports need to be improved. I remember from my first Java-days (in 1995)
the problems with lack of Java support on different platforms, and that
was exactly the reason I joined the Blackdown team. We had to sign a
license with Sun Microsystems, received the source code, and we could
work on a port that we could distribute. While this was still a rather
closed process, it allowed third party enthusiasts to speed up the
availability of Java.
&lt;p&gt;
A great example of how open-sourcing a project can enhance its quality
and acceptance is &lt;a href="http://glassfish.dev.java.net"&gt;Glassfish&lt;/a&gt;.
The Glassfish project was announced at JavaOne 2005 as the open source
Reference Implementation of the Java Enterprise specification.
It is a huge project, and Sun and Oracle have spent lots of resources in
it. It is difficult to quantify the community input, but there are many
people outside Sun/Oracle involved with Glassfish by writing/reviewing
code, documentation, working on the Quality Assurance (e.g. via FishCat),
working with early access versions etc.
&lt;br&gt;
The result of the combination Open-Source with "backed-by-a-company" is
in this case a great Application Server, leading edge and still very
mature, easy to use and highly configurable.
&lt;br&gt;
As a developer, one of the main benefits of the Glassfish community is that
I can easily debug issues I run into. If those issues are Glassfish-related,
I can report this to the community, I can write a patch myself and commit
it to the community. And, very important, while waiting for a released
version that contains a fix, I can patch my own version and run my
customer projects that require the fix.
&lt;p&gt;
I would recommend a similar approach for JavaFX. Strategic and commercial
decisions probably belong to Oracle. But opening the Runtime (including
ports to mobile and TV) can create a boost in JavaFX quality and
enthusiasm. It is important to have a company that is backing the development, and that provides steering and infrastructure. It is also important to have enthusiastic people in the community that are allowed to contribute and to enhance the quality and adoption.
</content><id>http://lodgon.com/eid-601</id><updated>2010-07-30T15:36:32.635+02:00</updated></entry><entry><title>RedFX: connecting JavaFX to the Enterprise</title><link href="http://blogs.lodgon.com/johan/RedFX_connecting_JavaFX_to_the_Enterprise" rel="alternate"/><author><name>johan</name></author><summary type="html">A couple of months ago, I started to work on RedFX
(&lt;a href="http://redfx.org"&gt;http://redfx.org&lt;/a&gt;), a framework that enables an
easy connection between JavaFX client-based code and Java Enterprise
based backend code. I strongly believe that the connection between
JavaFX and the enterprise in general is an important aspect
in the chances of success for JavaFX.
</summary><content type="html">A couple of months ago, I started to work on RedFX
(&lt;a href="http://redfx.org"&gt;http://redfx.org&lt;/a&gt;), a framework that enables an
easy connection between JavaFX client-based code and Java Enterprise
based backend code. I strongly believe that the connection between
JavaFX and the enterprise in general is an important aspect
in the chances of success for JavaFX.
&lt;p&gt;
The main reason I started to work on RedFX is that I needed something like
this in a number of JavaFX projects I was doing at LodgON. Initially, we
were writing lots of boilerplate code for doing REST-calls to a backend,
parsing the result via the PullParser, or for synchronizing state between
clients and a server.
&lt;br&gt;
However, there are some patterns that often come back, and most
applications would benefit from a clear separation
between the business functionality of the application and the
communication and synchronization parts.
&lt;p&gt;
The RedFX functionality is partly inspired by the
&lt;a href="http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/"&gt;BlazeDS&lt;/a&gt;
framework from &lt;a href="http://www.adobe.com"&gt;Adobe&lt;/a&gt;. RedFX consists of
three parts:
&lt;ul&gt;
&lt;li&gt;(remote) object synchronization: RemoteObjects can be shared across
different instances of JavaFX clients and a server.
&lt;li&gt;messaging: JavaFX clients and Java Enterprise server code can publish
messages and subscribe to channels
&lt;li&gt;WebServiceClient: make it easier to call remote resources using REST
and parse the result into a JavaFX object.
&lt;/ul&gt;
&lt;p&gt;
I am currently in the process of open-sourcing RedFX, and integrating it under
the &lt;a href="http://jfxtras.org"&gt;JFXtras&lt;/a&gt; umbrella.
I am pleasantly surprised by the activity on the jfxtras developer
mailinglist. The JavaFX - Enterprise connectivity is a very important
aspect. The more JavaFX developers are involved with this, the better.
Integrating RedFX in JFXtras will enhance the quality, and make it more
accessible.
&lt;/p&gt;
&lt;script type="text/javascript"&gt;var dzone_url = 'http://blogs.lodgon.com/johan/RedFX_connecting_JavaFX_to_the_Enterprise';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_title = 'RedFX: connecting JavaFX to the Enterprise';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_blurb = 'RedFX: connecting JavaFX to the Enterprise';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_style = '2';&lt;/script&gt;
&lt;script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"&gt;&lt;/script&gt; </content><id>http://lodgon.com/eid-539</id><updated>2010-06-10T20:00:43.830+02:00</updated></entry><entry><title>Glassfish 3.0.1 on Amazon EC2: performance and scaling</title><link href="http://blogs.lodgon.com/johan/Glassfish_301_on_Amazon_EC2_performance_and_scaling" rel="alternate"/><author><name>johan</name></author><summary type="html">Last week, our partner IvoxTools launched 3 voting tests, based on
LodgON's DaliCompare software. Performance and scalability were two of
the main requirements, and we realized this using a promoted build
of Glassfish 3.0.1 and leveraging the Amazon Elastic Cloud Computing (EC2).
</summary><content type="html">Last week, our partner &lt;a href="http://www.ivox.be/iTools_en.html"&gt;IvoxTools&lt;/a&gt; launched 3 voting tests, based on
&lt;a href="http://lodgon.com"&gt;LodgON&lt;/a&gt;'s DaliCompare software. Performance and scalability were two of
the main requirements, and we realized this using a promoted build
of Glassfish 3.0.1 and leveraging the Amazon Elastic Cloud Computing (EC2).
&lt;p&gt;
With elections for both the Dutch and the Belgian parliament nearing,
many people want to know which candidate best matches his own profile.
The DaliCompare software allows users to complete a survey and match
their answers with the answers of famous people, selected parts of the
population (e.g. men, women, people younger than 24 years) and their
friends at social network (currently, Facebook, NetLog and Hyves are
supported).
This allows a funny way for helping people to find out who they have to vote
for.
&lt;p&gt;
Our partner IvoxTools commercializes this software, and a number of Dutch
and Belgian media partners created projects based on DaliCompare:
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.depolitiekematchmaker.nl/"&gt;http://www.depolitiekematchmaker.nl/&lt;/a&gt; (dutch) in the Netherlands
&lt;li&gt;&lt;a href="http://stemvanvlaanderen.be/"&gt;http://stemvanvlaanderen.be/&lt;/a&gt; (dutch) in Belgium
&lt;li&gt;&lt;a href="http://lavoixdesbelges.rtlinfo.be/"&gt;http://lavoixdesbelges.rtlinfo.be/&lt;/a&gt; (french) in Belgium
&lt;/ul&gt;
&lt;p&gt;
I'm probably not allowed to give the exact number of visitors, but we are
talking more than 6 digits (and counting).
&lt;br&gt;
In order to be able to handle millions of users in a short timeframe, the
application needs to be performant (responsive) and scalable.
For previous DaliCompare projects, we used a high-end dedicated server.
The DaliCompare software leverages LodgON's DaliCore framework, which is
extremely performant already.
Expectations for the current projects were huge, and the expectations were
proven to be right. Hence, a single dedicated server for a project would
be insufficient during peak moments --- the project URL's were announced
several times during prime-time on the major tv stations.

The DaliCompare application is written using JavaEE 6. Due to a cookie-bug
in Glassfish 3, we decided to use a promoted build of Glassfish 3.0.1.
Glassfish, together with a well-written application, guarantees the
performance. Scalability is important as well, since the load during peak
moments is much higher than the load in off-peak moments.
We are using Amazon Elastic Cloud Computing (EC2) to achieve this. This
turned out to be very easy, both in configuration and in monitoring.
&lt;br/&gt;
For each project, we use an Amazon Load Balancer instance with session
stickiness, dispatching all requests to a number of instances running
DaliCompare and Glassfish. These instances communicate with an instance
running mysql for persistence.
The architecture of the projects is shown below (click for full-size):
&lt;br&gt;
&lt;a href="http://lodgon.com/johan/DaliCompareInfrastructure.png"&gt;
&lt;img src="http://lodgon.com/johan/DaliCompareInfrastructure.png" border="0" width="600"/&gt;
&lt;/a&gt;
&lt;br&gt;
During non-peak moments (e.g. less than 20.000 completed surveys in an hour),
the Load Balancer is not needed, and a single instance is sufficient. But it
is very easy to create a new instance on the fly (based on an AMI), and add
it to the LB --- which is what we do shortly before a major announcement
on TV is scheduled.

&lt;p&gt;
&lt;b&gt;About the application&lt;/b&gt;
&lt;p&gt;
DaliCore is the framework created by LodgON that provides granular
functionality for social software in general. Basically, it extends the
core Application Server functionality with the notion of users, roles,
permissions, groups, data, activities, preferences,... . This functionality
is needed in most of the projects we do. We have a number of tools
that we created on top of DaliCore. The DaliCore is very well tested,
both from functional point as from performance point. We use jmeter for
testing and regression-testing the performance of DaliCore and are very
confident about its behavior.
&lt;br&gt;
The DaliCore functionality is made available through REST-API's (implemented
using Jersey). Direct EJB-calls are possible as well, but the REST-interface
is the one that is extensively tested and we know the performance
characteristics very well. DaliCore contains stateless Session Beans and
Entity Beans (using JPA).
&lt;br&gt;
The DaliCompare application is a WAR, containing the graphical setup and
providing the application-specific logic needed for the projects. The
real business logic is delegated to the DaliCore application, using REST
calls (using the Jersey Client). It may sound strange, DaliCompare is using
DaliCore using REST-calls instead of e.g. EJB-calls. We did lots of load
testing, though, and Jersey on top of Grizzly behaves extremely well.
&lt;p&gt;
The Amazon Load Balancer dispatches requests to the instances that are attached
to it. In practice, a single instance is sufficient for most of the time,
but failover is a good thing for people's night rest.
While completing the survey, some information is kept on the HttpSession.
Therefore, it is important that the load balancer selects the same instance
for different requests in the same session. This can be easily configured
with the Amazon LB.
&lt;p&gt;
The DaliCompare and DaliCore applications each have their own http-listener
with separate thread-pools. This allows us to fine-tune the size of the
pools, both for external calls (to DaliCompare) and internal calls
(to DaliCore). The 2 thread pools are also needed, in order to avoid
a deadlock. Requests to the DaliCompare often need a request to DaliCore.
If there was only a single threadpool, and all these threads were occupied
at the same moment by requests to DaliCompare, no request to the DaliCore
could be made, hence no requests to DaliCompare could be completed and
no threads could be released.
&lt;p&gt;
Monitoring is an important part of the DaliCompare operations. The Amazon
EC2 console is very useful, it shows the CPU and network load on a
per-minute granularity. Apart from that, we monitor the number of threads
that are used in every threadpool, in order to optimize CPU usage.
&lt;p&gt;
If you want to run an application that needs to handle high volumes or loads,
it is very important that you understand how the constituting parts work.
Tuning the Application Server can save lots of money. Fortunately,
Glassfish allows for a very flexible and transparent tuning.
&lt;p&gt;
 &lt;script type="text/javascript"&gt;var dzone_url = 'http://blogs.lodgon.com/johan/Glassfish_301_on_Amazon_EC2_performance_and_scaling';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_title = 'Glassfish 3.0.1 on Amazon EC2: performance and scaling';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_blurb = 'Glassfish 3.0.1 on Amazon EC2: performance and scaling';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_style = '2';&lt;/script&gt;
&lt;script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"&gt;&lt;/script&gt; </content><id>http://lodgon.com/eid-526</id><updated>2010-05-28T10:38:42.159+02:00</updated></entry><entry><title>Map rendering in JavaFX</title><link href="http://blogs.lodgon.com/johan/Map_rendering_in_JavaFX" rel="alternate"/><author><name>johan</name></author><summary type="html">I have been writing location-based software for a long time. In this area,
JavaFX has some nice benefits that allows you to write map-related
software easily. As a very simple example, I wrote a map renderer that
renders tiles generated by the OpenStreetMap project.
</summary><content type="html">Map rendering in JavaFX

I have been writing location-based software for a long time. In this area,
JavaFX has some nice benefits that allows you to write map-related
software easily. As a very simple example, I wrote a map renderer that
renders tiles generated by the OpenStreetMap project.

The &lt;a href="http://www.openstreetmap.org"&gt;OpenStreetMap&lt;/a&gt; project (OSM) is a
collaborative effort where map data is provided by different sources and
people, and I am very impressed with the quality of the data that is in the
OSM database.
&lt;br&gt;
Apart from viewing the mapdata at the OpenStreetMap website itself, developers
can use the OpenStreetMap API or the Tile Rendering service to integrate
OSM based data in their projects.
&lt;p&gt;
I wrote a very small JavaFX project that retrieve tiles from the
Tiles@home rendering project and shows them. This project is far from a
functional mapping project, but it shows how easy it is to move around
on a map and to zoom in or zoom out using JavaFX.
&lt;br&gt;
&lt;a href="http://javafx.lodgon.com/osmtile/TileClient.jnlp"&gt;http://javafx.lodgon.com/osmtile/TileClient.jnlp&lt;/a&gt; will start the map renderer.
&lt;p&gt;
I made the code for this project available as well:
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://javafx.lodgon.com/osmtile/src/Main.fx"&gt;Main.fx&lt;/a&gt;
&lt;li&gt;&lt;a href="http://javafx.lodgon.com/osmtile/src/MapView.fx"&gt;MapView.fx&lt;/a&gt;
&lt;li&gt;&lt;a href="http://javafx.lodgon.com/osmtile/src/TileUI.fx"&gt;TileUI.fx&lt;/a&gt;
&lt;/ul&gt;
The code is pretty simple and self-explaining, so I am not diving too deep
into it here. The one thing I want to point out, is how easy it is to
show a scaled image while transferring the zoomed images.
&lt;br&gt;
If you zoom into a specific area, the application will first show the
existing tiles in a scaled way, while downloading the new tiles.
Downloading the new, more detailed tiles, can take some time and the
user needs to view "something" while waiting. We solve this by scaling the
tile from the lower zoom level, and showing this until the needed tiles
are downloaded.
&lt;br&gt;
Each TileUI instance represents a tile, and contains a reference to
its "zoomParent", which is the tile at the lower zoomlevel that covers
this tile. It also contains a list of tiles at the next zoomlevel that
are covering the same area as this tiles.
When a new tile is requested, its parent tile is looked up and the
new tile is added to the list of "covering" tiles for this parent:
&lt;pre&gt;
&lt;span class="line-number"&gt;100&lt;/span&gt;             &lt;span class="ST0"&gt;if&lt;/span&gt; (tileMap.containsKey(pidx)) {                          
&lt;span class="line-number"&gt;101&lt;/span&gt;               &lt;span class="keyword"&gt;var&lt;/span&gt; ptile: TileUI = tileMap.get(pidx) &lt;span class="keyword"&gt;as&lt;/span&gt; TileUI;                                                                                                           
&lt;span class="line-number"&gt;102&lt;/span&gt;               &lt;span class="keyword"&gt;inser&lt;/span&gt;&lt;span class="keyword"&gt;t&lt;/span&gt; newtile &lt;span class="keyword"&gt;into&lt;/span&gt; ptile.covering;                                                                                           
&lt;span class="line-number"&gt;103&lt;/span&gt;               newtile.zoomParent = ptile;                                                      
&lt;span class="line-number"&gt;104&lt;/span&gt;            }
&lt;/pre&gt;

Once all tiles for the new zoom level are downloaded, the scaled tile at
the lower zoom level should not be visible anymore.
This is accomplished by removing the dowloaded tile from the list
of covering tiles
&lt;pre&gt;
&lt;span class="line-number"&gt;30&lt;/span&gt;   &lt;span class="keyword"&gt;var&lt;/span&gt; image: Image = Image {
&lt;span class="line-number"&gt;31&lt;/span&gt;       url: resource;
&lt;span class="line-number"&gt;32&lt;/span&gt;       backgroundLoading: &lt;span class="ST0"&gt;true&lt;/span&gt;;
&lt;span class="line-number"&gt;33&lt;/span&gt;     }
...
&lt;span class="line-number"&gt;35&lt;/span&gt;   &lt;span class="keyword"&gt;var&lt;/span&gt; loading = &lt;span class="keyword"&gt;bind&lt;/span&gt; image.progress &lt;span class="keyword"&gt;on&lt;/span&gt; &lt;span class="keyword"&gt;replace&lt;/span&gt; {
&lt;span class="line-number"&gt;36&lt;/span&gt;     &lt;span class="ST0"&gt;if&lt;/span&gt; (loading ==100) {
&lt;span class="line-number"&gt;37&lt;/span&gt;       &lt;span class="keyword"&gt;delete&lt;/span&gt; &lt;span class="keyword"&gt;this&lt;/span&gt; &lt;span class="keyword"&gt;from&lt;/span&gt; zoomParent.covering;
&lt;span class="line-number"&gt;38&lt;/span&gt;     }
&lt;span class="line-number"&gt;39&lt;/span&gt;   }
&lt;/pre&gt;
and by only showing a tile when its zoomlevel is the active zoomlevel
or when this tile is covering higher-zoom tiles:
&lt;pre&gt;
&lt;span class="line-number"&gt;47&lt;/span&gt;   &lt;span class="keyword"&gt;override&lt;/span&gt; &lt;span class="keyword"&gt;var&lt;/span&gt; visible =  &lt;span class="keyword"&gt;bind&lt;/span&gt; ((zoom == mapView.zoom) &lt;span class="keyword"&gt;or&lt;/span&gt; (&lt;span class="keyword"&gt;sizeof&lt;/span&gt; covering &amp;gt; 0) );
&lt;/pre&gt;
I like the simplicity of JavaFX. I should stress though, that this application
is not a production-ready application. Ideally, we need to remove tiles
from the cache to save memory, and many other things should be improved as well.
But the goal was to show how easy it is to write a tile renderer in JavaFX.
</content><id>http://lodgon.com/eid-501</id><updated>2010-03-26T13:45:51.817+01:00</updated></entry><entry><title>Using Glassfish Embedded in offline mode</title><link href="http://blogs.lodgon.com/johan/Using_Glassfish_Embedded_in_offline_mode" rel="alternate"/><author><name>johan</name></author><summary type="html">I have been using Glassfish Embedded (or is it Embedded Glassfish) in a
customer project recently. At first, I just considered it as a customer
project, but now that I think about it, the concept of Glassfish
Embedded opens lots of possibilities.</summary><content type="html">I have been using Glassfish Embedded (or is it Embedded Glassfish) in a
customer project recently. At first, I just considered it as a customer
project, but now that I think about it, the concept of Glassfish
Embedded opens lots of possibilities.
&lt;p&gt;
Unfortunately, I am not allowed to talk about this specific project and
what kind of application it is. But the reason for using Embedded Glassfish
is clear. We created an Enterprise Application for this customer in the
past. The customer is happy with it and uses the application inside the company
and with a few other customers.
&lt;br&gt;
Then, the customer receives questions from his own customers that could
be addressed with the Enterprise Application. We are talking about a big
customer here, and big customers have typically meetings with big companies
in large meeting rooms without public Internet access.
&lt;br&gt;
Also, many presales people are afraid of giving live demonstrations
over the Internet and prefer their own laptop. In many cases they show a
PowerPoint presentation, but the number of potential customers who
can be convinced with slideware is decreasing.
&lt;p&gt;
And here is a perfect opportunity for Glassfish Embedded. It can be
preinstalled and configured on a demo laptop, and (pre)sales people
can show exactly the functionality that would be available in a full-blown
Internet-enabled application. They have everything under control, no
server that might go down, no dependency on a guest-account on a
semi-private Internet, no interference with other people using the application
at the same moment,...
&lt;p&gt;
It may sound strange to some to demonstrate a complex Enterprise Application
on a simple laptop (and laptops of (pre)sales people are often great in
design and pathetic in performance), but with Glassfish Embedded it is
possible:
&lt;ul&gt;
&lt;li&gt;*&amp;nbsp;laptops have much more power than some years ago, even the build-for-design laptops
&lt;li&gt;*&amp;nbsp;The performance of Glassfish is great.
&lt;li&gt;*&amp;nbsp;Glassfish is easy to use and to configure.
&lt;li&gt;*&amp;nbsp;The footprint of glassfish is small. All Java EE functionality is
implemented, still the embedded jar is below 50 MB. That is probably the
size of 2 power point presentations on a (pre)sales laptop.
&lt;li&gt;*&amp;nbsp;Complex problems often require simple solutions.
&lt;/ul&gt;
&lt;p&gt;
This example is just one usecase where Glassfish Embedded can make life
easier. There are probably lots of others as well.
&lt;p&gt;
For more information about Glassfish Embedded, see the following links:
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://embedded-glassfish.dev.java.net"&gt;https://embedded-glassfish.dev.java.net&lt;/a&gt;, the official home
&lt;li&gt;&lt;a href="http://blogs.sun.com/alexismp/entry/glassfish_embedded_reloaded"&gt;http://blogs.sun.com/alexismp/entry/glassfish_embedded_reloaded&lt;/a&gt;, an overview + hello world app from Alexis
&lt;li&gt;&lt;a href="http://docs.sun.com/app/docs/doc/821-1208?l=en"&gt;http://docs.sun.com/app/docs/doc/821-1208?l=en&lt;/a&gt;, the official guide.
&lt;/ul&gt;
</content><id>http://lodgon.com/eid-480</id><updated>2010-02-07T10:46:17.903+01:00</updated></entry><entry><title>JavaFX chat application for focus groups</title><link href="http://blogs.lodgon.com/johan/JavaFX_chat_application_for_focus_groups" rel="alternate"/><author><name>johan</name></author><summary type="html">Over the last months, we have worked on an application that allows companies
and organizations to chat with a dedicated focus group in a controlled
environment. We already have some users for this, e.g. a marketing company that
wants to get the first impressions from users on a new campaign.
The chat client is written in JavaFX and the backend runs on Glassfish v3
with Comet support enabled.
</summary><content type="html">Over the last months, we have worked on an application that allows companies
and organizations to chat with a dedicated focus group in a controlled
environment. We already have some users for this, e.g. a marketing company that
wants to get the first impressions from users on a new campaign.
The chat client is written in JavaFX and the backend runs on Glassfish v3
with Comet support enabled.
&lt;p&gt;
I have written some blog entries about JavaFX chat code before. The
principles in these entries are also used in the iParticipate application
--- iParticipate is the commercial name of the application, I think.
The iParticipate application is focused on moderated chats, though,
allowing a moderator to review, delay, accept or reject messages before they
are shown to the other users. The setup is hence slightly more complicated,
but you can try it yourself at
&lt;a href="http://g6.lodgon.com/TalkingBe"&gt;http://g6.lodgon.com/TalkingBe&lt;/a&gt;.
&lt;p&gt;
We have 2 different views on the application: an administrator view and
a user view. The user view is pretty simple and shows a chat window,
an overview of participants, and a whiteboard:
&lt;br&gt;
&lt;a href="http://lodgon.com/johan/iparticipate/user_iparticipate.jpg"&gt;&lt;img src="http://lodgon.com/johan/iparticipate/user_iparticipate.jpg" width="200"&gt;&lt;/a&gt;
&lt;p&gt;
The administrator view is based on the same code, but we have some more
panels here:
&lt;br&gt;
&lt;a href="http://lodgon.com/johan/iparticipate/chatserver.jpg"&gt;
&lt;img src="http://lodgon.com/johan/iparticipate/chatserver.jpg" width="200"&gt;
&lt;/a&gt;
&lt;br&gt;
The moderator has some more options:
&lt;ul&gt;
&lt;li&gt;add pictures and movies to the sessions and show them (full-screen or not)
&lt;li&gt;moderate incoming chat messages: accept them, reject them, or put them in a queue
&lt;li&gt;manage the auto-approve option by setting moderation time
&lt;li&gt;send a private message to a user
&lt;li&gt;manage bookmarked messages
&lt;li&gt;...
&lt;/ul&gt;
Actually, there are a lot more options, but they should be described somewhere
else.
&lt;p&gt;
Going back to the code and architecture, this project is a nice combination
of Glassfish v3 and JavaFX. The backend is a Java EE 6 WAR application,
containing REST handlers (using Jersey), session beans and JPA Entity
Beans. Different projects can be created simultaneously, and messages
for one project are of course separated from the other projects.
Actions (writing text, bookmarking messages, confirming messages,...)
are implemented as REST calls, and each client has a Comet Handler.
&lt;p&gt;
The JavaFX client code uses the &lt;code&gt;HttpRequest&lt;/code&gt; for sending
all request actions, and the incoming messages are retrieved using
the asynchronous JavaTaskBase/RunnableFuture constructions.
See &lt;a href="http://blogs.lodgon.com/johan/JavaFX_chat_client_with_Comet_server"&gt;http://blogs.lodgon.com/johan/JavaFX_chat_client_with_Comet_server&lt;/a&gt;
for some basic code.
&lt;br&gt;
Animations are used for dealing with the auto-approval functionality
(if the moderator does not do anything during a configurable amount of
seconds, a message will be automatically approved).
&lt;br&gt;
The media packages are used for showing media content. The administrator
manages when and how media content is shown to the user.
&lt;p&gt;
The iParticipate application shows that you can do lots of things with
JavaFX that are extremely difficult to achieve in HTML. Once again, this
convinces me that HTML is not the way forward for application
development.
</content><id>http://lodgon.com/eid-474</id><updated>2010-01-22T15:56:00.439+01:00</updated></entry><entry><title>GlassFish v3 release</title><link href="http://blogs.lodgon.com/johan/GlassFish_v3_release" rel="alternate"/><author><name>johan</name></author><summary type="html">A few minutes ago, &lt;a href="http://glassfish.dev.java.net"&gt;GlassFish v3&lt;/a&gt; was released. When I first talked about
GlassFish v3 in &lt;a href="http://blogs.lodgon.com/johan/Im_using_Java_EE_and_Im_proud_of_it"&gt;this blog entry&lt;/a&gt;, I considered it a revolution rather than
an evolution. Today, I still believe GlassFish v3 is more than just the
numerical successor to GlassFish v2.
</summary><content type="html">A few minutes ago, &lt;a href="http://glassfish.dev.java.net"&gt;GlassFish v3&lt;/a&gt;was released. When I first talked about
GlassFish v3 in &lt;a href="http://blogs.lodgon.com/johan/Im_using_Java_EE_and_Im_proud_of_it"&gt;this blog entry&lt;/a&gt;, I considered it a revolution rather than
an evolution. Today, I still believe GlassFish v3 is more than just the
numerical successor to GlassFish v2.
&lt;p&gt;
&lt;h3&gt;Reference implementation&lt;/h3&gt;
First of all, GlassFishv3 is the reference implementation of the Java EE 6
specification.
Compared with Java EE 5, this specification is a next step towards
simplification in enterprise development. The voice of the enterprise
developers has been heard.
Personally, I am very happy with the JSR 311 (Java API for RESTful
Web Services) and the EJB 3.1 spec. One of the major
benefits of JSR 311 is that it facilitates mobile applications instead
of just Web Applications. A decoupling of business logic and front-end
development at the REST interface offers lots of possibilities.
&lt;p&gt;
It took awhile before I realized the real benefits of EJB 3.1. But
once I started using a NetBeans 6.8 milestone, it became clear that
the enhancements are significant. We don't have to package an ejb-jar and
a war together in an ear anymore, everything can be in one package
(with the confusing name "war", though).
&lt;p&gt;
&lt;h3&gt;Open Source&lt;/h3&gt;
GlassFish v3 is completely Open Source. I have the head-version of the
repository on my desktop, and it is not too difficult to build and
install it yourself.
&lt;br&gt;
The simple fact that software is Open Source itself does not say anything
about its quality. But in the GlassFish case, the code is very well
written and documented, and I was often surprised how easy it is to
dive into the code of this complex piece of software.
&lt;br&gt;
Having access and being able to understand the source code is something
that speeds up development. In a number of cases, your application is
not behaving the way you want it, and you assume that this is a bug
or some strange feature in the application server. You can spend lots of
time trying to find out the cause without looking into the
application server --- and that is how it goes most often.
But you can also look into the relevant code of the Application Server
and try to find out what is causing the problem. When the code is
available and readable, this process can save developers time.
&lt;p&gt;
&lt;h3&gt;Modular&lt;/h3&gt;
One of the major changes in GlassFish v3 is the modular approach.
The old lib-directory has been replaced by a modules directory.

Modules can be installed and uninstalled easily. The Glassfish kernel
itself is very small. As a consequence, the kernel itself is also
usable in environments with limited resources -- desktop and even
mobile. Today, most modules are still enterprise focussed, but the
GlassFish modularity can be a next step towards convergence between
enterprise and mobile software. Enterprise software is becoming
simpler, and mobile devices are becoming more powerful. Software
patterns and technologies that are typically used in one
environment may also work (or be adapted) in another environment.
&lt;p&gt;
I assume GlassFish v3 will be primarily used in the same areas where
GlassFish v2 and other Application Servers are used. But in the
future, I think GlassFish can extend its marketing potential into
new areas, especially when modularity is required and when resources
are still somehow limited, preventing typical big application
servers from being used.
</content><id>http://lodgon.com/eid-444</id><updated>2009-12-10T15:16:45.018+01:00</updated></entry><entry><title>JavaFX and OSGi, part 2</title><link href="http://blogs.lodgon.com/johan/JavaFX_and_OSGi_part_2" rel="alternate"/><author><name>johan</name></author><summary type="html">In my previous blog entry, I described a method to execute an &lt;a href="http://www.osgi.org"&gt;OSGi&lt;/a&gt; framework
in a &lt;a href="http://javafx.com"&gt;JavaFX&lt;/a&gt; runtime. In this entry, I show how you can write OSGi Bundles
containing JavaFX code, and how they can be installed into the OSGi
platform running in the JavaFX runtime.
</summary><content type="html">In my previous blog entry, I described a method to execute an &lt;a href="http://www.osgi.org"&gt;OSGi&lt;/a&gt; framework
in a &lt;a href="http://javafx.com"&gt;JavaFX&lt;/a&gt; runtime. In this entry, I show how you can write OSGi Bundles
containing JavaFX code, and how they can be installed into the OSGi
platform running in the JavaFX runtime.
&lt;p&gt;
The idea behind this code might be a bit strange and dumb (why would one
want to write an OSGi bundle containing JavaFX and deploy it in an
OSGi container on top of JavaFX?) but I have two reasons why
this is really a practical
use case.
&lt;br/&gt;
In the hopefully not too distant future, we might have more
devices that come with JavaFX preinstalled. My HTC Diamond phone, for example,
has a JavaFX platform. If I want to install an OSGi framework onto this phone,
it has to run on top of the JavaFX platform.
&lt;br/&gt;
Also, more developers are getting used with OSGi. The JavaFX platform provides
interesting front-end capabilities for OSGi based services. With JavaFX,
front-end development is in general much easier than with any (A)WT
framework I know.
&lt;p&gt;
&lt;h3&gt;The OsgiFX framework&lt;/h3&gt;
Running an OSGi framework on top of JavaFX is described in
&lt;a href="http://blogs.lodgon.com/johan/JavaFX_and_OSGi_part_1"&gt;this blogentry&lt;/a&gt;, and the code can be found at
&lt;a href="http://code.google.com/p/osgifx"&gt;http://code.google.com/p/osgifx&lt;/a&gt;.
Note that I made some major changes to the code since I wrote the previous
blog entry --- I hope to find some time to discuss those in a next entry.
&lt;p&gt;
When starting the OSGiFX application, an OSGi Framework is created
(I use the &lt;a href="http://knopflerfish.org"&gt;Knopflerfish&lt;/a&gt; framework),
and an &lt;code&gt;org.osgifx.FxServiceListener&lt;/code&gt; instance is registered,
listening for implementations of &lt;code&gt;org.osgifx.view.JavaFxView&lt;/code&gt;
&lt;br&gt;
This interface acts as a bridge between the registered OSGi services and
the OSGiFX application that will manage and display the services.
&lt;code&gt;JavaFxView&lt;/code&gt; is a plain Java Interface, with two methods:
&lt;ul&gt;
&lt;li&gt;getTitle() provides the title of the registered application
&lt;li&gt;getRootNode() provides a javafx node that is the container for all
ui-stuff in the application.
&lt;/ul&gt;
The OSGiFX application maintains a list of registered JavaFxView implementations,
and will display an application when the user clicks on a name --- yes, it is
sort of a Service Browser on top of OSGi.
&lt;p&gt;
&lt;h3&gt;Applications&lt;/h3&gt;
I wrote a silly OSGi bundle that registers a JavaFXView implementation
containing a JavaFX custom node with a nice circle.
&lt;br&gt;
You can find the code and manifest file at
&lt;a href="http://lodgon.com/johan/javafxbundle.tar"&gt;http://lodgon.com/johan/javafxbundle.tar&lt;/a&gt;
Again, I hope to find more time later to document this better, but I think
the code in the BundleActivator is self-explaining:
&lt;pre&gt;
  override function start (bc: BundleContext) {
    println ("[JVDBG] Starting bundledemoactivator");
    var view: MyView = MyView{};
    var impl: JavaFxViewImpl = new JavaFxViewImpl (view);
    var props :Dictionary= new Properties();
    bc.registerService(JavaFxView.class.getName(),impl,props);
  }
&lt;/pre&gt;
The MyView class contains a CustomNode with the circle, and the
JavaFxViewImpl class will return this CustomNode when its getRootNode()
method is called.
&lt;p&gt;
When bundling this code into an OSGi bundle, we have to make sure we import
the needed packages. The JavaFX compiler creates some dependencies on
implementation packages, these should be exported by the OSGiFX platform
and imported by the bundles that rely on them.
&lt;p&gt;
This was a very quick intro to what I have been doing with OSGi and JavaFX,
feel free to mail me if you have questions or remarks (johan at lodgon dot com).
</content><id>http://lodgon.com/eid-441</id><updated>2009-11-24T20:32:47.668+01:00</updated></entry><entry><title>JavaFX and OSGi, part 1</title><link href="http://blogs.lodgon.com/johan/JavaFX_and_OSGi_part_1" rel="alternate"/><author><name>johan</name></author><summary type="html">Integrating new technologies is something that I like. The combination of
&lt;a href="http://javafx.com"&gt;JavaFX RIA technology&lt;/a&gt; and the
&lt;a href="http://osgi.org"&gt;OSGi platform&lt;/a&gt; was on my wish-list for
some time.
The title of this entry contains "part 1" since I assume this is an
ongoing effort.
</summary><content type="html">Integrating new technologies is something that I like. The combination of
&lt;a href="http://javafx.com"&gt;JavaFX RIA technology&lt;/a&gt; and the
&lt;a href="http://osgi.org"&gt;OSGi platform&lt;/a&gt; was on my wish-list for
some time.
The title of this entry contains "part 1" since I assume this is an
ongoing effort.
When combining JavaFX and OSGi, a number of possibilities exist:
&lt;ul&gt;
&lt;li&gt;Install a bundle containing JavaFX code in an OSGi framework
&lt;li&gt;Run an OSGi framework in a JavaFX environment
&lt;/ul&gt;

The first option is described in
&lt;a href="http://sinnema313.wordpress.com/2008/08/01/running-a-javafx-script-from-an-osgi-bundle/"&gt;this blogentry&lt;/a&gt;.
&lt;br&gt;
The second option is very relevant to me, since I hope that there will
be a huge number of devices that come pre-installed with JavaFX. If the
OSGi lifecycle management platform runs on these devices, lots of
nice stuff can be executed on the devices.
&lt;p&gt;
The latest OSGi specification contains a framework launch API. This allows
the framework to be instantiated by third party code. This is cool, since
it allows me to start an OSGi framework without any code change to the
framework implementation code.
&lt;p&gt;
For my proof of concept, I use the &lt;a href="http://knopflerfish.org"&gt;
KnopflerFish&lt;/a&gt; framework from &lt;a href="http://makewave.com"&gt;Makewave&lt;/a&gt;.
This is an Open Source implementation of the OSGi specification, and it is
very readable.
&lt;br&gt;
Running the Knopflerfish framework in JavaFX is not too difficult. You have
to be careful with the threading system of JavaFX though ("don't block the
AWT thread", remember?). I did it this way:
&lt;ul&gt;
&lt;li&gt;The Main.fx class launches the Framework and obtains a reference to the
System Bundle, hence to a BundleContext Object
&lt;li&gt;The BundleContext is used for installing new Bundles and for registering a ServiceListener and a BundleListener. Installing Bundles is done
asynchronously, not in the UI thread.
&lt;li&gt;A JavaFX class implements BundleListener and ServiceListener is notified
on Bundle and Service Events, and some UI component the Main.fx class
reflects the changes.
&lt;/ul&gt;

&lt;p&gt;
This approach leads to 4 classes:
&lt;ul&gt;
&lt;li&gt;Main.fx
&lt;li&gt;BundleInstaller.fx contains the FX code for installing bundles
&lt;li&gt;NativeInstaller.java contains the Java code for installing bundles
&lt;li&gt;FxServiceListener.fx implements both ServiceListener and BundleListener
&lt;/ul&gt;

&lt;p&gt;
Here is the code:
&lt;pre&gt;
package com.lodgon.kfix;

import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Bundle;
import java.util.HashMap;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.TextBox;
import javafx.scene.control.Button;
import javafx.scene.Group;
import javafx.scene.layout.VBox;
import javafx.scene.control.Label;
import javafx.async.Task;

/**
 * @author johan
 */

var urlText: TextBox = TextBox {
    text: "http://xavier.lodgon.com/osgi/log_all-2.0.0.jar"
    width: 282
    selectOnFocus: true
  }

  var installButton: Button = Button {
    translateX: 300;
      text: "install"
      action: function() {
        var installer: BundleInstaller = BundleInstaller {
          bc:bc;
          location:urlText.text;
        }
        installer.start();
      }
    }

  var installGroup: Group = Group {
    translateY:10;
    content: [urlText, installButton];
  }


  public var eventListBox: VBox = VBox {
    translateY:50;
  };



var stage: Stage = Stage {
    title: "Application title"
    width: 450
    height: 180
    scene: Scene {
        content: bind [
            installGroup,
            eventListBox
        ]
    }
  }

var bc: BundleContext;
var listener: FxServiceListener ;

function run () {
  stage;
  var knopflerfish: org.knopflerfish.framework.Main =
  new org.knopflerfish.framework.Main();
  var factory:FrameworkFactory = knopflerfish.getFrameworkFactory();
  var map:HashMap = new HashMap();
  var framework: Framework = factory.newFramework(map);
  framework.init();
  listener = FxServiceListener{};
  bc = framework.getBundleContext();
  bc.addServiceListener (listener);
  bc.addBundleListener (listener);
}

BundleInstaller:
package com.lodgon.kfix;

import javafx.async.JavaTaskBase;

import javafx.async.RunnableFuture;
import org.osgi.framework.BundleContext;

/**
 * @author johan
 */

public class BundleInstaller extends JavaTaskBase {

  public-init var bc: BundleContext;
  public-init var location: String;
  var installer: NativeInstaller;

  override protected function create() : RunnableFuture {
    installer = new NativeInstaller(bc, location);
    return installer;
 }

}
NativeInstaller:

package com.lodgon.kfix;

import javafx.async.RunnableFuture;
import org.osgi.framework.BundleContext;

/**
 *
 * @author johan
 */
public class NativeInstaller implements RunnableFuture {
  private final String location;
  private final BundleContext bc;

  public NativeInstaller (BundleContext bc, String loc) {
    this.bc = bc;
    this.location = loc;
  }

  @Override
  public void run() throws Exception {
    System.out.println ("[JVDBG] I have to install bundle at "+location);
    bc.installBundle(location);
    System.out.println ("[JVDBG] I installed "+location);
  }

}

FxServiceListener:
package com.lodgon.kfix;

import org.osgi.framework.*;
import javafx.scene.control.Label;

/**
 * @author johan
 */
public class FxServiceListener extends ServiceListener, BundleListener {

  override function serviceChanged (evt: ServiceEvent) {
    println ("[KFiX] Service changed: {evt}");
    var label: Label = Label {
        text: "service changed: {evt}"
      }
   insert label into Main.eventListBox.content;
  }

  override function bundleChanged (evt: BundleEvent) {
    println ("[KFiX] Bundle changed: {evt}");
    var label: Label = Label {
        text: "bundle changed: {evt}"
      }
    insert label into Main.eventListBox.content;
  }


}
&lt;/pre&gt;
That's it for now, but I have more ideas...</content><id>http://lodgon.com/eid-432</id><updated>2009-10-05T20:21:44.829+02:00</updated></entry><entry><title>JavaFX location example with GPS</title><link href="http://blogs.lodgon.com/johan/JavaFX_location_example_with_GPS" rel="alternate"/><author><name>johan</name></author><summary type="html">One of the cool things about the JavaFX Mobile platform running on my
HTC Diamond phone, is the easy integration with GPS. In this article,
I will describe the most simple example I could come up with.
</summary><content type="html">One of the cool things about the JavaFX Mobile platform running on my
HTC Diamond phone, is the easy integration with GPS. In this article,
I will describe the most simple example I could come up with.
&lt;p&gt;
I have been working with GPS integration in Java code since more than 10 years
now. In most cases, I had to use the serial io provided in comm.jar
implementations (the one providing javax.comm.SerialPort and others).
Although this worked fine in most of the cases, the
amount of low-level code was high compared with the amount of functional
code.
&lt;br&gt;
I have been a big supporter of JSR 179, the Location API for J2ME. This
API provides a simple way for obtaining locations and it also provides some
common functionality (e.g. proximity listeners).
Until recently, I haven't seen much devices that contained a clean
implementation of this API. But this is changing.
&lt;p&gt;
The &lt;a href="http://javafx.com/downloads/all.jsp"&gt;JavaFX Mobile 1.2 for Windows Mobile&lt;/a&gt; platform contains an implementation of
JSR 179, and it works very well with JavaFX.
&lt;br&gt;
The following code example shows a simple JavaFX example showing the status
of the built-in GPS and the latest known position. It probably violates some
patterns, but the only goal is showing how you can obtain position in
your JavaFX programs.
&lt;p&gt;
&lt;h3&gt;The main class&lt;/h3&gt;
The main class is a typical JavaFX example containing a Stage with a
Scene. The Scene contains 2 Text items. The contents of these text items
are dynamically bound to some variables.
&lt;pre&gt;
package com.lodgon.locationdemo;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;

public var gpsStatus: String = "unknown";
public var lat: Number = 0.0;
public var lon: Number = 0.0;

var stage: Stage = Stage {
    title: "Location demo"
    width: 250
    height: 120
    scene: Scene {
        content: [
            Text {
                font : Font { size : 16 }
                x: 10
                y: 30
                content: bind "gps status: {gpsStatus}"
            },
            Text {
                font : Font { size : 16 }
                x: 10
                y: 50
                content: bind "position: {lat}, {lon}"
            }
        ]
    }
}

function run () {
  stage;
  var processor: LocationProcessor = LocationProcessor{};
  processor.startReading();
}

&lt;/pre&gt;

No magic in here, notice the &lt;code&gt;LocationProcessor&lt;/code&gt; class that
we instantiate and that will do the interaction with the GPS. This
instance will create a &lt;code&gt;javax.microedition.location.LocationProvider&lt;/code&gt;
and register a &lt;code&gt;javax.microedition.location.LocationListener&lt;/code&gt;
with it.
&lt;p&gt;
When the status of the GPS is changed, the &lt;code&gt;providerStateChanged&lt;/code&gt;
method is called. The new status is assigned to the &lt;code&gt;gpsStatus&lt;/code&gt;
variable in the &lt;code&gt;Main&lt;/code&gt; class and shown on the device screen.
&lt;br&gt;
Similarly, when a new position is detected, the &lt;code&gt;locationUpdate&lt;/code&gt;
method is called, and the &lt;code&gt;lat&lt;/code&gt; and &lt;code&gt;lon&lt;/code&gt; variables
in the &lt;code&gt;Main&lt;/code&gt; class are changed.

&lt;pre&gt;
package com.lodgon.locationdemo;
import javax.microedition.location.LocationListener;
import javax.microedition.location.Location;
import javax.microedition.location.LocationProvider;
import javax.microedition.location.QualifiedCoordinates;

public class LocationProcessor extends LocationListener  {

  var provider: LocationProvider;

  public function startReading() {
    provider = LocationProvider.getInstance(null);
    provider.setLocationListener(this, 10, 5, -1);
    providerStateChanged (provider, provider.getState());
  }

  override function locationUpdated(provider: LocationProvider, location: Location) {
    if (location != null) {
      var coords: QualifiedCoordinates = location.getQualifiedCoordinates();
      if (coords != null) {
        var lat = coords.getLatitude();
        var lon = coords.getLongitude();
        println ("[JVDBG] lat = {lat}");
        Main.lat = lat;
        Main.lon = lon;
      }
    }

  }

  override function providerStateChanged(provider: LocationProvider, stat: Integer) {
    if (stat == 1) {
      Main.gpsStatus = "Available";
    }
    if (stat == 2) {
      Main.gpsStatus = "Temporarily Unvailable";
    }
    if (stat == 3) {
      Main.gpsStatus = "Out Of Service";
    }
  }

}

&lt;/pre&gt;

For more information about JSR 179, see the
&lt;a href="http://www.forum.nokia.com/infocenter/index.jsp?topic=/Java_Developers_Library/GUID-4AEC8DAF-DDCC-4A30-B820-23F2BA60EA52/overview-summary.html"&gt;Javadoc&lt;/a&gt; pages. You can easily change the update frequency (currently 10 seconds),
timeout (currently 5 seconds), and other criteria.
Also note that we actually should not do any processing in the interface
callback methods. Since this is a simple example without much processing,
I didn't use the javafx async threading mechanism for simplicity.
</content><id>http://lodgon.com/eid-430</id><updated>2009-09-26T14:09:21.128+02:00</updated></entry><entry><title>Social Networking in Telematics</title><link href="http://blogs.lodgon.com/johan/Social_Networking_in_Telematics" rel="alternate"/><author><name>johan</name></author><summary type="html">I&amp;#39;m on my way back from the ITS 2009 world conference in Stockholm --- see the website of the &lt;a href="http://www.itsworldcongress.com/"&gt; World Contress and Exhibition on Intelligent Transport Systems and Services&lt;/a&gt; for more information about this conference. We were showcasing an application that combines social networking with vehicle telematics. The past few days were really exhausting, but it definitely was worth it. </summary><content type="html">I&amp;#39;m on my way back from the ITS 2009 world conference in Stockholm --- see the website of the  World Contress and Exhibition on Intelligent Transport Systems and Services for more information about this conference. We were showcasing an application that combines social networking with vehicle telematics. The past few days were really exhausting, but it definitely was worth it. &lt;p&gt; Our company &lt;a href="http://lodgon.com"&gt;LodgON&lt;/a&gt; was selected as one of the four finalists of the CVIS Application Contest. &lt;a href="http://cvisproject.org"&gt;CVIS&lt;/a&gt; is a project funded by the European Commission. In this project, a global architecture is defined that allows the creation of cooperative vehicle applications. Developers use the Service Development Kit, based on the OSGi software of &lt;a href="http://makewave.com"&gt;MakeWave&lt;/a&gt; and create their own applications. &lt;/p&gt;&lt;p&gt; The four finalists developed different applications, ranging from pedestrian safety over intelligent agents to the social networking application that we developed. Visitors of the CVIS booth could vote for one of the finalists. We won the silver prize, worth 15.000 EUR. I am happy because we won this prize, and I am unhappy since we didn&amp;#39;t win the gold prize (25.000 EUR). &lt;/p&gt;&lt;p&gt; For LodgON, this conference was also very important since we demonstrated our Dali-based vehicle social networking application. You can find more information about this application &lt;a href="http://lodgon.com/Social_CVIS.html"&gt;at our website&lt;/a&gt;. We have a strong background in Social Networking, and most of the LodgON employees also have a background in Telematics. This combination automatically leads to a Social Networking application for telematics. My main question, though, was if the automotive industry was ready for this kind of applications. I am extremely pleasant surprised that indeed there was a huge interest from conference visitors in our application. Road authorities, car OEM&amp;#39;s, telecom operators, consumer organisations,... they all showed a clear interest in Social Networking, and they definitely do realize the benefits of social networking if it is properly implemented. &lt;/p&gt;&lt;p&gt; With our Social CVIS application, we showed that the research and development we have done during the past years in the field of social networking is really rewarding. We know the ins and outs, the benefits and pittfalls. We realize the importance of social status, we balance between clarity and fine-grained permission models. Social networking is more than having an account on facebook. The return on investment can be huge, but your project can also fail completely if you don&amp;#39;t combine users expectations with the goals of the company/organisation that is behind the project. &lt;br /&gt; We will have some work in the coming weeks, with the follow-up of the new contacts we have (and the re-connection with some old friends). But there are lots of opportunities out there now. &lt;/p&gt;&lt;p&gt; From a technical point of view (and in the end, that is what I am mostly involved with), this project has been fun as well. We combined our experience with OSGi, Glassfish and JavaFX in order to create the prototype. Glassfish is really mature, and more than ready for production. We already knew this, but it&amp;#39;s proven once again. The ease of development and the clear way of operations is worth a lot. The Jersey bundle in Glassfish (yes, we talk bundles since we use Glassfish v3) is one of my favourites, it allows an uncoupled REST-based client-server approach. &lt;br /&gt; We showed 4 clients for our application, one of them being a JavaFX mobile client, using GPS data through JSR 179. I have been working with GPS data often, and in most cases it came down to using the serial COMM port and talking to native GPS drivers. Which is fun for a while. I was extremely happy and positively surprised when I discovered that JavaFX supports JSR 179, and it takes about 10 lines of code in order to read the exact position from my HTC Diamond phone. This is one of the reasons I believe in JavaFX: easy support for real devices. &lt;/p&gt;&lt;p&gt; The telematics, location based social networking server is based on our Dali Community Server. We announced our &lt;a href="http://lodgon.com/Lodgon_releases_daliroadmap_.html"&gt;Dali Roadmap&lt;/a&gt; last week as well, and the positive feedback we got about this application proved to me that we made the right decisions in the development of Dali. &lt;/p&gt;</content><id>http://lodgon.com/eid-429</id><updated>2009-09-25T11:08:46.597+02:00</updated></entry><entry><title>JavaFX chat client with Comet server</title><link href="http://blogs.lodgon.com/johan/JavaFX_chat_client_with_Comet_server" rel="alternate"/><author><name>johan</name></author><summary type="html"> I have written a few entries about a JavaFX chat client and about a Comet Chat engine. Now, I have put together the simplest examples I could come up with.  </summary><content type="html">I have written a few entries about a JavaFX chat client and about a Comet Chat engine. Now, I have put together the simplest examples I could come up with.  &lt;p&gt; Both the ChatServer (using Comet) and the ChatClient (in JavaFX) can be downloaded &lt;a href="http://lodgon.com/johan/cometfx.zip"&gt;here&lt;/a&gt;. &lt;br /&gt; Some remarks: &lt;/p&gt;&lt;h2&gt;Comet based ChatServer&lt;/h2&gt; The &lt;code&gt;ChatServer&lt;/code&gt; directory contains a Netbeans project that uses Comet in GlassFish v2. If you want to run this example in GlassFish v3, you have to change the package name &lt;code&gt; com.sun.enterprise.web.connector.grizzly.comet; &lt;code&gt; into &lt;code&gt; com.sun.grizzly.comet.CometContext &lt;/code&gt;.  The ChatServer contains 3 classes: &lt;/code&gt;&lt;/code&gt;&lt;h3&gt;ChatEntry&lt;/h3&gt; This is a POJO, containing the information about chat entries (only a username and a text are used). &lt;h3&gt;ChatServlet&lt;/h3&gt; This is the entry point for clients. Comet initialization is done in the &lt;code&gt;init(ServletConfig config)&lt;/code&gt; method. Incoming requests have a parameter &lt;code&gt;method&lt;/code&gt;. This parameter can have two values: &lt;em&gt;listen&lt;/em&gt; and &lt;em&gt;chat&lt;/em&gt;. &lt;h4&gt;listen&lt;/h4&gt; A new CometHandler is created, and the PrintWriter of the &lt;code&gt;HttpServletResponse&lt;/code&gt; is attached to the &lt;code&gt;CometContext&lt;/code&gt; When new chat entries are received, the CometHandler will send the content to the attached writer. &lt;h4&gt;chat&lt;/h4&gt; An incoming chat entry is received. The CometContext is notified about this event, and it will send the chat text to all registered listeners. &lt;h3&gt;ChatHandler&lt;/h3&gt; This is our implementation of the &lt;code&gt;CometHandler&lt;/code&gt;. When a client starts listening, a new instance of the &lt;code&gt;ChatHandler&lt;code&gt; is created, and the &lt;code&gt;PrintWriter&lt;/code&gt; connected to the ServletResponse is stored. When new chat entries are received, the &lt;code&gt;onEvent&lt;/code&gt; method will be called, and the chat text will be written to the &lt;code&gt;PrintWriter&lt;/code&gt; instance.  &lt;/code&gt;&lt;/code&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h2&gt;JavaFX ChatClient&lt;/h2&gt; The ChatClient is slightly more complicated. See &lt;a href="http://blogs.lodgon.com/johan/JavaFX_12_asynchronous_chat_client"&gt;one of my previous blog entries&lt;/a&gt; for a detailed description of a JavaFX chat client. The example described in today&amp;#39;s entry is simplified a bit. We don&amp;#39;t use a separate class for writing new chat entries, but we use the &lt;code&gt;HttpRequest&lt;/code&gt; for calling a url containing the chat entry information. We can&amp;#39;t use the same approach for reading incoming chat entries, since the &lt;code&gt;onInput&lt;/code&gt; function of the &lt;code&gt;HttpRequest&lt;/code&gt; is only called when &lt;em&gt;all&lt;/em&gt; input has been read. The existing &lt;code&gt;javafx.data&lt;/code&gt; packages are very suitable for reading message-based content (i.e. RSS feeds), but not for streaming. Hence, we created a mechanism where a callback interface (&lt;code&gt;ChatInput&lt;/code&gt; is called each time the InputStream receives a new chat entry). This is done by means of the &lt;code&gt;FXReader&lt;/code&gt; JavaFX class and the &lt;code&gt;AsyncReader&lt;/code&gt; java class. Again, for implementation details have a look at my &lt;a href="http://blogs.lodgon.com/johan/JavaFX_12_asynchronous_chat_client"&gt;previous blog entry&lt;/a&gt;. &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt; At &lt;a href="http://lodgon.com"&gt;LodgON&lt;/a&gt;, we are working on a product that contains chat functionality. It is more complex than the example we&amp;#39;ve shown here, i.e. the chat can be moderated, users can have different roles, documents can be shown,... . The basic principles of the chat interactions are the same, though. &lt;/p&gt;</content><id>http://lodgon.com/eid-423</id><updated>2009-09-14T12:23:30.738+02:00</updated></entry><entry><title>Data accuracy, a killer app?</title><link href="http://blogs.lodgon.com/johan/Data_accuracy_a_killer_app" rel="alternate"/><author><name>johan</name></author><summary type="html">I am one of the 992.653 (and counting) followers of Tim O&amp;#39;Reilly&amp;#39;s twitter. O&amp;#39;Reilly tweets very often about &amp;quot;cool stuff&amp;quot;. That makes it hard for me to distinguish the real cool stuff from the &amp;quot;nice tries&amp;quot;. But one tweet about &amp;quot;the killer app for Apps for America&amp;quot; took my attention. It is about data integrity for government data. </summary><content type="html">I am one of the 992.653 (and counting) followers of Tim O&amp;#39;Reilly&amp;#39;s twitter. O&amp;#39;Reilly tweets very often about &amp;quot;cool stuff&amp;quot;. That makes it hard for me to distinguish the real cool stuff from the &amp;quot;nice tries&amp;quot;. But one tweet about &amp;quot;the killer app for Apps for America&amp;quot; took my attention. It is about data integrity for government data. &lt;p&gt; The article O&amp;#39;Reilly is referring to can be found at the &lt;a href="http://sunlightlabs.com/blog/2009/08/27/dealing-inaccurate-government-data/"&gt;Sunlight Labs blog&lt;/a&gt;. The bottom line is that the accuracy of (government) data is extremely important and is often beyond developer scope. The article lists three ways to improve data accuracy: &lt;/p&gt; &lt;p&gt;1.Make Data Imports Modular and Reusable &lt;/p&gt; &lt;p&gt;2.Create tests on the regulations around the data &lt;/p&gt; &lt;p&gt;3.Provide a way for users to report inaccuracies &lt;/p&gt;   The first and second way are pretty well known in software development -- although often being ignored in government projects I am aware off, because the requirements in government projects are mostly non-technical. &lt;br /&gt; The third way is still rare, although we see a growing interest in this concept. Allowing people to report inaccuracies is often hard, since this basically means that you admit that you might be wrong. And this is something that many customers/organizations still don&amp;#39;t want to hear. However, the benefits of using the community to improve the quality of data are huge --- depending on the nature of your community and data of course. Especially when large amounts of public data are the core of a project, it definitely helps to let the user report about the data quality. This goes further than reporting &amp;quot;inaccuracies&amp;quot; though, users can also indicate their importance or appreciation about particular data. &lt;p&gt; An interesting example is data related to road and street conditions. At least in the country where I live in, government bodies are responsible for keeping road signs visible, making sure there are no dangerous road conditions and so on. But this requires intensive checks from a number of people. A missing sign will probably be spot by hundreds of people before it is seen by the government body. &lt;br /&gt; It would be easier and cheaper if one of the hundreds of people that saw the defect earlier reports this problem online or via an in-car device, PDA or mobile phone. If this is where the software stops, the data quality is unlikely to improve. There will be quite a lot of funny people that will report unmissing stuff as missing. We would use strong authentication and written agreements about punishment for fake reports, but this will scare many people. In many cases, the community can regulate itself. Good citizens will be recognized and rewarded, bad behavior will be filtered as spam. I recently reviewed the book &lt;a href="http://www.manning.com/marmanis/"&gt; Algorithms of the Intelligent Web&lt;/a&gt;, and this contains a number of technologies that can be used to improve the quality of data based on user behavior and algorithms. &lt;br /&gt; Apart from the algorithms, there is a social aspect. In communities, users want to be recognized and appreciated. An implicit or explicit &amp;quot;ranking&amp;quot; amongst users can motivate them to be &amp;quot;good citizens&amp;quot;. Good behavior is rewarded by an increase in ranking, bad behavior cause a drop in ranking. &lt;/p&gt;&lt;p&gt; My conclusion is that the quality of data can often be improved by software, a dramatic improved comes from the right combination of community software and human community development.                                                  &lt;/p&gt;</content><id>http://lodgon.com/eid-411</id><updated>2009-08-27T22:21:03.404+02:00</updated></entry><entry><title>Development and source code</title><link href="http://blogs.lodgon.com/johan/Development_and_source_code" rel="alternate"/><author><name>johan</name></author><summary type="html">A quick one. Some people think that I use the latest version of software just for fun. Not. Well, it is fun of course, but it speeds up my development considerably. Read on for an example.</summary><content type="html">&lt;p&gt;A quick one. Some people think that I use the latest version of software just for fun. Not. Well, it is fun of course, but it speeds up my development considerably. Read on for an example.&lt;/p&gt;&lt;p&gt;I am developing some OSGi/JavaEE code under GlassFish v3. When starting a bundle, &amp;quot;it didn&amp;#39;t work&amp;quot;, During development, I *always* have the server.log file open (tail -f /opt/glassfish/glassfish/domains/domain1/logs/server.log should be under F1). I saw this error:&lt;/p&gt;&lt;p&gt;&amp;nbsp;[#|2009-08-13T21:16:06.549+0200|SEVERE|glassfish|org.apache.catalina.loader.WebappLoader|_ThreadID=19;_ThreadName=Thread-2;|LifecycleException&lt;br /&gt;java.lang.NullPointerException&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.util.StringTokenizer.&amp;lt;init&amp;gt;(StringTokenizer.java:182)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.util.StringTokenizer.&amp;lt;init&amp;gt;(StringTokenizer.java:204)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.glassfish.web.osgi.OSGiDeploymentContextImpl$2.convert(OSGiDeploymentContextImpl.java:153)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.glassfish.web.osgi.OSGiDeploymentContextImpl$2.getURLs(OSGiDeploymentContextImpl.java:147)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.catalina.loader.WebappLoader.setClassPath(WebappLoader.java:1204)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.catalina.loader.WebappLoader.start(WebappLoader.java:736)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.catalina.core.StandardContext.start(StandardContext.java:5187)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.enterprise.web.WebModule.start(WebModule.java:509)&lt;/p&gt;&lt;p&gt;Ok, so what do you do when you have this? I can only think about one possibility:&lt;/p&gt;&lt;p&gt;cd glassfish/svn/v3&lt;/p&gt;&lt;p&gt;find . -name OSGiDeploymentContextImpl.java&lt;/p&gt;&lt;p&gt;Aha, there is the file. Open it. (with vi, can be NetBeans too though). Look at line 153, and there it is:&lt;/p&gt;&lt;p&gt;&amp;nbsp;StringTokenizer entries = new StringTokenizer(bcp, &amp;quot;,;&amp;quot;);&lt;/p&gt;&lt;p&gt;Where bcp is a String that is passed with the value of Constants.BUNDLE_CLASSPATH&lt;/p&gt;&lt;p&gt;Whoops, looking at my manifest-file, and indeed, I supplied &amp;quot;Bundle-Classpath&amp;quot; instead of &amp;quot;Bundle-ClassPath&amp;quot;,&lt;/p&gt;&lt;p&gt;Took me less than 5 minutes to discover, fix and redeploy. How can you do this if you don&amp;#39;t have the source code of the tool/appserver you&amp;#39;re using? &lt;/p&gt;</content><id>http://lodgon.com/eid-403</id><updated>2009-08-13T21:30:26.857+02:00</updated></entry><entry><title>Is it a Module or a Bundle? Both, in GlassFish v3</title><link href="http://blogs.lodgon.com/johan/Is_it_a_Module_or_a_Bundle_Both_in_GlassFish_v3" rel="alternate"/><author><name>johan</name></author><summary type="html">With GlassFish v3, developers can deploy their software as traditional modules (jars and wars), but also as OSGi Bundles. Even more: one jar can be a Web Archive and an OSGi Bundle at the same time. It reminds me of the question whether light is a particle or a wave phenomena. It is both, depending on how you look at it. </summary><content type="html">With GlassFish v3, developers can deploy their software as traditional modules (jars and wars), but also as OSGi Bundles. Even more: one jar can be a Web Archive and an OSGi Bundle at the same time. It reminds me of the question whether light is a particle or a wave phenomena. It is both, depending on how you look at it. &lt;p&gt; I blogged about this more than a year ago. &lt;a href="http://glassfish.dev.java.net"&gt;GlassFish v3&lt;/a&gt; is not just an evolution, it is a revolutionary concept. Of course, it is also the reference implementation for the Java Enterprise specification, so it does not break the good tradition of GlassFish v2 by providing a first class Java EE compliant Application Server. &lt;br /&gt; But you can also deploy &lt;a href="http://osgi.org"&gt;OSGi bundles&lt;/a&gt; in GlassFish v3 (you should download the latest promoted build if possible, since this technology is evolving rapidly). And that opens new possibilities --- including some cans of worms, more possibilities lead to more opportunities to screw up. &lt;a href="http://weblogs.java.net/blog/ss141213/archive/2009/06/developing_hybr.html"&gt;This blogentry&lt;/a&gt; by &lt;a href="http://weblogs.java.net/blog/ss141213/"&gt;Sahoo&lt;/a&gt; is a good starting point to experiment with the dual behavior of applications in GlassFish v3. Sahoo uses the term &amp;quot;hybrid application&amp;quot; for an application that both uses Java EE and OSGi. I also recommend reading &lt;a href="http://blogs.sun.com/dochez/"&gt;Jerome&amp;#39;s blog&lt;/a&gt;. He provides some examples about using OSGi Declarative Services in GlassFish v3. &lt;/p&gt;&lt;p&gt; There are some distinctions and some minor overlaps between the OSGi goals and the Java EE goals. OSGi provides the modularity and the lifecycle management where the Java Enterprise specifications provide the traditional enterprise functionalities as persistence, transaction support, resource management. &lt;br /&gt; The mental coin flipping that is happening inside my developer head is whether my applications are now OSGi applications that leverage the Java Enterprise functionality, or are they Java Enterprise applications that benefit from the OSGi modular system? The combined functionality of both worlds offers lots of opportunities, but will also give birth to new patterns, do&amp;#39;s and dont&amp;#39;s. These are exciting times. &lt;/p&gt;</content><id>http://lodgon.com/eid-401</id><updated>2009-08-12T14:15:20.533+02:00</updated></entry></feed>