<?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>Christophe Coenraets&#187; BlazeDS</title>
	<atom:link href="http://coenraets.org/blog/category/blazeds/feed/" rel="self" type="application/rss+xml" />
	<link>http://coenraets.org/blog</link>
	<description>Mobile, Cloud, HTML, JavaScript, Java, PHP, Flex</description>
	<lastBuildDate>Fri, 03 Feb 2012 05:02:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using the Flash Builder 4 Data Centric Features with Parsley (and other frameworks)</title>
		<link>http://coenraets.org/blog/2010/05/using-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks</link>
		<comments>http://coenraets.org/blog/2010/05/using-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks/#comments</comments>
		<pubDate>Wed, 05 May 2010 13:59:13 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[LCDS]]></category>
		<category><![CDATA[Parsley]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=673</guid>
		<description><![CDATA[I have blogged about the new data-centric features in Flash Builder 4 here and here. One question people often ask me is: “Can I use this feature if I use a Framework (Cairngorm, Mate, Parsley, Spring ActionScript, Swiz, etc)?” The answer is yes: The classes generated by Flash Builder (Value Objects and Service Stubs) are [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Using the Flash Builder 4 Data Centric Features with Parsley (and other frameworks) http://coenraets.org/blog/?p=673" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2010%2F05%2Fusing-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p><img src="http://coenraets.org/apps/contacts/contacts.jpg" alt="" /></p>
<p>I have blogged about the new data-centric features in Flash Builder 4 <a href="http://coenraets.org/blog/2010/03/flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards/">here </a>and <a href="http://coenraets.org/blog/2010/03/flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards/">here</a>. One question people often ask me is: “Can I use this feature if I use a Framework (Cairngorm, Mate, Parsley, Spring ActionScript, Swiz, etc)?”</p>
<p>The answer is yes: The classes generated by Flash Builder (Value Objects and Service Stubs) are standard building blocks that are part of most RIA design patterns, regardless of whether or not you use a framework.</p>
<p>The way you leverage these classes in your application may differ slightly depending on the framework you are using. For example, each framework may have a different approach to configure service endpoints or to instantiate generated service stubs.</p>
<p>To demonstrate this, I built a version of my “Contacts” application (also known as InSync) using the Flash Builder 4 data-centric features and the <a href="http://www.spicefactory.org/parsley/">Parsley Framework</a>.</p>
<p><span id="more-673"></span><br />
<strong>Configuring Service Endpoints</strong></p>
<p>By default, an application built using a BlazeDS or LCDS project determines its service endpoints using a combination of assumptions made at runtime and hardcoded references baked into the swf at compile time. Read my <a href="http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lcds/">Externalizing Service Configuration</a> blog post for more information on this topic. The bottom line is that this default behavior is insufficient for any application other than a simple demo: you want endpoints to be fully configurable so that you can move services around without having to recompile your application.</p>
<p>Using Parsley, I inject the service endpoint configuration (in the form of a ChannelSet) in the generated service stubs as follows:</p>
<pre class="brush: jscript; title: ; notranslate">
public class ContactService extends _Super_ContactService
{
	[Inject]
	override public function set channelSet(cs:ChannelSet):void
	{
		super.channelSet = cs;
	}
}
</pre>
<p>Note that I added this code in ContactService.as and not _Super_ContactService.as. Contrary to _Super_ContactService.as, ContactService.as will never be regenerated and is therefore the right place to add your custom code.</p>
<p>The injected ChannelSet is defined in my own channels-config.xml configuration file as follows:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;object type=&quot;mx.messaging.ChannelSet&quot;&gt;
 	&lt;property name=&quot;channels&quot;&gt;
    		&lt;array&gt;
		    	&lt;object type=&quot;mx.messaging.channels.AMFChannel&quot;&gt;
		        	&lt;property name=&quot;uri&quot; value=&quot;http://localhost:8400/testdrive/messagebroker/amf&quot;/&gt;
		        &lt;/object&gt;
	        &lt;/array&gt;
	&lt;/property&gt;
&lt;/object&gt;
</pre>
<p>Note: Unlike the BlazeDS/LCDS services-config.xml file, channels-config.xml is read at runtime.</p>
<p>Because the ChannelSet is configured in an xml file, you can easily change the channel’s endpoint URI without recompiling the application. You could also add failoverURIs to this channel, or add completely new fall back channels to the ChannelSet.</p>
<p><strong>Instantiating Service Stubs</strong></p>
<p>As we already alluded to, Parsley is a dependency injection framework: Instead of letting a component instantiate its dependencies, those dependencies are injected in the component at runtime. For example, in ContactForm, instead of instantiating a ContactService as follows:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;services:ContactService/&gt;
</pre>
<p>… I simply defined a contactService reference variable that I annotated with [Inject] to let Parsley inject a ContactService instance a runtime.</p>
<pre class="brush: jscript; title: ; notranslate">
[Inject]
public var contactService:ContactService
</pre>
<p>The instance of ContactService that Parsley injects is defined in Config.mxml and has itself been injected with a ChannelSet. Object configuration in Parsley is very flexible. In this application I combine the xml and mxml configuration options. I use the xml configuration option for the things I don’t want to hardcode in my application, and the mxml configuration for traditional object instantiation and configuration.</p>
<p>Note: Parsley doesn’t force you to use any specific design pattern. For simplicity in this sample application, I inject a service directly into the view. You can of course use other patterns (like the Presentation Model) to achieve a greater level of abstraction. The Dependency Injection and Messaging infrastructure of Parsley will make the implementation of these patterns easier.</p>
<h2>Installation Instructions</h2>
<ol>
<li><a href="https://www.adobe.com/cfusion/entitlement/index.cfm?e=lc_blazeds">Download</a> and install BlazeDS 4</li>
<li>Make a copy the blazeds web application in blazeds/tomcat/webapps, and call the new web application contacts</li>
<li>Download <a href="http://coenraets.org/apps/contacts/contacts.zip">contacts.zip</a>, and unzip it anywhere on your file system.</li>
<li>Overlay contacts/webapps/contacts (from contacts.zip) on top of blazeds/webapps/contacts</li>
<li>Start the server</li>
<li>Open a Command Window or Shell, navigate to /blazeds/tomcat/bin, and start Tomcat (for instance: catalina run).</li>
<li>Open a browser and access <a href="http://localhost:8400/contacts/ContactsParsley/ContactsParsley.html">http://localhost:8400/contacts/ContactsParsley/ContactsParsley.html</a>.</li>
</ol>
<p>Note: The web application also include a plain (framework-less) version of the application available at this URL: <a href="http://localhost:8400/contacts/Contacts/Contacts.html">http://localhost:8400/contacts/Contacts/Contacts.html</a></></p>
<h2>Importing the projects in Flash Builder 4</h2>
<ol>
<li>In Flash Builder 4, click <strong>File > Import > General > Existing Projects into Workspace</strong>.</li>
<li>Specify <strong>contacts/projects</strong> as the root directory and click finish.</li>
<li>Explore the projects: Contacts is the Flex project for the plain version of the application, ContactsParsley is the version discussed in this article, and java-testdrive is the Java project for the server-side classes.</li>
</ol>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2010/05/using-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2010/05/using-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2010/05/using-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Using the Flash Builder 4 Data Centric Features with Parsley (and other frameworks) http://coenraets.org/blog/?p=673" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2010%2F05%2Fusing-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2010/05/using-the-flash-builder-4-data-centric-features-with-parsley-and-other-frameworks/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Flex 4 Sample Application using a Java Back-End, BlazeDS 4 and Flash Builder 4 Data Wizards</title>
		<link>http://coenraets.org/blog/2010/03/flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards</link>
		<comments>http://coenraets.org/blog/2010/03/flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 12:11:35 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex4]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=530</guid>
		<description><![CDATA[I put together a new Test Drive environment to allow you to explore the development of Flex 4 applications with a Java back-end using the new &#8220;Data-Centric Development&#8221; features of Flash Builder 4. These features include service introspection, value object and service stub generation, etc. This Test Drive is still work in progress: it currently [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Flex 4 Sample Application using a Java Back-End, BlazeDS 4 and Flash Builder 4 Data Wizards http://coenraets.org/blog/?p=530" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2010%2F03%2Fflex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p>I put together a new Test Drive environment to allow you to explore the development of Flex 4 applications with a Java back-end using the new &#8220;Data-Centric Development&#8221; features of Flash Builder 4. These features include service introspection, value object and service stub generation, etc. This Test Drive is still work in progress: it currently consists of a single application called InSync (a complete Flex 4 rewrite of my contact management sample application), but I think it&#8217;s already valuable to understand the impact of the new Flash Builder 4 data features. Insync also demonstrates some of the new features of Flex 4: skinning, skinnable components, layout managers, etc.</p>
<p>Watch the video below to get familiar with the Test Drive environment and the sample application:</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/ylm6GcMjU1w&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ylm6GcMjU1w&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<h2>Installation Instructions</h2>
<ol>
<li>Download <a href="http://coenraets.org/downloads/flex-java-testdrive/flex-java-testdrive.zip">flex-java-testdrive.zip</a>, and unzip the file in your root directory.</li>
<li>Open a Command Window or Shell, navigate to /flex-java-testdrive/tomcat/bin, and start Tomcat (for instance: catalina run).</li>
<li>Open a browser and access http://localhost:8400/testdrive/InSync/InSync.html.</li>
</ol>
<h2>Importing the projects in Flash Builder 4</h2>
<ol>
<li>In Flash Builder 4, click <strong>File > Import > General > Existing Projects into Workspace</strong>.</li>
<li>Specify <strong>flex-java-testdrive/projects</strong> as the root directory and click finish.</li>
<li>Explore the projects: InSync is the Flex project and java-testdrive is the Java project for the server-side classes.</li>
</ol>
<p>In the InSync project, the classes in the services and valueObjects packages have been generated automatically by Flash Builder 4. My next blog post will show you how to generate these classes based on existing Java services deployed in BlazeDS.</p>
<p>NOTE: Because BlazeDS 4 hasn’t yet been released, this version of the Test Drive uses a nightly build of BlazeDS 4.</p>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2010/03/flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2010/03/flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2010/03/flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Flex 4 Sample Application using a Java Back-End, BlazeDS 4 and Flash Builder 4 Data Wizards http://coenraets.org/blog/?p=530" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2010%2F03%2Fflex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2010/03/flex-4-sample-application-using-a-java-back-end-blazeds-4-and-flash-builder-4-data-wizards/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Building the Server-Side of the &quot;Tour de Flex&quot; Real-Time Dashboard</title>
		<link>http://coenraets.org/blog/2009/05/tdfdashboard/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tdfdashboard</link>
		<comments>http://coenraets.org/blog/2009/05/tdfdashboard/#comments</comments>
		<pubDate>Tue, 26 May 2009 15:18:30 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[LCDS]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=121</guid>
		<description><![CDATA[Greg Wilson and Damien Mandrioli are also blogging about the new Tour de Flex real time dashboard today. Greg is the inspiration behind everything “Tour de Flex”, including the idea of the dashboard. He has the story behind the genesis of this project on his blog. Damien (from IBM/ILOG) did a fantastic job at building [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Building the Server-Side of the &quot;Tour de Flex&quot; Real-Time Dashboard http://coenraets.org/blog/?p=121" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F05%2Ftdfdashboard%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p><img src="http://coenraets.org/downloads/tdfdashboard.png" alt="" /></p>
<p><a href="http://gregsramblings.com/">Greg Wilson</a> and <a href="http://blogs.ilog.com/elixir/author/dmandrioli/">Damien Mandrioli</a> are also blogging about the new Tour de Flex real time dashboard today. Greg is the inspiration behind everything “Tour de Flex”, including the idea of the dashboard. He has the story behind the genesis of this project <a href="http://gregsramblings.com/2009/05/26/tour-de-flex-live-planetary-dashboard">on his blog</a>. Damien (from IBM/ILOG) did a fantastic job at building the client-side of the dashboard using the very cool <a href="http://www.ilog.com/products/ilogelixir/">ILOG Elixir components</a>, and he <a href="http://blogs.ilog.com/elixir/2009/05/26/tdfdashboard/">walks you through the details</a> on his blog.</p>
<p>My contribution to the project is the &#8220;real-time messaging&#8221; infrastructure. I provide the details below.</p>
<p>First the overall workflow&#8230;</p>
<p><img src="http://coenraets.org/downloads/tdfdashboardflow.png" alt="" /></p>
<p>The reason we are combining PHP and Java in this workflow is mostly historical. In the initial version of Tour de Flex, there was no Java involved: Greg was persisting loaded samples data (sample id and timestamp) directly from his PHP page. We later added LiveCycle Data Services to the picture to support the data push requirement of the dashboard, and we took the opportunity to move some code (such as the database persistence) from PHP to Java. Note that we are using LCDS for the performance and scalability of its high-end channels, but the application could also be deployed on BlazeDS.</p>
<p>A more straightforward architecture would be for the client to communicate directly with LCDS. For example, the client could invoke a remote object that would directly publish the loaded sample data (sample id and geolocation of the client) to the message destination. Alternatively, the client could use a Producer object to directly publish the message to the destination. Because some logic (such as geolocating the IP address and persisting the data) has to be executed at the server-side before routing the messages to the subscribed clients, you would have to write a custom message adapter if you used this approach.</p>
<p>We will probably streamline the workflow with one of these two approaches in the future, but in the meantime here is the source code for the servlet (logging and non-essential code removed for brevity):</p>
<pre class="brush: java; title: ; notranslate">
package com.adobe.tdf;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.maxmind.geoip.Location;
import com.maxmind.geoip.LookupService;

import flex.messaging.MessageBroker;
import flex.messaging.messages.AsyncMessage;
import flex.messaging.util.UUIDUtils;

public class TDFServlet extends HttpServlet {

	// Unique clientID for the message service
	private String clientID = UUIDUtils.createUUID();

	// The geocoding service
	protected LookupService lookupService;

	// A DAO to store sample requests in a database
	protected SampleRequestDAO dao = new SampleRequestDAO();

	// The LCDS message broker
	protected MessageBroker messageBroker;

	// The LCDS messaging destination where real time sample requests information is pushed
	protected String destination;

	public void init() throws ServletException {

		ServletConfig config = getServletConfig();
		destination = config.getInitParameter(&quot;messaging.destination.name&quot;);
		String path = config.getInitParameter(&quot;geocoding.database.path&quot;);
		try {
			// Load the geocoding database in init() to make sure we load it only once
			lookupService = new LookupService(path, LookupService.GEOIP_MEMORY_CACHE);
		} catch (IOException e) {
			// We swallow the exception here. If the database is not available, the feed
			// will still work but won't provide the location info.
		}
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		if (messageBroker == null)
		{
			messageBroker = MessageBroker.getMessageBroker(null);
		}

		SampleRequest sampleRequest = new SampleRequest();

		try {
			sampleRequest.setSampleId(Integer.parseInt(request.getParameter(&quot;sampleId&quot;)));
		} catch (Exception e) {
			String message = &quot;A valid sampleId is required to process this request&quot;;
			throw new RuntimeException(message);
		}

		sampleRequest.setTimestamp(new Date());

		String ipAddress = request.getParameter(&quot;ipAddress&quot;);

		// Geolocate the IP address and add the info to the message
		if (lookupService != null &amp;&amp; ipAddress != null)
		{
	                Location location = lookupService.getLocation(ipAddress);
			if (location != null)
			{
				sampleRequest.setLatitude(location.latitude);
				sampleRequest.setLongitude(location.longitude);
				sampleRequest.setCountry(location.countryCode);
				sampleRequest.setCity(location.city);
			}
		}

		try {
			dao.create(sampleRequest, ipAddress);
		} catch (RuntimeException e) {

		}

		String subtopic = request.getParameter(&quot;subtopic&quot;);
		if (subtopic == null) subtopic = &quot;flex&quot;;

		// Publish the message to specified destination and subtopic.
		AsyncMessage msg = new AsyncMessage();
		msg.setDestination(destination);
		msg.setHeader(&quot;DSSubtopic&quot;, subtopic);
		msg.setClientId(clientID);
		msg.setMessageId(UUIDUtils.createUUID());
		msg.setTimestamp(System.currentTimeMillis());
		msg.setBody(sampleRequest);
		messageBroker.routeMessageToService(msg, null);

		PrintWriter out = response.getWriter();
	        out.println(&quot;&lt;html&gt;&lt;body&gt;ok&lt;/body&gt;&lt;/html&gt;&quot;);

	}

}
</pre>
<p>The servlet is responsible for three things:</p>
<ol>
<li>Geolocate the IP address of the client requesting the sample. We currently use the MaxMind Geolocation API. The API is straightforward and the results seem pretty accurate.</li>
<li>Save the information about the loaded sample in a database. We keep track of historical data to be able to support future data visualization projects.</li>
<li>Publish the data about the loaded sample to a message destination. The servlet uses the Message Service Java API to directly push messages to the Flex destination (lines 97 to 104). Note that the same API exists for ColdFusion, so CF developers could use a CF page instead of this servlet to push messages to the client.</li>
</ol>
<h3>Channels</h3>
<p>The messaging destination is set up to support different communication channels: RTMP, long polling, and regular polling. The client-side developer can decide which channel to use to communicate with the server. For example, if you wanted to use RTMP as the primary channel, fall back to long polling if the RTMP connection fails, and fall back to regular polling if the long polling connection fails you could set up your client-side ChannelSet as follows:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;mx:ChannelSet id=&quot;channelSet&quot;&gt;
	&lt;mx:RTMPChannel id=&quot;rtmp&quot; url=&quot;rtmp://hostname:2037&quot;/&gt;
	&lt;mx:AMFChannel url=&quot;http://hostname/context/messagebroker/amflongpolling&quot;/&gt;
	&lt;mx:AMFChannel url=&quot;http://hostname/context/messagebroker/amfpolling&quot;/&gt;
&lt;/mx:ChannelSet&gt;
</pre>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2009/05/tdfdashboard/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2009/05/tdfdashboard/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2009/05/tdfdashboard/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Building the Server-Side of the &quot;Tour de Flex&quot; Real-Time Dashboard http://coenraets.org/blog/?p=121" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F05%2Ftdfdashboard%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/05/tdfdashboard/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>New Update to the Spring BlazeDS Integration Test Drive</title>
		<link>http://coenraets.org/blog/2009/05/new-update-to-the-spring-blazeds-integration-test-drive/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-update-to-the-spring-blazeds-integration-test-drive</link>
		<comments>http://coenraets.org/blog/2009/05/new-update-to-the-spring-blazeds-integration-test-drive/#comments</comments>
		<pubDate>Tue, 12 May 2009 19:33:32 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=119</guid>
		<description><![CDATA[I made some additional changes to the Spring BlazeDS Integration (RC1) Test Drive: The Test Drive now includes an annotation-based configuration sample (the Company Manager sample). Spring annotations such as @Service, @RemotingDestination, @Autowired, @RemotingInclude, and @RemotingExclude make it really easy to configure your beans and make them available through Remoting. As an example, here is [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ New Update to the Spring BlazeDS Integration Test Drive http://coenraets.org/blog/?p=119" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F05%2Fnew-update-to-the-spring-blazeds-integration-test-drive%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p>I made some additional changes to the Spring BlazeDS Integration (RC1) Test Drive:</p>
<ul>
<li>The Test Drive now includes an annotation-based configuration sample (the Company Manager sample). Spring annotations such as @Service, @RemotingDestination, @Autowired, @RemotingInclude, and @RemotingExclude make it really easy to configure your beans and make them available through Remoting. As an example, here is the source code for the CompanyDAO class:
<p></p>
<pre class="brush: java; title: ; notranslate">
package flex.spring.samples.company;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.flex.remoting.RemotingExclude;
import org.springframework.flex.remoting.RemotingInclude;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;

import flex.spring.samples.industry.IIndustryDAO;

@Service(&quot;companyService&quot;)
@RemotingDestination(channels={&quot;my-amf&quot;})
public class CompanyDAO implements ICompanyDAO {

	private final SimpleJdbcTemplate template;
	private final SimpleJdbcInsert insertCompany;

	private IIndustryDAO industryDAO;

	private final ParameterizedRowMapper&lt;Company&gt; rowMapper = new ParameterizedRowMapper&lt;Company&gt;(){
		public Company mapRow(ResultSet rs, int rowNum) throws SQLException {
			Company company = new Company();
			company.setId(rs.getInt(&quot;id&quot;));
			company.setName(rs.getString(&quot;name&quot;));
			company.setAddress(rs.getString(&quot;address&quot;));
			company.setCity(rs.getString(&quot;city&quot;));
			company.setState(rs.getString(&quot;state&quot;));
			company.setZip(rs.getString(&quot;zip&quot;));
			company.setPhone(rs.getString(&quot;phone&quot;));
			company.setIndustry(industryDAO.findById(rs.getInt(&quot;industry_id&quot;)));
			return company;
		}
	};

	@Autowired
	public CompanyDAO(DataSource dataSource, IIndustryDAO industryDAO) {
		template = new SimpleJdbcTemplate(dataSource);
		insertCompany = new SimpleJdbcInsert(dataSource).withTableName(&quot;COMPANY&quot;).usingGeneratedKeyColumns(&quot;ID&quot;);
		this.industryDAO = industryDAO;
	}

	@RemotingInclude
	public Company findById(int id) {
		return template.queryForObject(&quot;SELECT * FROM company WHERE id=?&quot;, rowMapper, id);
	}

	@RemotingInclude
	public List&lt;Company&gt; findAll() {
		return template.query(&quot;SELECT * FROM company ORDER BY name&quot;, rowMapper);
	}

	@RemotingInclude
	public List&lt;Company&gt; findByName(String name) {
		return template.query(&quot;SELECT * FROM company WHERE UPPER(name) LIKE ? ORDER BY name&quot;,
				rowMapper,
				&quot;%&quot; + name.toUpperCase() + &quot;%&quot;);
	}

	@RemotingInclude
	public Company create(Company company) {
		Map&lt;String, Object&gt; parameters = new HashMap&lt;String, Object&gt;();
        parameters.put(&quot;name&quot;, company.getName());
        parameters.put(&quot;address&quot;, company.getAddress());
        parameters.put(&quot;city&quot;, company.getCity());
        parameters.put(&quot;state&quot;, company.getState());
        parameters.put(&quot;zip&quot;, company.getZip());
        parameters.put(&quot;phone&quot;, company.getPhone());
        parameters.put(&quot;industry_id&quot;, company.getIndustry().getId());
        Number id = insertCompany.executeAndReturnKey(parameters);
		company.setId(id.intValue());
		return company;
	}

	@RemotingInclude
	public boolean update(Company company) {
        int count = template.update(&quot;UPDATE company SET name=?, address=?, city=?, state=?, zip=?, phone=?, industry_id=? WHERE id=?&quot;,
				company.getName(),
				company.getAddress(),
				company.getCity(),
				company.getState(),
				company.getZip(),
				company.getPhone(),
				company.getIndustry().getId(),
				company.getId());
		return (count == 1);
	}

	@RemotingExclude
	public boolean remove(Company company) {
		int count = template.update(&quot;DELETE FROM company WHERE id=?&quot;, company.getId());
		return (count == 1);
	}

}
</pre>
<p>
</li>
<li>The Test Drive is now using the M3 build of Spring 3 (as opposed to M2 in the previous builds of the Test Drive).</li>
<li>I modified the configuration of the long polling channel to support more persistent connections per domain based on the browser capabilities.</li>
<li>And of course compared to the M2 build, this version of the Test Drive includes a number of Messaging samples.
<p>Using the Messaging integration, setting up a destination can be as easy as:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;flex:message-destination id=&quot;chat&quot; /&gt;
</pre>
<p>And here is how you configure a destination mapped to a JMS topic:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;flex:jms-message-destination id=&quot;jms-chat&quot; jms-destination=&quot;chatTopic&quot; /&gt;
</pre>
</li>
</ul>
<h3>Installation Instructions:</h3>
<ol>
<li>Download the Spring / Flex TestDrive here: <a href="http://coenraets.org/downloads/spring-flex-testdrive-RC1v2.zip">http://coenraets.org/downloads/spring-flex-testdrive-RC1v2.zip</a></li>
<li>Unzip it in your root directory</li>
<li>Navigate to /spring-flex-testdrive/tomcat/bin and start Tomcat (for instance: catalina run)</li>
<li>Open a browser and access http://localhost:8080</li>
<li>Follow the instructions</li>
</ol>
<p></p>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2009/05/new-update-to-the-spring-blazeds-integration-test-drive/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2009/05/new-update-to-the-spring-blazeds-integration-test-drive/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2009/05/new-update-to-the-spring-blazeds-integration-test-drive/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ New Update to the Spring BlazeDS Integration Test Drive http://coenraets.org/blog/?p=119" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F05%2Fnew-update-to-the-spring-blazeds-integration-test-drive%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/05/new-update-to-the-spring-blazeds-integration-test-drive/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Speaking at the New England Java User Group on Thursday (May 14th)</title>
		<link>http://coenraets.org/blog/2009/05/speaking-at-the-new-england-java-user-group-on-thursday-may-14th/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=speaking-at-the-new-england-java-user-group-on-thursday-may-14th</link>
		<comments>http://coenraets.org/blog/2009/05/speaking-at-the-new-england-java-user-group-on-thursday-may-14th/#comments</comments>
		<pubDate>Mon, 11 May 2009 18:47:18 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=118</guid>
		<description><![CDATA[Follow @ccoenraets
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Speaking at the New England Java User Group on Thursday (May 14th) http://coenraets.org/blog/?p=118" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F05%2Fspeaking-at-the-new-england-java-user-group-on-thursday-may-14th%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p><img src="http://coenraets.org/downloads/nejug.gif" alt="" </p>
<p>I will be joined by Mark Fisher from SpringSource and we will talk about Flex, Spring, BlazeDS and the integration of these technologies. <a href="http://www.springsource.org/spring-flex">Spring BlazeDS integration</a> RC1 was released last week. One of the key features in RC1 is the integration of the Message service, and Mark is the lead developer on that feature.</p>
<p>I hope to see you there if you live in the greater Boston area.</p>
<p>Thu, May 14 6:00pm<br />
Sun Microsystems &#8211; 1 Network Way, Burlington, MA<br />
<a href="http://www.nejug.org/events/show/93">NEJUG Link</a></p>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2009/05/speaking-at-the-new-england-java-user-group-on-thursday-may-14th/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2009/05/speaking-at-the-new-england-java-user-group-on-thursday-may-14th/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2009/05/speaking-at-the-new-england-java-user-group-on-thursday-may-14th/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Speaking at the New England Java User Group on Thursday (May 14th) http://coenraets.org/blog/?p=118" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F05%2Fspeaking-at-the-new-england-java-user-group-on-thursday-may-14th%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/05/speaking-at-the-new-england-java-user-group-on-thursday-may-14th/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>New Test Drive for Spring BlazeDS Integration RC1</title>
		<link>http://coenraets.org/blog/2009/05/new-test-drive-for-spring-blazeds-integration-rc1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-test-drive-for-spring-blazeds-integration-rc1</link>
		<comments>http://coenraets.org/blog/2009/05/new-test-drive-for-spring-blazeds-integration-rc1/#comments</comments>
		<pubDate>Fri, 08 May 2009 20:34:55 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[LCDS]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=117</guid>
		<description><![CDATA[UPDATE: An updated version of this Test Drive is available here SpringSource just released the RC1 build for the Spring / BlazeDS integration project. The key new feature in RC1 is the integration of the BlazeDS Message Service. I updated my Spring BlazeDS Integration Test Drive to showcase the messaging integration. In addition to Remoting [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ New Test Drive for Spring BlazeDS Integration RC1 http://coenraets.org/blog/?p=117" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F05%2Fnew-test-drive-for-spring-blazeds-integration-rc1%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: An updated version of this Test Drive is available <a href="http://coenraets.org/blog/2009/05/new-update-to-the-spring-blazeds-integration-test-drive/">here</a></strong></p>
<p>SpringSource just released the RC1 build for the <a href="http://www.springsource.org/spring-flex">Spring / BlazeDS integration project</a>. The key new feature in RC1 is the integration of the BlazeDS Message Service.</p>
<p>I updated my Spring BlazeDS Integration Test Drive to showcase the messaging integration.</p>
<p>In addition to Remoting and Security samples, the Test Drive now includes the following Messaging samples:</p>
<ul>
<li><strong>Chat</strong>: Messaging basics</li>
<li><strong>Simple Data Push</strong>: A simple data push example</li>
<li><strong>Traderdesktop</strong>: A more sophisticated data push example showing how to use subtopics</li>
<li><strong>JMS Chat</strong>: A chat application using a JMS topic and exchanging messages with a Swing-based client</li>
<li><strong>Collaboration</strong>: An example showing how to use messaging to remotely drive another client&#8217;s application</li>
</ul>
<h3>Installation Instructions:</h3>
<ol>
<li>Download the Spring / Flex TestDrive here: <a href="http://coenraets.org/downloads/spring-flex-testdrive-RC1.zip">http://coenraets.org/downloads/spring-flex-testdrive-RC1.zip</a></li>
<li>Unzip it in your root directory</li>
<li>Navigate to /spring-flex-testdrive/tomcat/bin and start Tomcat (for instance: catalina run)</li>
<li>Open a browser and access http://localhost:8080</li>
<li>Follow the instructions</li>
</ol>
<p>As always, I&#8217;d love to hear your feedback and your ideas to improve this Test Drive.</p>
<p>I will probably have another version next week with a couple of additional samples and more documentation for the Message Service, but I already wanted to make this version available to allow you to experiment RC1 samples.</p>
<p>Christophe</p>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2009/05/new-test-drive-for-spring-blazeds-integration-rc1/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2009/05/new-test-drive-for-spring-blazeds-integration-rc1/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2009/05/new-test-drive-for-spring-blazeds-integration-rc1/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ New Test Drive for Spring BlazeDS Integration RC1 http://coenraets.org/blog/?p=117" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F05%2Fnew-test-drive-for-spring-blazeds-integration-rc1%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/05/new-test-drive-for-spring-blazeds-integration-rc1/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Externalizing Service Configuration using BlazeDS and LCDS</title>
		<link>http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lcds/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=externalizing-service-configuration-using-blazeds-and-lcds</link>
		<comments>http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lcds/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 17:57:06 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[Air]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[LCDS]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=113</guid>
		<description><![CDATA[A typical source of confusion when developers start working with RemoteObject or other BlazeDS/LCDS related classes is where and most importantly *when* the configuration of your services is being read. The question often arises after an application stops working when you move it to another server. This is one of the most frequently asked questions [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Externalizing Service Configuration using BlazeDS and LCDS http://coenraets.org/blog/?p=113" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F03%2Fexternalizing-service-configuration-using-blazeds-and-lcds%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p>A typical source of confusion when developers start working with RemoteObject or other BlazeDS/LCDS related classes is where and most importantly *when* the configuration of your services is being read.</p>
<p>The question often arises after an application stops working when you move it to another server. This is one of the most frequently asked questions related to BlazeDS and LCDS, so I figured I would answer it here. There is nothing really new in this post, but hopefully this will be a good point of reference.</p>
<p>When you create a new BlazeDS or LCDS project in Flex Builder, you are typically told to select J2EE as the “Application Server Type” and then check “use remote object access service”. This adds a compiler argument pointing to the location of your services-config.xml. If you check the Flex Compiler properties of your Flex Builder project, you’ll see something like this:</p>
<p>-services &#8220;c:\blazeds\tomcat\webapps\samples\WEB-INF\flex\services-config.xml&#8221;</p>
<p>When you then compile your application, the required values of services-config.xml are baked into the SWF. In other words, services-config.xml is read at <strong>compile time</strong> and not at runtime as you may have thought intuitively. To abstract things a little bit, you can use tokens such as {server.name}, {server.port}, and {context.root} in services-config.xml. However, {context.root} is still substituted at compile time, while {server.name} and {server.port} are replaced at runtime using the server name and port number of the server the SWF was loaded from (which is why you can&#8217;t use these tokens for AIR applications).</p>
<p><span id="more-113"></span></p>
<p>Fortunately, the Flex SDK provides an API that allows you to configure your channels at runtime and entirely externalize your services configuration from your code (you definitely don&#8217;t want to recompile your application when you move it to another server).  At a high level, it works like this:</p>
<pre class="brush: jscript; title: ; notranslate">
var channelSet:ChannelSet = new ChannelSet();
var channel:AMFChannel = new AMFChannel(&quot;my-amf&quot;, &quot;http://localhost:8400/lcds-samples/messagebroker/amf&quot;);
channelSet.addChannel(channel);
remoteObject.channelSet = channelSet;
</pre>
<p>This is still not what we want because the endpoint URL is still hardcoded in the application. At least in this case it’s obvious that it is. So, the last step is to pass that endpoint URL value at runtime. There are a number of ways you can pass values to a SWF at runtime (flashvars, page parameters, etc). The approach I usually use is to read a configuration file using HTTPService at application startup. That configuration file includes (among other things) the information I need to programmatically create my channel set at runtime. Here is a basic implementation:
</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
	applicationComplete=&quot;configSrv.send()&quot;&gt;

	&lt;mx:Script&gt;
	&lt;![CDATA[

	import mx.controls.Alert;
	import mx.messaging.channels.AMFChannel;
	import mx.messaging.ChannelSet;
	import mx.rpc.events.ResultEvent;

	private var channelSet:ChannelSet;

	private function configResultHandler(event:ResultEvent):void
	{
		var xml:XML = event.result as XML;
		var amfEndpoint:String = &quot;&quot; + xml..channel.(@id==&quot;amf&quot;).@endpoint;
		if (amfEndpoint == &quot;&quot;)
		{
			Alert.show(&quot;amf channel not configured&quot;, &quot;Error&quot;);
		}
		else
		{
			channelSet = new ChannelSet();
			var channel:AMFChannel = new AMFChannel(&quot;my-amf&quot;, amfEndpoint);
			channelSet.addChannel(channel);
			ro.channelSet = channelSet;
			ro.getProducts();
		}
	}

	]]&gt;
	&lt;/mx:Script&gt;

	&lt;mx:HTTPService id=&quot;configSrv&quot; url=&quot;config.xml&quot; resultFormat=&quot;e4x&quot; result=&quot;configResultHandler(event)&quot;/&gt;

	&lt;mx:RemoteObject id=&quot;ro&quot; destination=&quot;product&quot;/&gt;

	&lt;mx:DataGrid dataProvider=&quot;{ro.getProducts.lastResult}&quot; width=&quot;100%&quot; height=&quot;100%&quot;/&gt;

&lt;/mx:Application&gt;
</pre>
<p>The configuration file looks like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;config&gt;
	&lt;channels&gt;
		&lt;channel id=&quot;amf&quot; endpoint=&quot;http://localhost:8400/lcds-samples/messagebroker/amf&quot;/&gt;
	&lt;/channels&gt;
&lt;/config&gt;
</pre>
<p>NOTE: With that type of runtime configuration in place, you can create plain Flex Builder projects (you can select None as the application server type).</p>
<p>This particular example is not extremely flexible. It assumes I will always work with an AMF channel and therefore the only thing my application needs to know at runtime is the AMF channel endpoint URL. For RemoteObject that’s a fairly safe bet, however for messaging-related classes (Producer and Consumer), you may also want to externalize the type of channel you use (AMF Polling, long polling, streaming, RTMP, etc.). Before you start creating that kind of dynamic configuration system, you may want to take a look at the <a href="http://www.pranaframework.org/">Flex ActionScript framework</a> that <a href="http://www.herrodius.com/blog/158">does that</a> very well.</p>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lcds/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lcds/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lcds/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Externalizing Service Configuration using BlazeDS and LCDS http://coenraets.org/blog/?p=113" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F03%2Fexternalizing-service-configuration-using-blazeds-and-lcds%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lcds/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Spring / BlazeDS Integration on Adobe TV</title>
		<link>http://coenraets.org/blog/2009/02/spring-blazeds-integration-on-adobe-tv/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=spring-blazeds-integration-on-adobe-tv</link>
		<comments>http://coenraets.org/blog/2009/02/spring-blazeds-integration-on-adobe-tv/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 16:09:34 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=105</guid>
		<description><![CDATA[In this new Adobe TV episode, I demonstrate how to build Flex applications that connect to a Spring back-end using the new Spring / BlazeDS Integration project. If you are interested in this integration, make sure you check out the Spring / BlazeDS Integration page on the SpringSource web site and the new Spring / [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Spring / BlazeDS Integration on Adobe TV http://coenraets.org/blog/?p=105" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F02%2Fspring-blazeds-integration-on-adobe-tv%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p>In this new Adobe TV episode, I demonstrate how to build Flex applications that connect to a Spring back-end using the new Spring / BlazeDS Integration project.</p>
<p>If you are interested in this integration, make sure you check out the <a href="http://www.springsource.org/spring-flex">Spring / BlazeDS Integration page</a> on the SpringSource web site and the <a href="http://coenraets.org/blog/2009/01/new-springblazeds-integration-test-drive/">new Spring / BlazeDS Integration Test Drive</a>.</p>
<p><embed src="http://tv.adobe.com/Embed.swf" quality="high" bgcolor="#000000" width="600" height="385" name="AdobeTVPlayer" play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" flashVars="v=~b64~aHR0cDovL2Fkb2JlLmVkZ2Vib3NzLm5ldC9mbGFzaC9hZG9iZS9hZG9iZXR2Mi9hZGNfcHJlc2VudHMvNjRfYWRjXzA5MC5mbHY/cnNzX2ZlZWRpZD0xNDcyJnhtbHZlcnM9Mg==&#038;w=600&#038;t=http://tv.adobe.com/#vi+f1472v1053&#038;h=385"></embed></p>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2009/02/spring-blazeds-integration-on-adobe-tv/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2009/02/spring-blazeds-integration-on-adobe-tv/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2009/02/spring-blazeds-integration-on-adobe-tv/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Spring / BlazeDS Integration on Adobe TV http://coenraets.org/blog/?p=105" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F02%2Fspring-blazeds-integration-on-adobe-tv%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/02/spring-blazeds-integration-on-adobe-tv/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Sample application using the Swiz Framework and BlazeDS</title>
		<link>http://coenraets.org/blog/2009/02/sample-application-using-the-swiz-framework-and-blazeds/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sample-application-using-the-swiz-framework-and-blazeds</link>
		<comments>http://coenraets.org/blog/2009/02/sample-application-using-the-swiz-framework-and-blazeds/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 18:30:28 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[Air]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[LCDS]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=101</guid>
		<description><![CDATA[There have been a lot of discussions around Flex Frameworks lately. Tony Hillerson has an interesting series here: 1 2 3 4 5 6 A relative newcomer on the list is Swiz, the work of Chris Scott. I figured I would give it a try, and create a Swiz version of the inSync application that [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Sample application using the Swiz Framework and BlazeDS http://coenraets.org/blog/?p=101" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F02%2Fsample-application-using-the-swiz-framework-and-blazeds%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p>There have been a lot of discussions around Flex Frameworks lately. Tony Hillerson has an interesting series here: <a href="http://www.insideria.com/2008/12/frameworkquest-2008-introducti.html">1</a> <a href="http://www.insideria.com/2008/12/frameworkquest-2008-part-2-get.html">2</a> <a href="http://www.insideria.com/2008/12/frameworkquest-2008-part-3-fra.html">3</a> <a href="http://www.insideria.com/2008/12/frameworkquest-2008-part-4-ioc.html">4</a> <a href="http://www.insideria.com/2008/12/frameworkquest-2008-part-5-mat.html">5</a> <a href="http://www.insideria.com/2009/01/frameworkquest-2008-part-6-the.html">6</a></p>
<p>A relative newcomer on the list is <a href="http://code.google.com/p/swizframework/">Swiz</a>, the work of <a href="http://cdscott.blogspot.com/">Chris Scott</a>. I figured I would give it a try, and create a Swiz version of the inSync application that I often use to try out and demonstrate different features and techniques in Flex and Adobe AIR. This is not an endorsement of Swiz over other frameworks. I simply wanted to share the sample application I built as part of my own research as a (neutral like a Swiss) Evangelist.</p>
<p><img src="http://coenraets.org/downloads/insync-swiz/insync-swiz.png"/></p>
<p><a href="http://coenraets.org/downloads/insync-swiz/srcview/index.html">View the source code</a>.</p>
<p><span id="more-101"></span></p>
<h3>Application Highlights:</h3>
<p>At his core, Swiz is a simple inversion of control framework. Using an IoC framework, the components of your application (for example, Views) don’t instantiate or even look up their dependencies (the objects they work with). The framework injects those dependencies when the components are created (hence the term “Dependency Injection” also used to describe this approach). The result is looser coupling and more reusable components. The components managed by the Swiz IoC framework are called beans.</p>
<h3>1. Defining your beans</h3>
<p>The beans of the inSync applications are defined in Beans.mxml:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;BeanLoader xmlns=&quot;org.swizframework.util.*&quot; xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:controllers=&quot;insync.controllers.*&quot;&gt;

    &lt;DynamicChannelSet id=&quot;myAmfChannel&quot;&gt;
		&lt;serverPort&gt;8400&lt;/serverPort&gt;
		&lt;contextRoot&gt;/lcds-samples&lt;/contextRoot&gt;
    &lt;/DynamicChannelSet&gt;

    &lt;mx:RemoteObject id=&quot;contactService&quot; destination=&quot;contacts&quot; channelSet=&quot;{myAmfChannel}&quot;/&gt;

    &lt;controllers:ContactController id=&quot;contactController&quot;/&gt;

&lt;/BeanLoader&gt;
</pre>
<h3>2. Bootstrapping Swiz</h3>
<p>You bootstrap Swiz in the preinitialize event of the application. You can have multiple Beans configuration classes. You pass your configuration classes in an array as an argument of the loadBeans function. In inSync, we have only one configuration class (Beans.mxml).</p>
<pre class="brush: jscript; title: ; notranslate">
Swiz.loadBeans( [Beans] );
</pre>
<h3>3. Injecting dependencies</h3>
<p>Swiz uses the [Autowire] custom metadata to inject beans into other beans and views.<br />
In inSync, the contactService RemoteObject is injected into ContactController.as as follows:</p>
<pre class="brush: jscript; title: ; notranslate">
[Autowire(bean=&quot;contactService&quot;)]
public var contactService:RemoteObject;
</pre>
<p>… and contactController is injected in the Views. For example, in ContactForm.mxml:</p>
<pre class="brush: jscript; title: ; notranslate">
[Autowire(bean=&quot;contactController&quot;)]
public var controller:IContactController;
</pre>
<p>Because we use an interface, the View is not coupled to a specific implementation of the controller. If you don’t like to have a reference to the controller in your view, keep reading…</p>
<h3>4. Dynamic Mediators</h3>
<p>Swiz is an IoC framework. Beyond that, it doesn’t force you to use any specific design pattern. So, if you don’t like to have a controller in your view, you can, for example, set up the view to dispatch events instead. For example, in the save() function of ContactForm.mxml, you would replace:</p>
<pre class="brush: jscript; title: ; notranslate">
controller.save(contact);
</pre>
<p>with:</p>
<pre class="brush: jscript; title: ; notranslate">
Swiz.dispatchEvent(ContactEvent.SAVE, contact);
</pre>
<p>You could then listen to this event in some &#8220;mediator&#8221; class using Swiz.addEventListener(ContactEvent.UPDATE, someHandler), but the dynamic mediator feature of Swiz allows you to automate this process. For example, you could annotate the save() function of the ContactController class as follows:</p>
<pre class="brush: jscript; title: ; notranslate">
[Mediate(event=&quot;ContactEvent.SAVE&quot;, properties=&quot;contact&quot;)]
public function save(contact:Contact):void
{
	executeServiceCall(contactService.save(contact), save_result, null, [contact]);
}
</pre>
<p>Swiz will automatically set up an event listener, invoke the annotated method when the event is dispatched, and pass the specified event properties (in this case: &#8220;contact&#8221;) as the function parameters.</p>
<h3>5. Prototypes</h3>
<p>By default, components defined in your Beans configuration classes are singletons. In other words, the same instance of a Bean gets injected everytime it is autowired. In some situations, you may want to inject a new instance of a Bean everytime it is autowired. For example, if you open multiple instances of the same View, you may decide you need one controller per view. Prototypes allow you to define non-singleton Beans in your Beans configuration class using the following syntax:</p>
<p>More on prototypes <a href="http://cdscott.blogspot.com/2009/01/more-swiz-features-or-swiz-005-part-2.html">here</a>.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;factory:Prototype xmlns:factory=&quot;org.swizframework.factory.*&quot;
        id=&quot;contactController&quot;
        className=&quot;insync.controllers.ContactController&quot;/&gt;
</pre>
<p></p>
<h3>Installation instructions:</h3>
<ol>
<li>Install the <a href="http://opensource.adobe.com/blazeds">BlazeDS turnkey server</a>. (To be clear: you don’t have to use BlazeDS to use Swiz… That’s just the sample I wanted to build.)</li>
<li>Download <a href="http://coenraets.org/downloads/insync-swiz/srcview/insync-swiz.zip">insync-swiz.zip</a>, and unzip it on your local file system.</li>
<li>Copy insync-swiz/java/classes/insync to blazeds/tomcat/webapps/samples/WEB-INF/classes/insync.</li>
<li>Add the following destination to blazeds/tomcat/webapps/samples/WEB-INF/flex/remoting-config.xml:</li>
<p><pre class="brush: xml; title: ; notranslate">
&lt;destination id=&quot;contacts&quot;&gt;
        &lt;properties&gt;
            &lt;source&gt;insync.dao.ContactDAO&lt;/source&gt;
            &lt;scope&gt;application&lt;/scope&gt;
        &lt;/properties&gt;
&lt;/destination&gt;
</pre>
</p>
<li>Copy insync-swiz/sampledb/insync to blazeds/sampledb/insync</li>
<li>Edit server.properties in blazeds/sampledb, and modify the file as follows to add the insync database to the startup procedure.
<p><pre class="brush: plain; title: ; notranslate">
server.database.0=file:flexdemodb/flexdemodb
server.dbname.0=flexdemodb
server.database.1=file:insync/insync
server.dbname.1=insync
server.port=9002
server.silent=true
server.trace=false
</pre>
</p>
</li>
<li>Start the database (startdb.bat or startdb.sh)</li>
<li>Start BlazeDS</li>
<li>In Flex Builder, create a new Flex project called insync-swiz. You don’t have to select any “Application server type”. </li>
<li>Copy the Swiz swc and the flexlib swc (used for the SuperTabNavigator) from insync-swiz/flex/lib to the lib directory of your project</li>
<li>Copy the files and folders from insync-swiz/flex/src to the src directory of your project</li>
<li>Open Beans.mxml and make sure the serverPort and contextRoot properties in DynamicChannelSet match your server setup.</li>
<li>Run the application</li>
</ol>
<h3>Summary</h3>
<p>Swiz was easy and enjoyable to work with. It is also non intrusive and definitely introduces some interesting ideas. A few lingering questions I didn’t have time to investigate&#8230;</p>
<ul>
<li>Swiz relies on introspection (describeType) to find its custom metadata in the objects added to the display list (with the exception of classes in the flash.* and mx.* packages). This has a performance impact. I’m not exactly sure how much of an impact it would have in real life apps yet…</li>
<li>How well does Swiz work with Modules or Marshall Plan subapplications?</li>
</ul>
<p>If you are looking for more information, check out the following resources:</p>
<ul>
<li><a href="http://link.brightcove.com/services/link/bcpid1753161885/bctid1738803894">Chris Scott’s presentation at Flex 360</a></li>
<li><a href="http://code.google.com/p/swizframework/wiki/GettingStarted">Getting Started</a></li>
<li><a href="http://cdscott.blogspot.com/">Chris Scott’s blog</a></li>
<li><a href="http://soenkerohde.com/2008/09/swiz-framework-brutally-simple/">Sönke Rohde’s blog</a></li>
</ul>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2009/02/sample-application-using-the-swiz-framework-and-blazeds/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2009/02/sample-application-using-the-swiz-framework-and-blazeds/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2009/02/sample-application-using-the-swiz-framework-and-blazeds/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ Sample application using the Swiz Framework and BlazeDS http://coenraets.org/blog/?p=101" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F02%2Fsample-application-using-the-swiz-framework-and-blazeds%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/02/sample-application-using-the-swiz-framework-and-blazeds/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>New Spring/BlazeDS Integration Test Drive</title>
		<link>http://coenraets.org/blog/2009/01/new-springblazeds-integration-test-drive/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-springblazeds-integration-test-drive</link>
		<comments>http://coenraets.org/blog/2009/01/new-springblazeds-integration-test-drive/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 16:54:16 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[Air]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=99</guid>
		<description><![CDATA[UPDATE: I posted a new version of the Test Drive for the M2 build of the Spring / BlazeDS integration project here. Please use that version. SpringSource recently announced the Spring / BlazeDS Integration project. You can read more about the project and download the bits at http://www.springsource.org/spring-flex. To help developers get started with the [...]
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ New Spring/BlazeDS Integration Test Drive http://coenraets.org/blog/?p=99" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F01%2Fnew-springblazeds-integration-test-drive%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: I posted a new version of the Test Drive for the M2 build of the Spring / BlazeDS integration project <a href="http://coenraets.org/blog/2009/03/springblazeds-integration-test-drive-m2-update-available/">here</a>. Please use that version.</strong></p>
<p>SpringSource recently announced the Spring / BlazeDS Integration project. You can read more about the project and download the bits at <a href="http://www.springsource.org/spring-flex">http://www.springsource.org/spring-flex</a>.</p>
<p>To help developers get started with the integration, I put together a new &#8220;Spring / BlazeDS Test Drive&#8221;. This Test Drive consists of a minimal version of Tomcat with BlazeDS and the “Spring / BlazeDS integration” preconfigured and ready to use. It also includes a series of samples running “out-of-the-box”  that should allow you to get up and running integrating Flex (and Adobe AIR) with Spring in  minutes.</p>
<h3>Installation Instructions:</h3>
<ol>
<li>Download the Spring / Flex TestDrive here: <a href="http://coenraets.org/downloads/spring-flex-testdrive.zip">http://coenraets.org/downloads/spring-flex-testdrive.zip</a></li>
<li>Unzip it in your root directory</li>
<li>Navigate to /spring-flex-testdrive/tomcat/bin and start Tomcat (for instance: catalina run)</li>
<li>Open a browser and access http://localhost:8080</li>
<li>Follow the instructions</li>
</ol>
<p>As always, I&#8217;d would love to hear your feedback and your ideas to improve this Test Drive.</p>
<p>Christophe</p>
<p>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"  data-lang="en"  data-url="http://coenraets.org/blog/2009/01/new-springblazeds-integration-test-drive/"></a>
<!-- End WP Socializer Plugin - Retweet Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - +1 Button -->
<g:plusone size="medium" href="http://coenraets.org/blog/2009/01/new-springblazeds-integration-test-drive/" ></g:plusone>
<!-- End WP Socializer Plugin - +1 Button -->
</span>
	<span class="margin5">
<!-- Start WP Socializer Plugin - Facebook Button -->
<iframe src="http://www.facebook.com/plugins/like.php?&amp;href=http://coenraets.org/blog/2009/01/new-springblazeds-integration-test-drive/&amp;layout=button_count&amp;show_faces=0&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>
<!-- End WP Socializer Plugin - Facebook Button -->
</span>
</p>
<p>
<a href="https://twitter.com/ccoenraets" class="twitter-follow-button" data-show-count="false" data-lang="en" data-size="large">Follow @ccoenraets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
	
<!-- Start WP Socializer Plugin - Retweet Button -->
<a href="http://twitter.com/?status=RT @ New Spring/BlazeDS Integration Test Drive http://coenraets.org/blog/?p=99" target="_blank">Retweet this</a>
<!-- End WP Socializer Plugin - Retweet Button -->

	
	
<!-- Start WP Socializer Plugin - Facebook Button -->
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fcoenraets.org%2Fblog%2F2009%2F01%2Fnew-springblazeds-integration-test-drive%2F" target="_blank">Share on Facebook</a>
<!-- End WP Socializer Plugin - Facebook Button -->



Follow @ccoenraets
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/01/new-springblazeds-integration-test-drive/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
	</channel>
</rss>

