<?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"
	>

<channel>
	<title>Christophe Coenraets</title>
	<atom:link href="http://coenraets.org/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://coenraets.org/blog</link>
	<description>Rich Internet Applications, Flex, AIR, Java</description>
	<pubDate>Tue, 26 May 2009 17:29:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Building the Server-Side of the &#8220;Tour de Flex&#8221; Real-Time Dashboard</title>
		<link>http://coenraets.org/blog/2009/05/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 [...]]]></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>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.adobe.tdf</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.PrintWriter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletConfig</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServlet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletRequest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletResponse</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.maxmind.geoip.Location</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.maxmind.geoip.LookupService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flex.messaging.MessageBroker</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flex.messaging.messages.AsyncMessage</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flex.messaging.util.UUIDUtils</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> TDFServlet <span style="color: #000000; font-weight: bold;">extends</span> HttpServlet <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Unique clientID for the message service</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> clientID <span style="color: #339933;">=</span> UUIDUtils.<span style="color: #006633;">createUUID</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;">// The geocoding service</span>
	<span style="color: #000000; font-weight: bold;">protected</span> LookupService lookupService<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// A DAO to store sample requests in a database</span>
	<span style="color: #000000; font-weight: bold;">protected</span> SampleRequestDAO dao <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SampleRequestDAO<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;">// The LCDS message broker</span>
	<span style="color: #000000; font-weight: bold;">protected</span> MessageBroker messageBroker<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// The LCDS messaging destination where real time sample requests information is pushed</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">String</span> destination<span style="color: #339933;">;</span> 
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException <span style="color: #009900;">&#123;</span>
&nbsp;
		ServletConfig config <span style="color: #339933;">=</span> getServletConfig<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		destination <span style="color: #339933;">=</span> config.<span style="color: #006633;">getInitParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;messaging.destination.name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> path <span style="color: #339933;">=</span> config.<span style="color: #006633;">getInitParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;geocoding.database.path&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// Load the geocoding database in init() to make sure we load it only once</span>
			lookupService <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LookupService<span style="color: #009900;">&#40;</span>path, LookupService.<span style="color: #006633;">GEOIP_MEMORY_CACHE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// We swallow the exception here. If the database is not available, the feed</span>
			<span style="color: #666666; font-style: italic;">// will still work but won't provide the location info.</span>
		<span style="color: #009900;">&#125;</span>	
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>messageBroker <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			messageBroker <span style="color: #339933;">=</span> MessageBroker.<span style="color: #006633;">getMessageBroker</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		SampleRequest sampleRequest <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SampleRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			sampleRequest.<span style="color: #006633;">setSampleId</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sampleId&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">String</span> message <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;A valid sampleId is required to process this request&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">RuntimeException</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		sampleRequest.<span style="color: #006633;">setTimestamp</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">String</span> ipAddress <span style="color: #339933;">=</span> request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ipAddress&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Geolocate the IP address and add the info to the message</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>lookupService <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> ipAddress <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
	                Location location <span style="color: #339933;">=</span> lookupService.<span style="color: #006633;">getLocation</span><span style="color: #009900;">&#40;</span>ipAddress<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>location <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				sampleRequest.<span style="color: #006633;">setLatitude</span><span style="color: #009900;">&#40;</span>location.<span style="color: #006633;">latitude</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				sampleRequest.<span style="color: #006633;">setLongitude</span><span style="color: #009900;">&#40;</span>location.<span style="color: #006633;">longitude</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				sampleRequest.<span style="color: #006633;">setCountry</span><span style="color: #009900;">&#40;</span>location.<span style="color: #006633;">countryCode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				sampleRequest.<span style="color: #006633;">setCity</span><span style="color: #009900;">&#40;</span>location.<span style="color: #006633;">city</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			dao.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>sampleRequest, ipAddress<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">RuntimeException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #003399;">String</span> subtopic <span style="color: #339933;">=</span> request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;subtopic&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>subtopic <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> subtopic <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;flex&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Publish the message to specified destination and subtopic.</span>
		AsyncMessage msg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AsyncMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		msg.<span style="color: #006633;">setDestination</span><span style="color: #009900;">&#40;</span>destination<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		msg.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DSSubtopic&quot;</span>, subtopic<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		msg.<span style="color: #006633;">setClientId</span><span style="color: #009900;">&#40;</span>clientID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		msg.<span style="color: #006633;">setMessageId</span><span style="color: #009900;">&#40;</span>UUIDUtils.<span style="color: #006633;">createUUID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		msg.<span style="color: #006633;">setTimestamp</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		msg.<span style="color: #006633;">setBody</span><span style="color: #009900;">&#40;</span>sampleRequest<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		messageBroker.<span style="color: #006633;">routeMessageToService</span><span style="color: #009900;">&#40;</span>msg, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">PrintWriter</span> out <span style="color: #339933;">=</span> response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;html&gt;&lt;body&gt;ok&lt;/body&gt;&lt;/html&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<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>
