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

<channel>
	<title>Gaurav &#187; java</title>
	<atom:link href="http://allyourcodearebelongto.me/blog/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://allyourcodearebelongto.me/blog</link>
	<description>All About Everything</description>
	<lastBuildDate>Sun, 23 Nov 2008 19:44:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting up BlazeDS with Flex</title>
		<link>http://allyourcodearebelongto.me/blog/2008/03/02/setting-up-blazeds-with-flex/</link>
		<comments>http://allyourcodearebelongto.me/blog/2008/03/02/setting-up-blazeds-with-flex/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 11:49:42 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[adobe]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tomcat]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2008/03/02/setting-up-blazeds-with-flex/</guid>
		<description><![CDATA[&#160;
Let me give some introduction first.
BlazeDS is a server-based Java remoting and web messaging technology that allows to connect to back-end distributed data and push data in real-time to Adobe Flex and Adobe AIR rich Internet applications (RIA). Because of its open licensing, BlazeDS is not precluded from being used with other client platforms, such [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Let me give some introduction first.</p>
<blockquote><p><em>BlazeDS is a server-based Java remoting and web messaging technology that allows to connect to back-end distributed data and push data in real-time to Adobe Flex and Adobe AIR rich Internet applications (RIA). Because of its open licensing, BlazeDS is not precluded from being used with other client platforms, such as JavaScript/AJAX. (<a href="http://en.wikipedia.org/wiki/BlazeDS">wikipedia</a>)</em></p>
<p><em>Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform, rich Internet applications based on the proprietary Adobe Flash platform. The initial release in March 2004 by Macromedia included a software development kit, an IDE, and a J2EE integration application known as Flex Data Services. Since Adobe acquired Macromedia in 2005, subsequent releases of Flex no longer require a license for Flex Data Services, which has become a separate product rebranded as LiveCycle Data Services. (<a href="http://en.wikipedia.org/wiki/Adobe_Flex">wikipedia</a>)</em></p>
</blockquote>
<p><span id="more-41"></span></p>
<h2>Setting up JAVA:</h2>
<p>Install the java sdk (jdk) and setup the environment by setting up the following two variables.</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/03/image.png"><img style="border-width:0;" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/03/image-thumb.png" width="359" height="52"></a></p>
<p>&nbsp;</p>
<h2>Setting up BlazeDS:</h2>
<p>BlazeDS can be downloaded from: <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3email">here</a>. We will be using the turnkey download as it is preconfigured.</p>
<p>Now unzip blazeds in any folder. In my case I unzipped it to: <strong>&#8220;D:\Blaze_ds&#8221;</strong></p>
<p>Now I will be setting up a new project in this directory: <strong>&#8220;D:\Blaze_ds\tomcat\webapps\blazeds&#8221;</strong></p>
<p><strong></strong>&nbsp;</p>
<h2>Setting up Flex Builder:</h2>
<p>A 60 ay trial can be downloaded form: <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3email">here</a></p>
<p>Download flex builder 3 and install it. I installed flex builder in: <strong>&#8220;D:\Flex&#8221;</strong></p>
<p>&nbsp;</p>
<h2>Creating a new project:</h2>
<p>Now fire up flex builder and create a new flex project inside it.</p>
<p>&nbsp;<a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/03/image1.png"><img style="border-width:0;" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/03/image-thumb1.png" width="481" height="484"></a></p>
<p>&nbsp;<a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/03/image2.png"><img style="border-width:0;" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/03/image-thumb2.png" width="482" height="484"></a></p>
<p>Now fill in the appropriate entries and click on the &#8220;Validate Configuration&#8221; button. Now before you click on the button Tomcat needs to be started or the configuration won&#8217;t be validated. To start the server start a console and navigate to bin directory of Tomcat which is <strong>&#8220;D:\Blaze_ds\tomcat\bin&#8221; </strong>in my case. Now the configuration should validate. I have selected the current project directory as the output directory. Click on finish and a new project should be created.</p>
<p>The configuration is complete now. Just write some code to test the configuration.</p>
<div>
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">&lt;?</span><span style="color:#800000;">xml</span> <span style="color:#ff0000;">version</span><span style="color:#0000ff;">="1.0"</span> <span style="color:#ff0000;">encoding</span><span style="color:#0000ff;">="utf-8"</span>?<span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:Application</span> <span style="color:#ff0000;">xmlns:mx</span><span style="color:#0000ff;">="http://www.adobe.com/2006/mxml"</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>     <span style="color:#ff0000;">creationComplete</span><span style="color:#0000ff;">="consumer.subscribe()"</span><span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>     </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>     <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:Script</span><span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>         <span style="color:#0000ff;">&lt;!</span>[CDATA[</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>         </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span>             import mx.messaging.messages.AsyncMessage;</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>             import mx.messaging.messages.IMessage;</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span>             </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span>             private function send():void</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span>             {</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  13:</span>                 var message:IMessage = new AsyncMessage();</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  14:</span>                 message.body.chatMessage = msg.text;</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  15:</span>                 producer.send(message);</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  16:</span>                 msg.text = "";</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  17:</span>             }</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  18:</span>                             </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  19:</span>             private function messageHandler(message:IMessage):void</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  20:</span>             {</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  21:</span>                 log.text += message.body.chatMessage + "n";    </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  22:</span>             }</pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  23:</span>             </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  24:</span>         ]]<span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  25:</span>     <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">mx:Script</span><span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  26:</span>     </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  27:</span>     <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:Producer</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">="producer"</span> <span style="color:#ff0000;">destination</span><span style="color:#0000ff;">="data_sample"</span><span style="color:#0000ff;">/&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  28:</span>     <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:Consumer</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">="consumer"</span> <span style="color:#ff0000;">destination</span><span style="color:#0000ff;">="data_sample"</span> <span style="color:#ff0000;">message</span><span style="color:#0000ff;">="messageHandler(event.message)"</span><span style="color:#0000ff;">/&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  29:</span>     </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  30:</span>     <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:Panel</span> <span style="color:#ff0000;">title</span><span style="color:#0000ff;">="Chat"</span> <span style="color:#ff0000;">width</span><span style="color:#0000ff;">="100%"</span> <span style="color:#ff0000;">height</span><span style="color:#0000ff;">="100%"</span><span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  31:</span>         <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:TextArea</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">="log"</span> <span style="color:#ff0000;">width</span><span style="color:#0000ff;">="100%"</span> <span style="color:#ff0000;">height</span><span style="color:#0000ff;">="100%"</span><span style="color:#0000ff;">/&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  32:</span>         <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:ControlBar</span><span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  33:</span>              <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:TextInput</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">="msg"</span> <span style="color:#ff0000;">width</span><span style="color:#0000ff;">="100%"</span> <span style="color:#ff0000;">enter</span><span style="color:#0000ff;">="send()"</span><span style="color:#0000ff;">/&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  34:</span>              <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">mx:Button</span> <span style="color:#ff0000;">label</span><span style="color:#0000ff;">="Send"</span> <span style="color:#ff0000;">click</span><span style="color:#0000ff;">="send()"</span><span style="color:#0000ff;">/&gt;</span> </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  35:</span>         <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">mx:ControlBar</span><span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  36:</span>     <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">mx:Panel</span><span style="color:#0000ff;">&gt;</span></pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  37:</span>     </pre>
</p>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  38:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">mx:Application</span><span style="color:#0000ff;">&gt;</span></pre>
</div>
</div>
<p>This is some code taken from on of the samples provided. I guess, it is as simple as it can get.</p>
<p>The destination given in the Producer and Consumer needs to be defined in the <strong>&#8220;messaging-config.xml&#8221;</strong> file which is located<strong> &#8220;D:\Blaze_ds\tomcat\webapps\blazeds\WEB-INF\flex\messaging-config.xml&#8221;.</strong></p>
<p>Just add <strong>&lt;destination id=&#8221;data_sample&#8221;/&gt;</strong> inside the service tag.</p>
<p>Thats it. To test run application in two browser windows and the messages between the two windows showd be synchronized.</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/03/image3.png"><img style="border-width:0;" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/03/image-thumb3.png" width="644" height="443"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2008/03/02/setting-up-blazeds-with-flex/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
