<?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>/home/nick &#187; web-dev</title>
	<atom:link href="http://whatwouldnickdo.com/wordpress/category/web-dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://whatwouldnickdo.com/wordpress</link>
	<description>Discussions on Programming, Linux, and whatever else.</description>
	<lastBuildDate>Sun, 22 Aug 2010 14:56:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Calling multiple methods from one RemoteObject in Flex and Actionscript using BlazeDS</title>
		<link>http://whatwouldnickdo.com/wordpress/532/calling-multiple-methods-from-one-remoteobject-in-flex-and-actionscript-using-blazeds/</link>
		<comments>http://whatwouldnickdo.com/wordpress/532/calling-multiple-methods-from-one-remoteobject-in-flex-and-actionscript-using-blazeds/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 20:22:36 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[web-dev]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[BlazeDS]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=532</guid>
		<description><![CDATA[BlazeDS allows us to use RPC to access our Java objects from an Adobe Flex or AIR app. This is a simple example that allows you to have a remote java object which you will make calls upon from Flex (or Actionscript). There are plenty of BlazeDS remoting tutorials out there. This HOW-TO shows how [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/BlazeDS">BlazeDS</a> allows us to use <a href="http://en.wikipedia.org/wiki/Remote_procedure_call">RPC</a> to access our <a href="http://en.wikipedia.org/wiki/Java_(programming_language)">Java</a> objects from an <a href="http://en.wikipedia.org/wiki/Adobe_Flex">Adobe Flex</a> or <a href="http://en.wikipedia.org/wiki/Adobe_Apollo">AIR</a> app.  This is a simple example that allows you to have a remote java object which you will make calls upon from Flex (or <a href="http://en.wikipedia.org/wiki/ActionScript">Actionscript</a>).   There are plenty of BlazeDS remoting tutorials out there.  This HOW-TO shows how to create an actionscript class to handle your remote objects and handlers as well as linking more than one method to a single remote object.<br />
<span id="more-532"></span><br />
This HOW-TO assumes you have the knowledge to create a small flex app and a server-side java project using BlazeDS.  If you don&#8217;t know how to do this, there are tons of tutorials out there like <a href="http://codeofdoom.com/wordpress/2009/02/01/blazeds-with-remote-objects-example/">this one</a>.</p>
<p>Here&#8217;s the java object that we&#8217;ll be calling methods on from Flex:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyRemoteService <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> MyRemoteService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getSessionId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> sessionId <span style="color: #339933;">=</span> FlexContext.<span style="color: #006633;">getFlexSession</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: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;returning sessionId &quot;</span><span style="color: #339933;">+</span>sessionId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> sessionId<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getMyData<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> stuff from database or whatever
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Our <a href="http://livedocs.adobe.com/flex/3/langref/mx/rpc/remoting/mxml/RemoteObject.html">RemoteObject</a> will be called remoteService and will call the two methods <strong>getSessionId()</strong> and <strong>getMyData()</strong>.  The following is the <a href="http://en.wikipedia.org/wiki/MXML">mxml</a> for remoteService that has the two methods.  Each method has a name attribute and attributes to set handlers for a <strong>fault</strong> and <strong>result</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="flex" style="font-family:monospace;">&lt;mx:RemoteObject id=&quot;remoteService&quot; destination=&quot;remoteServiceDestination&quot;&gt;
	&lt;mx:method name=&quot;getSessionId&quot; fault=&quot;handler_getSessionIdFault(event)&quot; result = &quot;handler_getSessionIdSuccess(event)&quot; /&gt;
	&lt;mx:method name=&quot;getMyData&quot;    fault=&quot;handler_getMyDataFault(event)&quot;    result = &quot;handler_getMyDataSuccess(event)&quot; /&gt;
&lt;/mx:RemoteObject&gt;</pre></div></div>

<p>This next code block does the same thing as our above code, except it&#8217;s an actionscript class.  It handles the same two methods.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ConnectionManager
<span style="color: #66cc66;">&#123;</span>
	<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;">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;">AsyncToken</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">Responder</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>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">Channel</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;">messaging</span>.<span style="color: #006600;">channels</span>.<span style="color: #006600;">AMFChannel</span>;  
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> blazeUrl:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;http://localhost:8080/BlazeServer/messagebroker/&quot;</span>;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> remoteService:RemoteObject = <span style="color: #000000; font-weight: bold;">new</span> RemoteObject;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ConnectionManager<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> cs: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> myAMF:Channel = <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>, blazeUrl + <span style="color: #ff0000;">&quot;amf&quot;</span><span style="color: #66cc66;">&#41;</span>; 
		cs.<span style="color: #006600;">addChannel</span><span style="color: #66cc66;">&#40;</span>myAMF<span style="color: #66cc66;">&#41;</span>; 
		remoteService.<span style="color: #006600;">channelSet</span> = cs; 
&nbsp;
		remoteService.<span style="color: #006600;">destination</span> = <span style="color: #ff0000;">&quot;remoteServiceDestination&quot;</span>;
		remoteService.<span style="color: #006600;">showBusyCursor</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #000000; font-weight: bold;">var</span> rpcCall:AsyncToken;
&nbsp;
		rpcCall = remoteService.<span style="color: #006600;">getSessionId</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		rpcCall.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>handler_getSessionIdSuccess, handler_getSessionIdFault<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
		rpcCall = remoteService.<span style="color: #006600;">getMyData</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		rpcCall.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>handler_getMyDataSuccess, handler_getMyDataFault<span style="color: #66cc66;">&#41;</span> <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> handler_getSessionIdSuccess<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: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;sessionId: &quot;</span>+event.<span style="color: #0066CC;">message</span>.<span style="color: #006600;">body</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;handler_getSessionIdSuccess&quot;</span><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> handler_getSessionIdFault<span style="color: #66cc66;">&#40;</span>fault:FaultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>fault<span style="color: #66cc66;">&#41;</span>;
		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>fault.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;handler_getSessionIdFault&quot;</span><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> handler_getMyDataSuccess<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: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #0066CC;">message</span>.<span style="color: #006600;">body</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;handler_getMyDataSuccess&quot;</span><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> handler_getMyDataFault<span style="color: #66cc66;">&#40;</span>fault:FaultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>fault<span style="color: #66cc66;">&#41;</span>;
		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>fault.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;handler_getMyDataFault&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>For a good book about Flex check out <a href="http://www.amazon.com/gp/product/1933988746?ie=UTF8&#038;tag=homenick-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1933988746">Flex 3 in Action</a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=as2&#038;o=1&#038;a=1933988746" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/532/calling-multiple-methods-from-one-remoteobject-in-flex-and-actionscript-using-blazeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tomcat https SSL Config</title>
		<link>http://whatwouldnickdo.com/wordpress/431/quick-tomcat-https-ssl-config/</link>
		<comments>http://whatwouldnickdo.com/wordpress/431/quick-tomcat-https-ssl-config/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 19:04:52 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[web-dev]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=431</guid>
		<description><![CDATA[Setting up your webapp to work with https and SSL encryption when using Tomcat is easier than most people think.  Here&#8217;s a very quick HOW-TO to get you up and running&#8230; The first thing you need to do is create a certificate.  If you&#8217;re unfamiliar with certificates or SSL you can look at some of [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up your webapp to work with <a href="http://en.wikipedia.org/wiki/Https">https and SSL encryption</a> when using <a href="http://tomcat.apache.org/">Tomcat</a> is easier than most people think.  Here&#8217;s a very quick HOW-TO to get you up and running&#8230;<br />
<span id="more-431"></span><br />
The first thing you need to do is create a <a href="http://en.wikipedia.org/wiki/Certificate_Authority">certificate</a>.  If you&#8217;re unfamiliar with certificates or SSL you can look at some of the following links to help school you:<br />
<a href="http://tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html">http://tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html</a><br />
<a href="http://www.ourshop.org/resources/ssl.html">http://www.ourshop.org/resources/ssl.html </a><br />
<a href="http://www.wisegeek.com/what-is-the-difference-between-http-and-https.htm">http://www.wisegeek.com/what-is-the-difference-between-http-and-https.htm</a></p>
<p><strong>Creating your certificate</strong></p>
<ul>
<li>Go to your JRE bin folder and there will be a file called &#8220;keytool&#8221;.</li>
<li>Type <strong>keytool -genkey -alias tomcat -keyalg RSA -keystore c:/.keystore</strong> The &#8220;keystore&#8221; parameter is optional.  It&#8217;s the location where the certificate keystore will be stored.  By default it will be stored in the current user&#8217;s home directory.</li>
<li>Upon executing, you will be prompted with a number of questions like name, location, organization, etc.  For name I recommend using the domain or if need be the machine name.</li>
</ul>
<p><strong>Modifying the server.xml file</strong></p>
<ul>
<li>Locate the server.xml in $CATALINA_HOME/conf/server.xml</li>
<li>Open it and look for a section dealing with the SSL Connector.  The section will look something like this:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt;-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">&lt;Connector </span>
<span style="color: #808080; font-style: italic;">           port=&quot;8443&quot; minProcessors=&quot;5&quot; maxProcessors=&quot;75&quot;</span>
<span style="color: #808080; font-style: italic;">           enableLookups=&quot;true&quot; disableUploadTimeout=&quot;true&quot;</span>
<span style="color: #808080; font-style: italic;">           acceptCount=&quot;100&quot; debug=&quot;0&quot; scheme=&quot;https&quot; secure=&quot;true&quot;;</span>
<span style="color: #808080; font-style: italic;">           clientAuth=&quot;false&quot; sslProtocol=&quot;TLS&quot;/&gt;</span>
<span style="color: #808080; font-style: italic;">--&gt;</span></pre></div></div>

<ul>
<li>Uncomment the block, and add in another attribute  for the keystore location.  We&#8217;ll add in <strong>keystoreFile=&#8221;c:\.keystore&#8221;</strong>, so when finished we&#8217;ll have:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt;-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Connector</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">port</span>=<span style="color: #ff0000;">&quot;8443&quot;</span> <span style="color: #000066;">minProcessors</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">maxProcessors</span>=<span style="color: #ff0000;">&quot;75&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">enableLookups</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">disableUploadTimeout</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">acceptCount</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">debug</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">scheme</span>=<span style="color: #ff0000;">&quot;https&quot;</span> <span style="color: #000066;">secure</span>=<span style="color: #ff0000;">&quot;true&quot;</span>;</span>
<span style="color: #009900;">           <span style="color: #000066;">clientAuth</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">sslProtocol</span>=<span style="color: #ff0000;">&quot;TLS&quot;</span> <span style="color: #000066;">keystoreFile</span>=<span style="color: #ff0000;">&quot;c:\.keystore&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Connector<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>For full workings of server.xml refer to the <a href="http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html">apache site</a>.   </p>
<p>Last step is to restart Tomcat and point the browser to:<br />
<strong>https://localhost:8443 </strong><br />
Remember the <strong>https</strong> and it uses port 8443 by default which can be changed in the server.xml</p>
]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/431/quick-tomcat-https-ssl-config/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