<h4>Channels</h4>
<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>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:ChannelSet</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;channelSet&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:RTMPChannel</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;rtmp&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;rtmp://hostname:2037&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:AMFChannel</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://hostname/context/messagebroker/amflongpolling&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:AMFChannel</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://hostname/context/messagebroker/amfpolling&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:ChannelSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/05/tdfdashboard/feed/</wfw:commentRss>
		</item>
		<item>
		<title>“Model Driven Development with Flash Builder 4 and LCDS 3” at Flex 360 Indianapolis</title>
		<link>http://coenraets.org/blog/2009/05/%e2%80%9cmodel-driven-development-with-flash-builder-4-and-lcds-3%e2%80%9d-at-flex-360-indianapolis/</link>
		<comments>http://coenraets.org/blog/2009/05/%e2%80%9cmodel-driven-development-with-flash-builder-4-and-lcds-3%e2%80%9d-at-flex-360-indianapolis/#comments</comments>
		<pubDate>Sat, 16 May 2009 02:23:09 +0000</pubDate>
		<dc:creator>christophe</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=120</guid>
		<description><![CDATA[I’ll be presenting two sessions at Flex 360 Indianapolis next week.
In the “Flex / BlazeDS Integration Project”  session (Monday), I’ll provide a brief introduction of the Spring framework and the “Dependency Injection” pattern, followed by a deep dive into the brand new “Spring / BlazeDS integration project”.
My second session (on Wednesday) is “Model Driven [...]]]></description>
			<content:encoded><![CDATA[<p>I’ll be presenting two sessions at Flex 360 Indianapolis next week.</p>
<p>In the “Flex / BlazeDS Integration Project”  session (Monday), I’ll provide a brief introduction of the Spring framework and the “Dependency Injection” pattern, followed by a deep dive into the brand new “<a href="http://www.springsource.org/spring-flex">Spring / BlazeDS integration project</a>”.</p>
<p>My second session (on Wednesday) is “Model Driven Development with Flash Builder 4 and LCDS 3”. (The next version of Flex Builder will be named Flash Builder 4. The name of the Flex framework and the Flex SDK doesn’t change: it’s still Flex). In this session I will present a new and exciting feature in Flash Builder 4 and LiveCycle Data Services 3. Using the combination of these two products, you can build data-driven applications using a Model-Driven Development approach. In other words, you don’t have to write any server-side code: the data access logic is derived from a simple data model that is easily created and updated using new tooling in Flash Builder 4. This solution is designed to work for simple and very complex applications. I presented a sneak peek of this new feature at MAX last year, and we made a lot of progress since then.</p>
<p>I hope to see you there.</p>
<p>Christophe</p>
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/05/%e2%80%9cmodel-driven-development-with-flash-builder-4-and-lcds-3%e2%80%9d-at-flex-360-indianapolis/feed/</wfw:commentRss>
		</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/</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 the [...]]]></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>
<div style="height:300px;overflow: scroll;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">flex.spring.samples.company</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.ResultSet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.SQLException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.sql.DataSource</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.flex.remoting.RemotingDestination</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.flex.remoting.RemotingExclude</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.flex.remoting.RemotingInclude</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.annotation.Autowired</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.stereotype.Service</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.jdbc.core.simple.ParameterizedRowMapper</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.jdbc.core.simple.SimpleJdbcInsert</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.jdbc.core.simple.SimpleJdbcTemplate</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flex.spring.samples.industry.IIndustryDAO</span><span style="color: #339933;">;</span>
&nbsp;
@Service<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;companyService&quot;</span><span style="color: #009900;">&#41;</span>
@RemotingDestination<span style="color: #009900;">&#40;</span>channels<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;my-amf&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CompanyDAO <span style="color: #000000; font-weight: bold;">implements</span> ICompanyDAO <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> SimpleJdbcTemplate template<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> SimpleJdbcInsert insertCompany<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> IIndustryDAO industryDAO<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> ParameterizedRowMapper<span style="color: #339933;">&lt;</span>Company<span style="color: #339933;">&gt;</span> rowMapper <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ParameterizedRowMapper<span style="color: #339933;">&lt;</span>Company<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">public</span> Company mapRow<span style="color: #009900;">&#40;</span><span style="color: #003399;">ResultSet</span> rs, <span style="color: #000066; font-weight: bold;">int</span> rowNum<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
			Company company <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Company<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			company.<span style="color: #006633;">setId</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			company.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			company.<span style="color: #006633;">setAddress</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			company.<span style="color: #006633;">setCity</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;city&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			company.<span style="color: #006633;">setState</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;state&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			company.<span style="color: #006633;">setZip</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;zip&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			company.<span style="color: #006633;">setPhone</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;phone&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			company.<span style="color: #006633;">setIndustry</span><span style="color: #009900;">&#40;</span>industryDAO.<span style="color: #006633;">findById</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;industry_id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">return</span> company<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	@Autowired
	<span style="color: #000000; font-weight: bold;">public</span> CompanyDAO<span style="color: #009900;">&#40;</span>DataSource dataSource, IIndustryDAO industryDAO<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		template <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleJdbcTemplate<span style="color: #009900;">&#40;</span>dataSource<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		insertCompany <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleJdbcInsert<span style="color: #009900;">&#40;</span>dataSource<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">withTableName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;COMPANY&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">usingGeneratedKeyColumns</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ID&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">industryDAO</span> <span style="color: #339933;">=</span> industryDAO<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@RemotingInclude
	<span style="color: #000000; font-weight: bold;">public</span> Company findById<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> template.<span style="color: #006633;">queryForObject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM company WHERE id=?&quot;</span>, rowMapper, id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@RemotingInclude
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Company<span style="color: #339933;">&gt;</span> findAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> template.<span style="color: #006633;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM company ORDER BY name&quot;</span>, rowMapper<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@RemotingInclude
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Company<span style="color: #339933;">&gt;</span> findByName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> template.<span style="color: #006633;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM company WHERE UPPER(name) LIKE ? ORDER BY name&quot;</span>,
				rowMapper,
				<span style="color: #0000ff;">&quot;%&quot;</span> <span style="color: #339933;">+</span> name.<span style="color: #006633;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;%&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@RemotingInclude
	<span style="color: #000000; font-weight: bold;">public</span> Company create<span style="color: #009900;">&#40;</span>Company company<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		Map<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span> parameters <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parameters.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span>, company.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parameters.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;address&quot;</span>, company.<span style="color: #006633;">getAddress</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parameters.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;city&quot;</span>, company.<span style="color: #006633;">getCity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parameters.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;state&quot;</span>, company.<span style="color: #006633;">getState</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parameters.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;zip&quot;</span>, company.<span style="color: #006633;">getZip</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parameters.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;phone&quot;</span>, company.<span style="color: #006633;">getPhone</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parameters.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;industry_id&quot;</span>, company.<span style="color: #006633;">getIndustry</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">Number</span> id <span style="color: #339933;">=</span> insertCompany.<span style="color: #006633;">executeAndReturnKey</span><span style="color: #009900;">&#40;</span>parameters<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		company.<span style="color: #006633;">setId</span><span style="color: #009900;">&#40;</span>id.<span style="color: #006633;">intValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> company<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@RemotingInclude
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> update<span style="color: #009900;">&#40;</span>Company company<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> count <span style="color: #339933;">=</span> template.<span style="color: #006633;">update</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UPDATE company SET name=?, address=?, city=?, state=?, zip=?, phone=?, industry_id=? WHERE id=?&quot;</span>, 
				company.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				company.<span style="color: #006633;">getAddress</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				company.<span style="color: #006633;">getCity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				company.<span style="color: #006633;">getState</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				company.<span style="color: #006633;">getZip</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				company.<span style="color: #006633;">getPhone</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				company.<span style="color: #006633;">getIndustry</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				company.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>count <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@RemotingExclude
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> remove<span style="color: #009900;">&#40;</span>Company company<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> count <span style="color: #339933;">=</span> template.<span style="color: #006633;">update</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DELETE FROM company WHERE id=?&quot;</span>, company.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>count <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<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>

