<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MuddyHorse Farm and Tech &#187; java</title>
	<atom:link href="http://blog.muddyhorse.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.muddyhorse.com</link>
	<description>Where animals and technology collide</description>
	<lastBuildDate>Sat, 04 Sep 2010 03:57:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel="next" href="http://blog.muddyhorse.com/tag/java/feed/?page=2" />

		<item>
		<title>Android Development Quick-start</title>
		<link>http://blog.muddyhorse.com/2010/06/android-development-quick-start/</link>
		<comments>http://blog.muddyhorse.com/2010/06/android-development-quick-start/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 15:24:30 +0000</pubDate>
		<dc:creator>pforhan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://blog.muddyhorse.com/?p=341</guid>
		<description><![CDATA[I&#8217;m trying to pick up a bit of Android development experience. Here&#8217;s some tips for getting started from scratch.  I have a lot to learn&#8230; Documentation and Tutorials What is Android? &#8212; Quick start on architecture . Application Fundamentals &#8212; Terminology and Components Hello, World tutorial &#8212; very basic tutorial Notepad tutorial &#8212; nice tutorial [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to pick up a bit of Android development experience.  Here&#8217;s some tips for getting started from scratch.  I have a lot to learn&#8230;<span id="more-341"></span></p>
<h1>Documentation and Tutorials</h1>
<p style="padding-left: 30px;"><a href="http://developer.android.com/guide/basics/what-is-android.html">What is Android?</a> &#8212; Quick start on architecture .</p>
<p style="padding-left: 30px;"><a href="http://developer.android.com/guide/topics/fundamentals.html">Application Fundamentals</a> &#8212; Terminology and Components</p>
<p style="padding-left: 30px;"><a href="http://developer.android.com/resources/tutorials/hello-world.html">Hello, World tutorial</a> &#8212; very basic tutorial<a href="http://developer.android.com/resources/tutorials/notepad/index.html"></a></p>
<p style="padding-left: 30px;"><a href="http://developer.android.com/resources/tutorials/notepad/index.html">Notepad tutorial</a> &#8212; nice tutorial with &#8220;problems&#8221; to work though, as well as a clear goal.  Demonstrates different parts of an app&#8217;s lifecycle.</p>
<h1>Development Set-Up</h1>
<p>You&#8217;ll have to go through several steps to get a fully working development environment.  Start with the <a href="http://developer.android.com/sdk/index.html">Android SDK</a>.  Download to somewhere reasonable, then cd into {android&#8217;s home}/tools and run android.  This brings up the SDK/AVD manager, which can pull down samples, documentation, and runtime environments for the different Android versions.  It also is where you set up and launch the device emulators.</p>
<p>Get the <a href="http://developer.android.com/sdk/eclipse-adt.html">Eclipse plug-in for Android</a> next, if you like that sort of thing.  Be sure to configure the SDK location in your preferences.  Note that you can launch the SDK/AVD manager right out of Eclipse, if you like.  If you don&#8217;t want to use the plug in, be sure to check the documentation for the <a href="http://developer.android.com/guide/developing/other-ide.html">command-line tools</a>, which can do many (if not all) of the Eclipse plugin&#8217;s functions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muddyhorse.com/2010/06/android-development-quick-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Clumsy Pattern: Software Development</title>
		<link>http://blog.muddyhorse.com/2010/02/the-clumsy-pattern-software-development/</link>
		<comments>http://blog.muddyhorse.com/2010/02/the-clumsy-pattern-software-development/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 14:30:48 +0000</pubDate>
		<dc:creator>pforhan</dc:creator>
				<category><![CDATA[The Clumsy Pattern]]></category>
		<category><![CDATA[archaic]]></category>
		<category><![CDATA[clumsy]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://blog.muddyhorse.com/?p=295</guid>
		<description><![CDATA[I haven&#8217;t formulated exactly what I&#8217;m going to say, but I wanted to start a series on the Clumsy pattern in software development.  Don&#8217;t get excited, I&#8217;m neither adopting patterns as a beloved thing (that sentence needs its own post), nor am I trying to establish a new industry term.  I&#8217;ll do a Clumsy Pattern [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t formulated exactly what I&#8217;m going to say, but I wanted to start a series on the Clumsy pattern in software development.  Don&#8217;t get excited, I&#8217;m neither adopting patterns as a beloved thing (that sentence needs its own post), nor am I trying to establish a new industry term.  I&#8217;ll do a Clumsy Pattern post when I come across things that are so archaic or broken that they have no right still existing.<span id="more-295"></span></p>
<p>Another way of putting it is that I&#8217;m ashamed of the state of our industry, in these cases.  It may be inertia, or the teams I&#8217;m on, or anything, but I still have to fight it, understand it.  These things are what we should be laughing about, when talking about  the bad old days.</p>
<p>I have some thing swirling in my head&#8230; part of this may be the continuation of the <a href="http://blog.muddyhorse.com/2009/02/java-build-systems-part-2-maven/">Java Build Systems posts</a> I had earlier, and more.  Next two entries, I think: Java and ORM, Java and the Web.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muddyhorse.com/2010/02/the-clumsy-pattern-software-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Podcast Rotation</title>
		<link>http://blog.muddyhorse.com/2010/01/podcast-rotation/</link>
		<comments>http://blog.muddyhorse.com/2010/01/podcast-rotation/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 15:00:12 +0000</pubDate>
		<dc:creator>pforhan</dc:creator>
				<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[podcasts]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.muddyhorse.com/?p=267</guid>
		<description><![CDATA[I just wanted to capture the current set of podcasts I listen to. I commute two hours a day, and this set keeps me lightly stocked &#8212; Sometimes I run out for a day or two, and I rarely fall behind. This is my current gold-standard set of podcasts: Here are some podcasts I&#8217;ve just [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to capture the current set of podcasts I listen to.  I commute two hours a day, and this set keeps me lightly stocked &#8212; Sometimes I run out for a day or two, and I rarely fall behind.</p>
<p><span id="more-267"></span>This is my current gold-standard set of podcasts:<br />

<table id="wp-table-reloaded-id-1-no-1" class="wp-table-reloaded wp-table-reloaded-id-1">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">Podcast / RSS Link</th><th class="column-2">Category</th><th class="column-3">Average Length</th><th class="column-4">Description</th>
	</tr>
</thead>
<tbody class="row-hover">
	<tr class="row-2 even">
		<td class="column-1"><a href="http://feeds.feedburner.com/MajorNelsonblogcast">Major Nelson Radio</a></td><td class="column-2">Gaming</td><td class="column-3">1:15 - 2:00</td><td class="column-4">Gaming podcast, focussed almost exclusively on the Xbox 360.  Interviews and news.</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1"><a href="http://scripts.ign.com/rss/ign.podcasts.2.0.xml">IGN Games Podcasts</a></td><td class="column-2">Gaming</td><td class="column-3">0:40 - 1:15</td><td class="column-4">I listen to the following podcasts from this RSS:<br />
Game Scoop (all around gaming news)<br />
Three Red Lights (ostensibly 360, often silly)<br />
Nintendo Voice Chat (Wii / DS)<br />
Command Prompt (PC Gaming)</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1"><a href="http://feeds.ign.com/ignfeeds/podcasts/entertainment/">IGN Entertainment Podcasts</a></td><td class="column-2">Television / Movies / Technology</td><td class="column-3">0:40 - 1:00</td><td class="column-4">I only currently listen to Channel Surfing, but occasionally there are other interesting podcasts</td>
	</tr>
	<tr class="row-5 odd">
		<td class="column-1"><a href="http://www.bungie.net/podcast/bungiepodcast.xml">Bungie Podcast</a><br />
</td><td class="column-2">Gaming</td><td class="column-3">1:30 - 2:00</td><td class="column-4">Bungie studios talking mostly about Halo.  Note:  Not bleeped, not filtered.</td>
	</tr>
	<tr class="row-6 even">
		<td class="column-1"><a href="http://rampancy.net/podcast/angersadnessenvy">Anger, Sadness, Envy</a><br />
</td><td class="column-2">Gaming</td><td class="column-3">1:15 - 1:45</td><td class="column-4">Rampancy.net's podcast discussing all things halo.  Fun deep dives into story and gameplay.</td>
	</tr>
	<tr class="row-7 odd">
		<td class="column-1"><a href="http://dealnews.com/rss/516-">The Dealnews Podcast</a></td><td class="column-2">Technology, Consumer News</td><td class="column-3">0:40 - 1:00</td><td class="column-4">A medium-length, somewhat lighthearted take on tech news and product deals.</td>
	</tr>
	<tr class="row-8 even">
		<td class="column-1"><a href="http://feeds.feedburner.com/javaposse">The Java Posse</a></td><td class="column-2">Programming</td><td class="column-3">1:00 - 1:30</td><td class="column-4">Java and JVM news and sessions</td>
	</tr>
</tbody>
</table>
<br />
Here are some podcasts I&#8217;ve just started listening to and am still evaluating:</p>

<table id="wp-table-reloaded-id-2-no-1" class="wp-table-reloaded wp-table-reloaded-id-2">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">Podcast / RSS</th><th class="column-2">Category</th><th class="column-3">Average Length</th><th class="column-4">Description</th>
	</tr>
</thead>
<tbody class="row-hover">
	<tr class="row-2 even">
		<td class="column-1"><a href="http://www.twiandroid.com/?feed=rss2">This Week in Android</a></td><td class="column-2">Mobile</td><td class="column-3">?</td><td class="column-4">News and interview regarding Android phones and OS.  Just got started.</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1"><a href="http://feeds.feedburner.com/ThisAintYourDadsJava">This Ain't Your Dad's Java</a></td><td class="column-2">Programming, JavaFX</td><td class="column-3">1:00 - 1:30</td><td class="column-4">News and comments about JavaFX</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1"><a href="http://feeds.feedburner.com/LibrivoxCommunityPodcast">Librivox Community Podcast</a></td><td class="column-2">Audio Books</td><td class="column-3">?</td><td class="column-4">Community thoughts from the Librivox audio book site</td>
	</tr>
	<tr class="row-5 odd">
		<td class="column-1"><a href="http://www.npr.org/rss/podcast.php?id=510221">NPR Science Friday</a></td><td class="column-2">Science and Technology</td><td class="column-3">?</td><td class="column-4">Segments from NPR's Talk of the Nation Science Fridays</td>
	</tr>
	<tr class="row-6 even">
		<td class="column-1"><a href="http://www.npr.org/rss/podcast.php?id=5">NPR Talk of the Nation</a></td><td class="column-2">News</td><td class="column-3">?</td><td class="column-4">Segments from NPR's Talk of the Nation</td>
	</tr>
	<tr class="row-7 odd">
		<td class="column-1"><a href="http://marketplace.publicradio.org/RSS/mmr_full.xml">Marketplace Morning Report</a></td><td class="column-2">Financial News</td><td class="column-3">0:08</td><td class="column-4">Short but dense financial news</td>
	</tr>
</tbody>
</table>

]]></content:encoded>
			<wfw:commentRss>http://blog.muddyhorse.com/2010/01/podcast-rotation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java Build Systems, Part 2: Maven</title>
		<link>http://blog.muddyhorse.com/2009/02/java-build-systems-part-2-maven/</link>
		<comments>http://blog.muddyhorse.com/2009/02/java-build-systems-part-2-maven/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 20:39:21 +0000</pubDate>
		<dc:creator>pforhan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[java-build-systems]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://blog.muddyhorse.com/?p=165</guid>
		<description><![CDATA[Continuing the Java build systems discussion, today I want to focus on Maven, what it does well and what it does that frustrates.  We&#8217;ll get a little taste of the minimum expectations for a new build system as well.  Note:  this page may be subject to edits, as I come across more pros &#38; cons [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the <a href="http://blog.muddyhorse.com/?tag=java-build-systems">Java build systems discussion</a>, today I want to focus on Maven, what it does well and what it does that frustrates.  We&#8217;ll get a little taste of the minimum expectations for a new build system as well.  Note:  this page may be subject to edits, as I come across more pros &amp; cons of Maven.</p>
<p><span id="more-165"></span><strong>What Maven does right</strong></p>
<p>Maven teaches us several important things about what we need from a build system.</p>
<ul>
<li><em>Convention over configuration. </em> Maven strongly encourages developers to put source files, resources, tests, and project metadata in standard locations.  Maven make life very difficult for anyone deviating from the norms.  In general, this is good, helps teamwork and collaboration, and helps for picking up a project cold.</li>
<li><em>Defaults just work.</em> Similar to the last entry, if you follow maven standards, then it works fine and has a reasonable assumption of defaults.</li>
<li><em>Dependency Management.</em> Probably the single best feature of Maven and modern build tools.  This allows a developer to specify requirements for a project without having to directly specify the physical location of those library dependencies.  This frees the build system to resolve from the network, automatically check for updates, and manage multiple versions of libraries.</li>
<li><em>Plugins</em>.  Easy extensibility is key to Maven.  In fact, most of its internals actually exist as plugins, from compilation to Ant support to deployment.  The ability to add new, custom behavior and have it tie into your builds is fantastic.</li>
</ul>
<p><strong>What Maven does wrong</strong></p>
<p>There are some pretty big gotchas in Maven.  Nothing insurmountable, but frustrating nonetheless.  And before you say &#8220;It&#8217;s open source, fix it yourself!&#8221; know that it is not that simple.  There may be resistance to a certain change, for example, from &#8220;the establishment&#8221; or some issues and Maven&#8217;s solutions are fundamentally tricky.</p>
<ul>
<li><em>Outside the ordinary is very hard.</em> Doing anything beyond the standard use cases requires an arcane knowledge of plugins.  All of a sudden, Maven&#8217;s configuration-based approach falls down, and things become easier to do in code &#8212; ie, you have to write a plugin.  But don&#8217;t think you can use the nifty <a href="http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html">ant-scripted mojos</a> for that plugin&#8211; for example, for compilation, there isn&#8217;t a standard way to get the classpath into the ant script.</li>
<li><em>Dependency Management.</em> Yep, the same benefit is a detriment.  Or, at the very least, Maven&#8217;s handling of it.  Several things fall in here.  The ones I can recall are:
<ul>
<li>Transitive dependencies prove very tricky and make for lots of classloading troubles.  Adding a single dependency to a POM can really change the entire dependency graph of  a project.</li>
<li>There is no way to simply say &#8220;I want the latest of library XX&#8221;.  On the one hand, Maven makes sense here; you should usually know exactly which version of software you are building against.  But there are cases, for example, due to a lack of maturity, where having to know that version number is just an annoyance.  Ivy apparently has an intermediate option here, where you can specify latest, but when a build happens, it records what that version was.</li>
</ul>
</li>
<li><em>Long-standing bugs.</em> Maven suffers a bit from what other mature open-source products hit upon.  Whether it is loss of momentum for something that works well enough or that too many are depending on the quirks, there are lots of oddities and issues left in core plugins.  A perfect example is maven-antrun-plugin, which only sets its classpath once per maven run, regardless of how many POMs reference it.</li>
<li><em>Documentation bugs.</em> Some of the Maven docs are a bit light on details.  Part of it may be Maven&#8217;s built-in site creation, which leads to some sites that have lots of links but are pretty information-sparse.  Other times, many common scenarios are presented, but some of the edge cases are glossed over.  Related:  looking for a list of available Maven properties for use in your POM is tricky because of Maven&#8217;s dynamic nature.  But a simple guide describing common ones and how to construct others would be great.</li>
</ul>
<p><strong>Summary</strong></p>
<p>Generally, what Maven teaches us is that you need to fully embrace Maven to get the full benefit of Maven.  Once you get the hang of the Maven way, things go much more smoothly.  That is not unexpected, but it is uncomfortable.  But there are times where you have to fight &#8212; deploying to multiple load-balanced servers, for example, and you end up with some nasty scripts and configuration on top of a previously elegant solution.</p>
<p>The important thing is, though, that Maven does work.  It&#8217;s not too much of a bear to get started with, has great defaults, and it has some compelling solutions to annoying problems.</p>
<p>So, can Maven be fixed?  Should it be fixed, or should a build system start from scratch?  More on that next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muddyhorse.com/2009/02/java-build-systems-part-2-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven + OSGi + Spring + JavaFX (+Ant)</title>
		<link>http://blog.muddyhorse.com/2009/02/maven-osgi-spring-javafx-ant/</link>
		<comments>http://blog.muddyhorse.com/2009/02/maven-osgi-spring-javafx-ant/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 21:46:50 +0000</pubDate>
		<dc:creator>pforhan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[javafx]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[osgi]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.muddyhorse.com/?p=174</guid>
		<description><![CDATA[We had to go through a number of steps to support the combination of Maven + OSGi + Spring + JavaFX-1.1 in our Swing-based application. This document describes all the steps and technology we&#8217;ve gone through to get it working. ! With JavaFX 1.2, some of the steps have changed. I will post a new [...]]]></description>
			<content:encoded><![CDATA[<p>We had to go through a number of steps to support the combination of Maven + OSGi + Spring + JavaFX-1.1 in our Swing-based application.  This document describes all the steps and technology we&#8217;ve gone through to get it working.</p>
<h3><span id="more-174"></span>! With JavaFX 1.2, some of the steps have changed.  I will post a new entry covering the differences shortly.</h3>
<h1>Build / Compile</h1>
<p>We use Maven as our build system, so JavaFX compilation must coexist with these.</p>
<h3>Upload Dependencies to a Maven repository</h3>
<p>First, we took every single Jar file in the JavaFX SDK 1.1 and uploaded them into Nexus, our development Maven repository.  We took all jars from lib/shared and lib/desktop, uploaded them with groupID of javafx, artifactID matching the Jar name, version 1.1.</p>
<h3>Building alongside Java code</h3>
<p>To combat an explosion of modules, we determined that we wanted to have a src/main/fx source folder that is compiled and used right alongside src/main/java and src/main/resources.  Furthermore, the JavaFX code needs to be able to refer to classes and interfaces in the same module as well as in any maven dependencies.</p>
<p>Our first attempt was to use the seemingly perfect fit, the <a rel="nofollow" href="http://m2-javafxc.sourceforge.net/">m2-javafxc maven plugin</a>.  Early attempts seemed workable, but things started to fall apart and we had to abandon.  Here are some of the issues:</p>
<ol>
<li>m2-javafxc is based on the maven-plexus-compiler.  This compiler will only run once per module.  So we were unable to have src/main/java and src/main/fx side-by-side</li>
<li>m2-javafxc filters out anything other than .fx files.  So we couldn&#8217;t have java and fx intermingled inside a single source folder.</li>
<li>Unfortunately, m2-javafxc is supported by only one individual, and barely used by the community.  While the codebase is not large or complicated, this does represent a bit of a risk.</li>
</ol>
<p>Next, we we noticed that the SDK includes an ant task, something easily runnable in maven.  So, we built up a working ant script.  If you look carefully, you will notice it takes three parameters.  These are covered below.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;compile-jfx&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #000066;">xmlns:artifact</span>=<span style="color: #ff0000;">&quot;urn:maven-artifact-ant&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;compile.jfx&quot;</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">&quot;check-if-should-build&quot;</span> <span style="color: #000066;">if</span>=<span style="color: #ff0000;">&quot;should-build&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;javafxc.class.path&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${localRepo}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;javafx/**/${javafx.version}/*-${javafx.version}.jar&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pathelement</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;${compile.classpath}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;localRepo: ${localRepo}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;jfx ver: ${javafx.version}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;compiler.class.path&quot;</span> <span style="color: #000066;">refid</span>=<span style="color: #ff0000;">&quot;javafxc.class.path&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;jfxc classpath: ${compiler.class.path}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #808080; font-style: italic;">&lt;!-- create output directories: --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;target/fxclasses&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;target/classes&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;target/clover/classes&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;javafxc-ant-task.properties&quot;</span> <span style="color: #000066;">classpathref</span>=<span style="color: #ff0000;">&quot;javafxc.class.path&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;javafxc</span> <span style="color: #000066;">srcdir</span>=<span style="color: #ff0000;">&quot;src/main/fx&quot;</span> <span style="color: #000066;">destdir</span>=<span style="color: #ff0000;">&quot;target/fxclasses&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;**/*.fx&quot;</span> <span style="color: #000066;">compilerclasspath</span>=<span style="color: #ff0000;">&quot;${compiler.class.path}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #808080; font-style: italic;">&lt;!-- copy output files to two places to deal with clovery issues: --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;target/fxclasses&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;fxclasses&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">&quot;target/classes&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">refid</span>=<span style="color: #ff0000;">&quot;fxclasses&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/copy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">&quot;target/clover/classes&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">refid</span>=<span style="color: #ff0000;">&quot;fxclasses&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/copy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;check-if-should-build&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;available</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;src/main/fx&quot;</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;should-build&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;should-build: ${should-build}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>To integrate into maven, we use the following snippet.  It ties into the standard lifecycle, as you see, and happens just after src/main/java is compiled.  It supplies three parameters to the ant script:</p>
<ul>
<li>compile.classpath &#8212; the modules&#8217;s dependecy classpath</li>
<li>localRepo &#8212; the root of the local repository</li>
<li>javafx.vesion &#8212; the version of JavaFX to build with.</li>
</ul>
<p>The last two parameters are used in the script to build the classpath to insure all the JavaFX libraries are present during compilation.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-antrun-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ant-process-classes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>compile<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;compile.classpath&quot;</span> <span style="color: #000066;">refid</span>=<span style="color: #ff0000;">&quot;maven.compile.classpath&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;localRepo&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${settings.localRepository}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;javafx.version&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${javafx.version}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ant</span> <span style="color: #000066;">antfile</span>=<span style="color: #ff0000;">&quot;javafxc.build.xml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;compile.jfx&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ant<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>run<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #808080; font-style: italic;">&lt;!-- needed to compile javafx --&gt;</span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafxc<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafxrt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>scenario<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h3>Working Around Bugs</h3>
<h4>Ant Mojo</h4>
<p>Next, we tried to wrap the above into a Maven plugin via the nifty <a rel="nofollow" href="http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html">Ant script-driven Mojo</a> concept.  However, I could not specify dependencies as I could with a Java mojo, and I was unable to get maven to pass the compile classpath into the script</p>
<h4>maven-antrun-plugin</h4>
<p>It turns out, if you have a multimodule project (we do) and you have multiple invocations of maven-antrun-plugin, the classpath gets set once, by the first run.  We had the choice of putting every dependency on every antrun, or the light hack of having an empty antrun in the parent project with every dependency specified.</p>
<h4>Clover</h4>
<p>When doing a build that includes Clover numbers, clover changes the build classpath to include the artifact with the clover classifier instead of the regular one.  We were putting our result classes directly into target/classes</p>
<h4>javafxc crash</h4>
<p>A dependency on org.apache.felix:org.osgi.compendium will cause the javafxc ant task to crash, hard, with a JVM dump.  I suspect it is the javax-servlet 1.0.0, but I&#8217;m too lazy to prove that.</p>
<pre>+- org.apache.felix:org.osgi.compendium:jar:1.2.0:compile
|  +- org.apache.felix:javax.servlet:jar:1.0.0:compile
|  \- org.apache.felix:org.osgi.foundation:jar:1.2.0:compile</pre>
<h1>OSGi / Runtime</h1>
<p>The above gets us to a compiling and building state. However, our target platform is OSGi, specifically the Felix implementation. We need to be able to supply the JavaFX runtime classes to other bundles.</p>
<h3>The javafx-runtime bundle</h3>
<p>Rather than packaging each SDK jar individually into a bundle, we just dropped all of them into a single mega bundle.  The following POM accomplishes this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>PT2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.bjc.es<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.11.0-SNAPSHOT<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/parent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.bjc.pt2.javafx-runtime<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.bjc.pt2.javafx-runtime<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- the &lt;packaging&gt; pulls bundle from the parent's properties --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${packaging}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>bundle<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clover-percentage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>-100<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/clover-percentage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        This bundle simply wraps the various javafx-compiled jars as a bundle.
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>decora-d3d<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>decora-hw<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>decora-ogl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx-swing<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafxc<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">        &lt;dependency&gt;</span>
<span style="color: #808080; font-style: italic;">          &lt;groupId&gt;javafx&lt;/groupId&gt;</span>
<span style="color: #808080; font-style: italic;">          &lt;artifactId&gt;javafxdoc&lt;/artifactId&gt;</span>
<span style="color: #808080; font-style: italic;">          &lt;version&gt;${javafx.version}&lt;/version&gt;</span>
<span style="color: #808080; font-style: italic;">        &lt;/dependency&gt;</span>
<span style="color: #808080; font-style: italic;">        --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>gluegen-rt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>scenario<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jogl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jmc<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafxgui<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javafxrt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${javafx.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.felix<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-bundle-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extensions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/extensions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;instructions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Bundle-SymbolicName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            ${pom.artifactId}
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Bundle-SymbolicName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #808080; font-style: italic;">&lt;!-- embed all compile and runtime scope dependencies --&gt;</span>
                        <span style="color: #808080; font-style: italic;">&lt;!-- &lt;Embed-Dependency&gt;*;scope=compile;artifactId=!log4j|javafxc&lt;/Embed-Dependency&gt; --&gt;</span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Import-Package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            com.sun.imageio.plugins.gif;resolution:=optional,
                            javax.imageio.*,
                            javax.swing.*,
                            javax.sound.*,
                            javax.xml.parsers,
                            javax.media.*;resolution:=optional,
                            javax.script.*;resolution:=optional,
                            netscape.javascript.*;resolution:=optional,
                            sun.*;resolution:=optional,
                            com.sun.javafx.api;resolution:=optional,
                            com.sun.javafx.runtime.adapter;resolution:=optional,
                            org.jdesktop.applet.util;resolution:=optional,
                            org.jdesktop.animation.timing.*;resolution:=optional,
                            org.xml.sax.*;resolution:=optional,
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Import-Package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Export-Package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            com.sun.gluegen.*,
                            !com.sun.javafx.runtime.adapter,
                            !com.sun.javafx.runtime.liveconnect,
                            !com.sun.javafx.runtime.provider,
                            !com.sun.javafx.api.*,
                            com.sun.javafx.*,
                            com.sun.embeddedswing,
                            com.sun.media.*,
                            com.sun.medialib.*,
                            com.sun.opengl.*,
                            com.sun.scenario.*,
                            com.sun.stylesheet.*,
                            javax.media.opengl.*,
                            org.jdesktop.layout,
                            !javafx.fxunit,
                            javafx.*,
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Export-Package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/instructions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>You can alternately use Eclipse to export a bundle like this, see the post <a rel="nofollow" href="http://sinnema313.wordpress.com/2008/08/01/running-a-javafx-script-from-an-osgi-bundle/">Running a JavaFX script from an OSGi bundle</a>&#8211; generally a good article, but slightly skewed from our purpose.</p>
<p>The bundle created above is not quite perfect; some imports marked optional are probably not optional, but are for parts we aren&#8217;t using just yet, like sound, or applets.  It is missing all the native code shipped with the SDK, which probably has a performance impact.  We also haven&#8217;t tested a fully-featured screen yet.  Finally, there is another problem, which we&#8217;ll see in the next section.</p>
<h1>Integrating JavaFX into a Swing Application</h1>
<h3>I can&#8217;t create a Scene!</h3>
<p>There is a pretty nice article called <a rel="nofollow" href="http://blogs.sun.com/javafx/entry/how_to_use_javafx_in">How to Use JavaFX in Your Swing Application</a> on the main JavaFX blog.  It gives details for how to convert a Scene subclass into a JComponent for use in a swing app.  The only problem with that:  With the javafx-runtime bundle above, I <strong>always</strong> get a NullPointerException during some StyleSheet intialization.  Even when we do it from the command-line, the result is the same.  Again, the javafx-runtime bundle is not quite perfect, and I think that this bears that out.</p>
<h3>Getting the JComponent</h3>
<p>So, we had a workaround:  Extend CustomNode, then create a Scene in Java and inject the custom node in.  The class below has a field called node, which is of type javafx.scene.Node, set in by Spring (see next section).  We steal some of the code from the above link to help with the final extraction.  Also note, we had to duplicate SingletonSequence.java in our package, since it is package-protected in the SDK.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">        Scene scene <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Scene<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Sequence<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>Node<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> seq <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SingletonSequence<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>Node<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #009900;">&#40;</span>TypeInfo.<span style="color: #006633;">getTypeInfo</span><span style="color: #009900;">&#40;</span>Node.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>, node<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        scene.<span style="color: #006633;">get</span>$content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setAsSequenceFromLiteral</span><span style="color: #009900;">&#40;</span>seq<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        scene.<span style="color: #006633;">initialize</span>$<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// stolen from JFXPanel.java by Richard Bair and Jasper Potts:</span>
&nbsp;
        <span style="color: #003399;">String</span> helperName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;com.sun.javafx.scene.JSGPanelSceneImpl&quot;</span><span style="color: #339933;">;</span>
        FXClassType type <span style="color: #339933;">=</span> FXContext.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">findClass</span><span style="color: #009900;">&#40;</span>helperName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        FXObjectValue panelSceneImpl <span style="color: #339933;">=</span> type.<span style="color: #006633;">allocate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        panelSceneImpl.<span style="color: #006633;">initVar</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;scene&quot;</span>, FXLocal.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">mirrorOf</span><span style="color: #009900;">&#40;</span>scene<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        panelSceneImpl.<span style="color: #006633;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        FXValue jsgPanelV <span style="color: #339933;">=</span> type.<span style="color: #006633;">getVariable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jsgPanel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span>panelSceneImpl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">JComponent</span> jsgPanel <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">JComponent</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>FXLocal.<span style="color: #006633;">ObjectValue</span><span style="color: #009900;">&#41;</span> jsgPanelV<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">asObject</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<h3>Working with Spring</h3>
<p>The last piece of the puzzle is the ability to allow Spring to create JavaFX instances and set properties on them.  Here is an example JavaFX class:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">whatever</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.paint.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.shape.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.text.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EDText <span style="color: #000000; font-weight: bold;">extends</span> CustomNode <span style="color: #009900;">&#123;</span>
    var text<span style="color: #339933;">:</span><span style="color: #003399;">String</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Dialog</span>.<span style="color: #006633;">MESSAGE</span><span style="color: #339933;">;</span>
&nbsp;
    override <span style="color: #000000; font-weight: bold;">public</span> function create<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>Node <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">Group</span> <span style="color: #009900;">&#123;</span>
            content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span>
                    width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">300</span>
                    height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">200</span>
                    fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLUE</span>
                <span style="color: #009900;">&#125;</span>,
                Text <span style="color: #009900;">&#123;</span>
                    x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span>
                    y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span>
                    content<span style="color: #339933;">:</span> bind text
                    fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">WHITE</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// endgroup</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    function setDisplayString<span style="color: #009900;">&#40;</span>newValue<span style="color: #339933;">:</span><span style="color: #003399;">String</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        text <span style="color: #339933;">=</span> newValue<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It has a single operation, setDisplayString().  Then came this Spring config snippet to access it:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;edNode&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.bjc.pt2.authentication.ui.EDText&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;displayString&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;set a value from spring!&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>&#8230; which of course <strong>doesn&#8217;t</strong> work.  JavaFX infers that the setter has a return value because none was specified.  Spring is looking for public void setDisplayString(String) but finds public string setDisplayString(String) and complains.  Minor tweak to the JavaFX code for the function declaration:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"> function setDisplayString<span style="color: #009900;">&#40;</span>newValue<span style="color: #339933;">:</span><span style="color: #003399;">String</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>And it&#8217;s all happy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muddyhorse.com/2009/02/maven-osgi-spring-javafx-ant/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java Build Systems, Part 1: What they do</title>
		<link>http://blog.muddyhorse.com/2009/02/java-build-systems-part-1-what-they-do/</link>
		<comments>http://blog.muddyhorse.com/2009/02/java-build-systems-part-1-what-they-do/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 22:10:08 +0000</pubDate>
		<dc:creator>pforhan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[java-build-systems]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://blog.muddyhorse.com/?p=159</guid>
		<description><![CDATA[Two recent posts on the java-weblog circuit spurred me to motion: Maven Adoption Curve (Alex Miller, coworker at MetaMatrix) Maven and Ivy (Ryan Senior, coworker at BJC) I was trying to think of the ideal build system.  I won&#8217;t pretend that I&#8217;m going to get there in this post.  Instead, I&#8217;ll enumerate what we do [...]]]></description>
			<content:encoded><![CDATA[<p>Two recent posts on the java-weblog circuit spurred me to motion:</p>
<p><a href="http://tech.puredanger.com/2009/01/28/maven-adoption-curve/">Maven Adoption Curve</a> (Alex Miller, coworker at MetaMatrix)<a href="http://www.objectcommando.com/blog/?p=12"><br />
Maven and Ivy</a> (Ryan Senior, coworker at BJC)</p>
<p>I was trying to think of the ideal build system.  I won&#8217;t pretend that I&#8217;m going to get there in this post.  Instead, I&#8217;ll enumerate what we do every day and what we need from a build system so as to start thinking about the ideal system.</p>
<p><span id="more-159"></span>So, to the brainstorming.  Here&#8217;s what we do in the regular process of our osgi bundle development:</p>
<ol>
<li>Obtain dependencies</li>
<li>Compile java source</li>
<li>Compile javafx source</li>
<li>Generate metadata / configuration data</li>
<li>Make jar files</li>
<li>Upload jar files to central repository</li>
<li>Upload jar files to deployment location</li>
<li>Update remote (OBR) xml file with information about uploaded jar</li>
<li>Generate reports about the quality of the source (clover, PMD, checkstyle, etc)</li>
<li>check out from CVS / source control</li>
<li>check in to CVS / source control</li>
<li>tag CVS / source control</li>
<li>manage versions and releases</li>
</ol>
<p>I&#8217;m sure there are more.  Obviously, under web development, you&#8217;d deal with wars and their deployment.  We have ssh tasks to run code on the server.  We even have some install/run stuff that works pretty well.</p>
<p>You may have guessed we use maven.  Maven is so close, but just not there.  It is frustrating, performs a lot of magic, and just falls down in annoying ways.  We have gotten it to do all of the above, some of it is just not pretty.</p>
<p>Next episode, I&#8217;ll go into Maven and what it does well and what it does poorly.  Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muddyhorse.com/2009/02/java-build-systems-part-1-what-they-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wit: A Programmer&#8217;s Best Tool</title>
		<link>http://blog.muddyhorse.com/2008/08/wit-a-programmers-best-tool/</link>
		<comments>http://blog.muddyhorse.com/2008/08/wit-a-programmers-best-tool/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 14:27:27 +0000</pubDate>
		<dc:creator>pforhan</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[interviews]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[programmers]]></category>
		<category><![CDATA[wits]]></category>

		<guid isPermaLink="false">http://blog.muddyhorse.com/?p=97</guid>
		<description><![CDATA[I was humbled this past week.  I went to an interview at a game company.  But I didn&#8217;t have my most valuable asset. I&#8217;m sure I&#8217;m rewriting history as I go to make myself appear in a more positive light, but the more I think about it, the more it seems I just didn&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<p>I was humbled this past week.  I went to an interview at a game company.  But I didn&#8217;t have my most valuable asset.</p>
<p><span id="more-97"></span></p>
<p>I&#8217;m sure I&#8217;m rewriting history as I go to make myself appear in a more positive light, but the more I think about it, the more it seems I just didn&#8217;t have my wits about me.  Now, don&#8217;t get me wrong, I wasn&#8217;t up to snuff for the position for some pretty significant other reasons (like my hate/hate relationship with <a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)">Design Patterns</a>), but I&#8217;ll explore those issues at another time.</p>
<p>To set the stage:  I don&#8217;t know if jet lag is due to travel time, traveling at night, lack of sleep, or changing time zones, but I did all of them, and I was pretty draggy in the morning.</p>
<p>Except I didn&#8217;t realize that.  I had no edge, no sharpness, no wit.  I said idiotic things, couldn&#8217;t explain basic concepts, and would talk about things too long and then just trail off&#8230;</p>
<p>A prime example of my condition was when I was asked to explain the difference in usage and purpose of an array and a linked list (in Java terms, <code>ArrayList</code> and <code>LinkedList</code>).  I was barely able to stammer out something about resizing and that I knew there was another big difference that I couldn&#8217;t recall at the moment (random access performance times, sorting, sublists, etc).</p>
<p>I should have just stopped the interview there.  But I went on, because I didn&#8217;t have the wit to know better, and the rest of the day was similar, or worse.  All along, I blithely thought things were going pretty well.</p>
<p>The point I&#8217;m getting at is that a programmer without a quick wit really isn&#8217;t a programmer.  It takes a lot of fast operations to access needed information and format it for the receiver of that information, whether computer or human.  Know yourself, and know what you need to do to kick yourself out of a dimwitted day.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muddyhorse.com/2008/08/wit-a-programmers-best-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Guide to using Weak References in Java</title>
		<link>http://blog.muddyhorse.com/2008/07/quick-guide-to-using-weak-references-in-java/</link>
		<comments>http://blog.muddyhorse.com/2008/07/quick-guide-to-using-weak-references-in-java/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 20:31:42 +0000</pubDate>
		<dc:creator>pforhan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[garbage-collection]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[weak-references]]></category>

		<guid isPermaLink="false">http://blog.muddyhorse.com/?p=7</guid>
		<description><![CDATA[Java's WeakRef functionality is an easy way to handle a lot of data but not have to worry about running out of memory.  Here is a quick guide and example of use.]]></description>
			<content:encoded><![CDATA[<p>Java&#8217;s WeakReference functionality is an easy way to handle a lot of data but not have to worry about running out of memory.  Works well in lazy-initialization situations, such as when you want to be able to read in a potentially large amount of data, but that data is not important enough that you want to guarantee that it is always immediately available.</p>
<p>For example, say you are reading a 5 megapixel image off the disk in order to determine its size or make a thumbnail or otherwise read metadata. Or, you could be scanning files for spell checking or search terms.  Either way, you really don&#8217;t care that the original, large, source data stays in memory. If would be great if it did, for performance&#8217;s sake, but not the end of the world if it was garbage-collected.</p>
<p>By default, all java references are strong references &#8212; the object on the other end of a strong reference is not garbage collected until the object containing the reference is collected.  That is where java.lang.ref.WeakReference comes in. Instead of keeping your strong reference in your object, you give it to a WeakReference instance instead. It does the dirty work of allowing the reference to be collected.</p>
<p>You now have a strong reference to only a WeakReference object &#8212; a relative lightweight, in memory terms.  All you have to do is make sure the data is loaded when you want, and WeakRef and the GC will take care of unloading it as needed.</p>
<p>So, let&#8217;s take the example of reading a large file into a string, but we don&#8217;t mind re-reading the file if memory becomes tight.</p>
<p>The following code assumes there is a class, FileUtils, that has a method for reading the file. Implementation of that method is left as an exercise to the reader.</p>
<blockquote>
<table border="0">
<tbody>
<tr>
<td>
<pre>import java.io.File;
import java.lang.ref.WeakReference;

public class LazyFileReader {
    private WeakReference&lt;String&gt; fileRef;
    private final String filename;

    public LazyFileReader(String filename) {
        this.filename = filename;
    }

    private String forceLoadFileData() {
        // force initialization; create reference
        String rv = FileUtils.fileToString(new File(filename));
        // update weakRef:
        fileRef = new WeakReference&lt;String&gt;(rv); // **1**

        return rv;
    }

    public String getFileData() {
        String rv;

        if (fileRef == null) { // **2**
            // first loading, force:
            System.out.println("first loading: " + filename);
            rv = forceLoadFileData();

        } else {
            // load from weakRef:
            rv = fileRef.get(); // **3**
            if (rv == null) {
                System.out.println("file needs reloading: " + filename);
                rv = forceLoadFileData(); // **4**
            } // endif
        } // endif

        return rv;
    }
}</pre>
</td>
</tr>
</tbody>
</table>
</blockquote>
<p>Some notes, indicated by // ** # ** comments above:</p>
<ol>
<li>Note that once a WeakReference has released its data, you can&#8217;t update the reference &#8212; you must create a new one each time.</li>
<li>The very first time getFileData() is called, we don&#8217;t even have a WeakReference reference. This situation will only happen once.</li>
<li>get() is the means by which you get back the reference you put in. A null value indicates that the reference was collected and therefore needs to be recreated.</li>
<li>Note that we perform the exact same code during the first time through and the first time through after the reference was collected.</li>
</ol>
<p>Hope that helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muddyhorse.com/2008/07/quick-guide-to-using-weak-references-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