<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;flex:message-destination</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;chat&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>And here is how you configure a destination mapped to a JMS topic:</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;flex:jms-message-destination</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;jms-chat&quot;</span> <span style="color: #000066;">jms-destination</span>=<span style="color: #ff0000;">&quot;chatTopic&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

</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>
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/05/new-update-to-the-spring-blazeds-integration-test-drive/feed/</wfw:commentRss>
		</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/</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[]]></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 - 1 Network Way, Burlington, MA<br />
<a href="http://www.nejug.org/events/show/93">NEJUG Link</a></p>
]]></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>
		</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/</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 and Security samples, [...]]]></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>
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/05/new-test-drive-for-spring-blazeds-integration-rc1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Version of Salesbuilder with Ribbit Integration: Source Code Available</title>
		<link>http://coenraets.org/blog/2009/04/new-version-of-salesbuilder-with-ribbit-integration-source-code-available/</link>
		<comments>http://coenraets.org/blog/2009/04/new-version-of-salesbuilder-with-ribbit-integration-source-code-available/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 17:25:31 +0000</pubDate>
		<dc:creator>christophe</dc:creator>
		
		<category><![CDATA[Air]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[KapIT]]></category>

		<category><![CDATA[Ribbit]]></category>

		<category><![CDATA[ilog]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=116</guid>
		<description><![CDATA[Many people have asked for the source code of the new version of Salesbuilder that includes Ribbit (phone service) integration, an offline calendar (using the ILog component), and the KapIT visualizer component.
You can now download the source code here.
As a reminder, you can watch a screencast showing the key features of the application here (go [...]]]></description>
			<content:encoded><![CDATA[<p>Many people have asked for the source code of the <a href="http://coenraets.org/blog/2009/03/make-and-receive-phone-calls-in-the-new-version-of-the-salesbuilder-sample-flex-application/">new version of Salesbuilder</a> that includes Ribbit (phone service) integration, an offline calendar (using the ILog component), and the KapIT visualizer component.</p>
<p>You can now download the source code <a href="http://coenraets.org/apps/salesbuilder2/salesbuilder-v2.zip">here</a>.</p>
<p>As a reminder, you can watch a screencast showing the key features of the application <a href="http://vimeo.com/3882718">here</a> (go full screen for a better viewing experience. Also make sure HD is on).</p>
<p>You must create a <a href="http://developer.ribbit.com/">Ribbit developer account</a> (free) to be able to use the phone service. Once you have a Ribbit account, click the Options menu item in Salesbuilder and enter your Ribbit user id and password.</p>
<p>You will also need to <a href="http://www.ilog.fr/elixir">install the ILog swc</a> if you want to compile the application.</p>
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/04/new-version-of-salesbuilder-with-ribbit-integration-source-code-available/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My New Spring BlazeDS Integration Article Live on DZone</title>
		<link>http://coenraets.org/blog/2009/04/my-new-spring-blazeds-integration-article-live-on-dzone/</link>
		<comments>http://coenraets.org/blog/2009/04/my-new-spring-blazeds-integration-article-live-on-dzone/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 21:17:49 +0000</pubDate>
		<dc:creator>christophe</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=115</guid>
		<description><![CDATA[http://ria.dzone.com/articles/introduction-spring-blazeds
]]></description>
			<content:encoded><![CDATA[<p><a href="http://ria.dzone.com/articles/introduction-spring-blazeds">http://ria.dzone.com/articles/introduction-spring-blazeds</a></p>
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/04/my-new-spring-blazeds-integration-article-live-on-dzone/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Make and Receive Phone Calls in the New Version of the Salesbuilder Sample Flex Application</title>
		<link>http://coenraets.org/blog/2009/03/make-and-receive-phone-calls-in-the-new-version-of-the-salesbuilder-sample-flex-application/</link>
		<comments>http://coenraets.org/blog/2009/03/make-and-receive-phone-calls-in-the-new-version-of-the-salesbuilder-sample-flex-application/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 18:22:30 +0000</pubDate>
		<dc:creator>christophe</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=114</guid>
		<description><![CDATA[I updated my Salesbuilder sample Flex/Adobe AIR application with a couple of new interesting features:

Ribbit integration: allows you to make and receive calls from within the application
KapIt Visualizer component to represent the org chart
ILog calendar component





I recorded a quick screencast to show the new (and previous features) of the application. You can watch it in [...]]]></description>
			<content:encoded><![CDATA[<p>I updated my Salesbuilder sample Flex/Adobe AIR application with a couple of new interesting features:</p>
<ol>
<li><a href="http://www.ribbit.com/">Ribbit </a>integration: allows you to make and receive calls from within the application</li>
<li><a href="http://labs.kapit.fr">KapIt Visualizer</a> component to represent the org chart</li>
<li><a href="http://www.ilog.com/products/ilogelixir/">ILog</a> calendar component</li>
</ol>
<p><img src="http://coenraets.org/apps/salesbuilder2/salesbuilder2.gif" alt="" /></p>
<p><span id="more-114"></span></p>
<p><img src="http://coenraets.org/apps/salesbuilder2/salesbuilder1.gif" alt="" /></p>
<p><img src="http://coenraets.org/apps/salesbuilder2/salesbuilder3.gif" alt="" /></p>
<p>I recorded a quick screencast to show the new (and previous features) of the application. You can watch it in the player below, however, I highly recommend you click <a href="http://vimeo.com/3882718">here</a> to watch it in HD (go full screen for a better viewing experience. Also make sure HD is on).</p>
<p><object width="640" height="360"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3882718&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3882718&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="360"></embed></object>
<p>Click on the badge below to install the application.</p>
<p><div id="flashcontent1244" style="width:215px; height:180px;"><strong>Please upgrade your Flash Player</strong> This is the content that would be shown if the user does not have Flash Player 9.0.115 or higher installed.</div><script type="text/javascript">
// <![CDATA[
var so = new SWFObject("http://coenraets.org/blog/wp-content/plugins/air-badge/AIRInstallBadge.swf", "Badge", "215", "180", "9.0.115", "#FFFFFF");
so.useExpressInstall("http://coenraets.org/blog/wp-content/plugins/air-badge/expressinstall.swf");
so.addVariable("airversion", "1.0");
so.addVariable("appname", "Salesbuilder");
so.addVariable("appurl", "http://coenraets.org/apps/salesbuilder2/salesbuilder.air");
so.addVariable("appid", "Salesbuilder");
so.addVariable("pubid", "");
so.addVariable("appversion", "1.5");
so.addVariable("imageurl", "http://coenraets.org/apps/salesbuilder2/salesbuilder1.gif");
so.addVariable("appinstallarg", "installed from web");
so.addVariable("applauncharg", "launched from web");
so.addVariable("helpurl", "help.html");
so.addVariable("hidehelp", "true");
so.addVariable("skiptransition", "false");
so.addVariable("titlecolor", "#00AAFF");
so.addVariable("buttonlabelcolor", "#00AAFF");
so.addVariable("appnamecolor", "#00AAFF");
so.addVariable("str_err_airswf", "<u>Running locally?</u><br/><br/>The AIR proxy swf won't load properly when this demo is run from the local file system.");
so.write("flashcontent1244");
// ]]&gt;
</script>
</p>
<p>NOTE: You must create a <a href="http://developer.ribbit.com/">Ribbit developer account</a> (free) to be able to use the phone service. Once you have a Ribbit account, click the Options menu item in Salesbuilder and enter your Ribbit user id and password.</p>
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/03/make-and-receive-phone-calls-in-the-new-version-of-the-salesbuilder-sample-flex-application/feed/</wfw:commentRss>
		</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/</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 related [...]]]></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>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> channelSet:ChannelSet = <span style="color: #000000; font-weight: bold;">new</span> ChannelSet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> channel:AMFChannel = <span style="color: #000000; font-weight: bold;">new</span> AMFChannel<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;my-amf&quot;</span>, <span style="color: #ff0000;">&quot;http://localhost:8400/lcds-samples/messagebroker/amf&quot;</span><span style="color: #66cc66;">&#41;</span>;
channelSet.<span style="color: #006600;">addChannel</span><span style="color: #66cc66;">&#40;</span>channel<span style="color: #66cc66;">&#41;</span>;
remoteObject.<span style="color: #006600;">channelSet</span> = channelSet;</pre></td></tr></table></div>

<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>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span>
	applicationComplete=<span style="color: #ff0000;">&quot;configSrv.send()&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">channels</span>.<span style="color: #006600;">AMFChannel</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">ChannelSet</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> channelSet:ChannelSet;
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> configResultHandler<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">xml</span>:<span style="color: #0066CC;">XML</span> = event.<span style="color: #006600;">result</span> as <span style="color: #0066CC;">XML</span>;
		<span style="color: #000000; font-weight: bold;">var</span> amfEndpoint:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span> + <span style="color: #0066CC;">xml</span>..<span style="color: #006600;">channel</span>.<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">@</span>id==<span style="color: #ff0000;">&quot;amf&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #66cc66;">@</span>endpoint;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>amfEndpoint == <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;amf channel not configured&quot;</span>, <span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #66cc66;">&#41;</span>;					
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #66cc66;">&#123;</span>
			channelSet = <span style="color: #000000; font-weight: bold;">new</span> ChannelSet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> channel:AMFChannel = <span style="color: #000000; font-weight: bold;">new</span> AMFChannel<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;my-amf&quot;</span>, amfEndpoint<span style="color: #66cc66;">&#41;</span>;
			channelSet.<span style="color: #006600;">addChannel</span><span style="color: #66cc66;">&#40;</span>channel<span style="color: #66cc66;">&#41;</span>;
			ro.<span style="color: #006600;">channelSet</span> = channelSet;
			ro.<span style="color: #006600;">getProducts</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:HTTPService id=<span style="color: #ff0000;">&quot;configSrv&quot;</span> <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">&quot;config.xml&quot;</span> resultFormat=<span style="color: #ff0000;">&quot;e4x&quot;</span> result=<span style="color: #ff0000;">&quot;configResultHandler(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:RemoteObject id=<span style="color: #ff0000;">&quot;ro&quot;</span> destination=<span style="color: #ff0000;">&quot;product&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:DataGrid dataProvider=<span style="color: #ff0000;">&quot;{ro.getProducts.lastResult}&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>The configuration file looks like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>config<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>channels<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>channel id=<span style="color: #ff0000;">&quot;amf&quot;</span> endpoint=<span style="color: #ff0000;">&quot;http://localhost:8400/lcds-samples/messagebroker/amf&quot;</span><span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>channels<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>config<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<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>
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lcds/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Spring ActionScript Framework &#8212; Part 3: Injecting Services (and Mock Services)</title>
		<link>http://coenraets.org/blog/2009/03/the-spring-actionscript-framework-part-3-injecting-services-and-mock-services/</link>
		<comments>http://coenraets.org/blog/2009/03/the-spring-actionscript-framework-part-3-injecting-services-and-mock-services/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 16:35:44 +0000</pubDate>
		<dc:creator>christophe</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://coenraets.org/blog/?p=112</guid>
		<description><![CDATA[In part 1 of this series, we saw how Flex AS allows you to externalize the configuration and the wiring of objects. In part 2, we discussed how you can &#8220;autowire&#8221; view properties. We intentionally kept the example simplistic by directly injecting the contact RemoteObject into the views. In real life, however, you generally don’t [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://coenraets.org/blog/2009/03/the-%E2%80%9Cspring-actionscript%E2%80%9D-framework-%E2%80%93-part-1-the-basics/">part 1</a> of this series, we saw how Flex AS allows you to externalize the configuration and the wiring of objects. In <a href="http://coenraets.org/blog/2009/03/the-spring-actionscript-framework-%E2%80%93-part-2-autowiring/">part 2</a>, we discussed how you can &#8220;autowire&#8221; view properties. We intentionally kept the example simplistic by directly injecting the contact RemoteObject into the views. In real life, however, you generally don’t want to tie your views to a specific service implementation… The views should be independent from your data access strategy: RemoteObject, HTTPService, WebService, mock service, etc.</p>
<p>To satisfy this requirement, we will create an IContactService interface, and two classes that implement that interface:</p>
<ol>
<li><strong>ContactRemoteObjectService</strong> uses RemoteObject to access contact data</li>
<li><strong>ContactMockService</strong> encapsulates mock data as a way of testing the application without backend data</li>
</ol>
<p>For the purpose of this sample application, IContactService is defined as follows:</p>
<p><span id="more-112"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package insync.<span style="color: #006600;">services</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> insync.<span style="color: #006600;">model</span>.<span style="color: #006600;">Contact</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncToken</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IContactService
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> getContactsByName<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:AsyncToken;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> save<span style="color: #66cc66;">&#40;</span>contact:Contact<span style="color: #66cc66;">&#41;</span>:AsyncToken;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> remove<span style="color: #66cc66;">&#40;</span>contact:Contact<span style="color: #66cc66;">&#41;</span>:AsyncToken;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>ContactRemoteObjectService is implemented as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package insync.<span style="color: #006600;">services</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> insync.<span style="color: #006600;">model</span>.<span style="color: #006600;">Contact</span>;
&nbsp;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncResponder</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncToken</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">FaultEvent</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">remoting</span>.<span style="color: #006600;">mxml</span>.<span style="color: #006600;">RemoteObject</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ContactRemoteObjectService <span style="color: #0066CC;">implements</span> IContactService
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> remoteObject:RemoteObject;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ContactRemoteObjectService<span style="color: #66cc66;">&#40;</span>remoteObject:RemoteObject<span style="color: #66cc66;">&#41;</span> 
	<span style="color: #66cc66;">&#123;</span>
    		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">remoteObject</span> = remoteObject;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> save<span style="color: #66cc66;">&#40;</span>contact:Contact<span style="color: #66cc66;">&#41;</span>:AsyncToken
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> token:AsyncToken = remoteObject.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;
		token.<span style="color: #006600;">contact</span> = contact;
        	token.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span>save_result, faultHandler<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        	<span style="color: #b1b100;">return</span> token;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> remove<span style="color: #66cc66;">&#40;</span>contact:Contact<span style="color: #66cc66;">&#41;</span>:AsyncToken
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> token:AsyncToken = remoteObject.<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;
	        token.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span>remove_result, faultHandler<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        	<span style="color: #b1b100;">return</span> token;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getContactsByName<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:AsyncToken
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> token:AsyncToken = remoteObject.<span style="color: #006600;">getContactsByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>;
	        token.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span>getContactsByName_result, faultHandler<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        	<span style="color: #b1b100;">return</span> token;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">/* Result Handlers ---------------------------------------------------------------*/</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> save_result<span style="color: #66cc66;">&#40;</span>event:ResultEvent, token:AsyncToken=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">// For a create operation, assign the generated primary key to the id property </span>
		<span style="color: #808080; font-style: italic;">// of the contact object</span>
		event.<span style="color: #006600;">token</span>.<span style="color: #006600;">contact</span>.<span style="color: #006600;">id</span> = event.<span style="color: #006600;">result</span>.<span style="color: #006600;">id</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// Dispatch an event on the async token. This allows the caller of the method to register as</span>
		<span style="color: #808080; font-style: italic;">// a listener for the result event of the specific method call. (See ContactForm.mxml for an example.</span>
		event.<span style="color: #006600;">token</span>.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>		
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> remove_result<span style="color: #66cc66;">&#40;</span>event:ResultEvent, token:AsyncToken=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
	<span style="color: #66cc66;">&#123;</span>
		event.<span style="color: #006600;">token</span>.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>		
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getContactsByName_result<span style="color: #66cc66;">&#40;</span>event:ResultEvent, token:AsyncToken=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
	<span style="color: #66cc66;">&#123;</span>
		event.<span style="color: #006600;">token</span>.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
    	<span style="color: #66cc66;">&#125;</span>		
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> faultHandler<span style="color: #66cc66;">&#40;</span>event:FaultEvent, token:AsyncToken=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
    	<span style="color: #66cc66;">&#123;</span>
    		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">fault</span>.<span style="color: #006600;">faultString</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> + event.<span style="color: #006600;">fault</span>.<span style="color: #006600;">faultDetail</span>, <span style="color: #ff0000;">&quot;Error Invoking RemoteObject&quot;</span><span style="color: #66cc66;">&#41;</span>;
    	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>NOTE: There is nothing specific to the Spring AS framework in this class, except that the remoteObject property will be injected by the framework. This simple implementation is tied to the Flex framework and specifically the rpc API: the contract between the service and other components of the application relies on mx.rpc classes (AsyncToken and ResultEvent).   You can replace this basic implementation with your own. Spring AS also provides an abstraction API for working with asynchronous method calls that is not tied to the Flex framework (see the AbstractRemoteObjectService class).  Spring AS aims to be an AS framework and not specifically a Flex framework.</p>
<p>ContactMockService is implemented as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package insync.<span style="color: #006600;">services</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> insync.<span style="color: #006600;">model</span>.<span style="color: #006600;">Contact</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncResponder</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncToken</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ContactMockService <span style="color: #0066CC;">extends</span> MockService <span style="color: #0066CC;">implements</span> IContactService
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> contacts:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> nextId:<span style="color: #0066CC;">int</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ContactMockService<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> contact:Contact = <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		contact.<span style="color: #006600;">id</span> = <span style="color: #cc66cc;">1</span>;
		contact.<span style="color: #006600;">firstName</span> = <span style="color: #ff0000;">&quot;Christophe&quot;</span>; 
		contact.<span style="color: #006600;">lastName</span> = <span style="color: #ff0000;">&quot;Coenraets&quot;</span>;
		contacts.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		contact = <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
		contact.<span style="color: #006600;">id</span> = <span style="color: #cc66cc;">2</span>;
		contact.<span style="color: #006600;">firstName</span> = <span style="color: #ff0000;">&quot;Lisa&quot;</span>; 
		contact.<span style="color: #006600;">lastName</span> = <span style="color: #ff0000;">&quot;Taylor&quot;</span>;
		contacts.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		contact = <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
		contact.<span style="color: #006600;">id</span> = <span style="color: #cc66cc;">3</span>;
		contact.<span style="color: #006600;">firstName</span> = <span style="color: #ff0000;">&quot;John&quot;</span>; 
		contact.<span style="color: #006600;">lastName</span> = <span style="color: #ff0000;">&quot;Smith&quot;</span>;
		contacts.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		nextId = <span style="color: #cc66cc;">4</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> save<span style="color: #66cc66;">&#40;</span>contact:Contact<span style="color: #66cc66;">&#41;</span>:AsyncToken
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>contact.<span style="color: #006600;">id</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// New contact</span>
		<span style="color: #66cc66;">&#123;</span>
			contact.<span style="color: #006600;">id</span> = nextId++;
			contacts.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">var</span> token:AsyncToken = createToken<span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;
        	token.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span>resultHandler, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        	<span style="color: #b1b100;">return</span> token;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> remove<span style="color: #66cc66;">&#40;</span>contact:Contact<span style="color: #66cc66;">&#41;</span>:AsyncToken
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> result:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>contacts.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> current:Contact = contacts.<span style="color: #006600;">getItemAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span> as Contact;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>current.<span style="color: #006600;">id</span> == contact.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				contacts.<span style="color: #006600;">removeItemAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">break</span>;
			<span style="color: #66cc66;">&#125;</span> 
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">var</span> token:AsyncToken = createToken<span style="color: #66cc66;">&#40;</span>contacts<span style="color: #66cc66;">&#41;</span>;
	        token.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span>resultHandler, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        	<span style="color: #b1b100;">return</span> token;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getContactsByName<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:AsyncToken
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> result:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>contacts.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> contact:Contact = contacts.<span style="color: #006600;">getItemAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span> as Contact;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>contact.<span style="color: #006600;">fullName</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&gt;</span>=<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				result.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span> 
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> token:AsyncToken = createToken<span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#41;</span>;
	        token.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span>resultHandler, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        	<span style="color: #b1b100;">return</span> token;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> resultHandler<span style="color: #66cc66;">&#40;</span>event:ResultEvent, token:AsyncToken = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		event.<span style="color: #006600;">token</span>.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;	
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>To keep the views independent from a specific implementation of the service, we provide them with a property of the interface type (IContactService). Depending on the Spring AS application context, a specific implementation of the service is injected. For example, ContactForm is defined as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Canvas</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> xmlns:controls=<span style="color: #ff0000;">&quot;insync.controls.*&quot;</span></span>
<span style="color: #000000;">	width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span></span>
<span style="color: #000000;">	label=<span style="color: #ff0000;">&quot;{contact.id&gt;</span></span>0?contact.fullName:'New Contact'}&quot;&gt;
&nbsp;
	<span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">	&lt;![CDATA[</span>
&nbsp;
<span style="color: #339933;">	import mx.rpc.events.ResultEvent;</span>
<span style="color: #339933;">	import insync.events.ContactEvent;</span>
<span style="color: #339933;">	import insync.services.IContactService;</span>
<span style="color: #339933;">	import insync.model.Contact;</span>
&nbsp;
<span style="color: #339933;">	[Autowired]			</span>
<span style="color: #339933;">	public var contactService:IContactService;</span>
&nbsp;
<span style="color: #339933;">	[Bindable] </span>
<span style="color: #339933;">	public var contact:Contact;</span>
&nbsp;
<span style="color: #339933;">	private function save():void</span>
<span style="color: #339933;">	{</span>
<span style="color: #339933;">		contact.firstName = firstName.text;</span>
<span style="color: #339933;">		contact.lastName = lastName.text;</span>
<span style="color: #339933;">		contact.email = email.text;</span>
<span style="color: #339933;">		contact.phone = phone.text;</span>
<span style="color: #339933;">		contact.address = address.text;</span>
<span style="color: #339933;">		contact.city = city.text;</span>
<span style="color: #339933;">		contact.state = state.text;</span>
<span style="color: #339933;">		contact.zip = zip.text;</span>
<span style="color: #339933;">		contact.pic = picture.source;</span>
&nbsp;
<span style="color: #339933;">		contactService.save(contact).addEventListener(ResultEvent.RESULT,</span>
<span style="color: #339933;">			function(event:ResultEvent):void</span>
<span style="color: #339933;">			{</span>
<span style="color: #339933;">				// Display a status message. Added here to provide an example where</span>
<span style="color: #339933;">				// a specific contact view needs to be notified of the success or failure</span>
<span style="color: #339933;">				// of a service operation. </span>
<span style="color: #339933;">				status.text = &quot;Contact saved successfully&quot;;</span>
<span style="color: #339933;">				setTimeout(function():void{status.text=&quot;&quot;}, 1500);						</span>
<span style="color: #339933;">			});</span>
<span style="color: #339933;">	}</span>
&nbsp;
<span style="color: #339933;">	private function remove():void</span>
<span style="color: #339933;">	{</span>
<span style="color: #339933;">		contactService.remove(contact);</span>
<span style="color: #339933;">	}</span>
&nbsp;
<span style="color: #339933;">	]]&gt;</span>
<span style="color: #339933;">	&lt;/mx:Script&gt;</span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Id&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> text=<span style="color: #ff0000;">&quot;{contact.id}&quot;</span> enabled=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;First Name&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;firstName&quot;</span> text=<span style="color: #ff0000;">&quot;{contact.firstName}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Last Name&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;lastName&quot;</span> text=<span style="color: #ff0000;">&quot;{contact.lastName}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Email&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;email&quot;</span> text=<span style="color: #ff0000;">&quot;{contact.email}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Phone&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;phone&quot;</span> text=<span style="color: #ff0000;">&quot;{contact.phone}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Address&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;address&quot;</span> text=<span style="color: #ff0000;">&quot;{contact.address}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;City&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;city&quot;</span> text=<span style="color: #ff0000;">&quot;{contact.city}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;State&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;state&quot;</span> text=<span style="color: #ff0000;">&quot;{contact.state}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Zip&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;zip&quot;</span> text=<span style="color: #ff0000;">&quot;{contact.zip}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;controls:PictureInput</span> id=<span style="color: #ff0000;">&quot;picture&quot;</span> top=<span style="color: #ff0000;">&quot;14&quot;</span> left=<span style="color: #ff0000;">&quot;350&quot;</span> styleName=<span style="color: #ff0000;">&quot;pictureFrame&quot;</span></span>
<span style="color: #000000;">		pictureWidth=<span style="color: #ff0000;">&quot;160&quot;</span> pictureHeight=<span style="color: #ff0000;">&quot;160&quot;</span></span>
<span style="color: #000000;">		source=<span style="color: #ff0000;">&quot;{contact.pic}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> id=<span style="color: #ff0000;">&quot;status&quot;</span> left=<span style="color: #ff0000;">&quot;8&quot;</span> bottom=<span style="color: #ff0000;">&quot;50&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HBox</span> left=<span style="color: #ff0000;">&quot;8&quot;</span> bottom=<span style="color: #ff0000;">&quot;8&quot;</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Save&quot;</span> click=<span style="color: #ff0000;">&quot;save()&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Delete&quot;</span> click=<span style="color: #ff0000;">&quot;remove()&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Canvas</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>Although very simple, the InSync application allows you to open multiple contact views. It’s therefore important for a specific view to be able to know that a specific operation succeeded or failed. For example, in this case, we show a status message when the save operation succeeded.</p>
<p>If you want to work with the Mock Service implementation, you’d define applicationContext.xml as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;objects<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;contactService&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;insync.services.ContactMockService&quot;</span> </span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/objects<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>If you want to switch to the RemoteObject implementation, you’d change the applicationContext.xml as follows. No need to change anything in the application, and no need to recompile.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;">&lt;objects<span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;">&lt;object id=<span style="color: #ff0000;">&quot;remoteObject&quot;</span> class=<span style="color: #ff0000;">&quot;mx.rpc.remoting.mxml.RemoteObject&quot;</span>	abstract=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;">&lt;property name=<span style="color: #ff0000;">&quot;endpoint&quot;</span> value=<span style="color: #ff0000;">&quot;http://localhost:8400/lcds-samples/messagebroker/amf&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;">&lt;property name=<span style="color: #ff0000;">&quot;showBusyCursor&quot;</span> value=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;">&lt;/object<span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;">&lt;object id=<span style="color: #ff0000;">&quot;contactRemoteObject&quot;</span> parent=<span style="color: #ff0000;">&quot;remoteObject&quot;</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;">&lt;property name=<span style="color: #ff0000;">&quot;destination&quot;</span> value=<span style="color: #ff0000;">&quot;contacts&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;">&lt;/object<span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;">&lt;object id=<span style="color: #ff0000;">&quot;contactService&quot;</span> class=<span style="color: #ff0000;">&quot;insync.services.ContactRemoteObjectService&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	    <span style="color: #000000;">&lt;constructor-arg<span style="color: #7400FF;">&gt;</span></span>
	        <span style="color: #000000;">&lt;object id=<span style="color: #ff0000;">&quot;myContactRemoteObject&quot;</span> parent=<span style="color: #ff0000;">&quot;remoteObject&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	            <span style="color: #000000;">&lt;property name=<span style="color: #ff0000;">&quot;destination&quot;</span> value=<span style="color: #ff0000;">&quot;contacts&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
	        <span style="color: #000000;">&lt;/object<span style="color: #7400FF;">&gt;</span></span>
	    <span style="color: #000000;">&lt;/constructor-arg<span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;">&lt;/object<span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;">&lt;/objects<span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>In this version of the application, we achieved an important goal: we decoupled the views of the application from any specific service implementation (and we can easily change the implementation we want to use). Decoupling the service layer from the other layers of your application is Spring AS’ primary objective.</p>
<p>Beyond that, you are free to implement the design patterns that you like, or that best fit the requirements of your application and the makeup of your development team. For example, you may prefer a design pattern where the view doesn’t have a reference to a service or controller (even if that reference is defined as an interface).</p>
<p>One additional benefit of using a Mock Service is that I can host the application configured with the MockService and let you play with it without having to worry about my database.</p>
<p>Click <a href="http://coenraets.org/apps/insyncspringas3/springaspart3.html">here </a>to run the application. (View Source is enabled)</p>
<h3>Installation instructions</h3>
<p>NOTE: If you already installed the application provided with part 2 of this series, you can skip steps 1, 3, 4, 5 and 6.</p>
<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 Spring ActionScript… That’s just what this sample is using.)</li>
<li>Download <a href="http://coenraets.org/apps/insyncspringas3/srcview/springaspart3.zip">insyncspringas3.zip</a>, and unzip it on your local file system.</li>
<li>Copy insyncspringas3/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>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;destination</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;contacts&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</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>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>insync.dao.ContactDAO<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>application<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<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>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/destination<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</p>
<li>Copy insyncspringas3/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>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="as" style="font-family:monospace;">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></td></tr></table></div>

</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 insyncspringas3. You don’t have to select any &#8220;Application server type&#8221;. </li>
<li>Copy spring-actionscript.swc and as3reflect.swc from insyncspringas3/flex/lib to the lib directory of your project</li>
<li>Copy the files and folders from insyncspringas3/flex/src to the src directory of your project</li>
<li>Open applicationContext.xml and make sure the remoteObject endpoint value matches your server setup.</li>
<li>Run the application</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://coenraets.org/blog/2009/03/the-spring-actionscript-framework-part-3-injecting-services-and-mock-services/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
