<?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>James Ward &#187; Cloud</title>
	<atom:link href="http://www.jamesward.com/category/cloud/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jamesward.com</link>
	<description>Heroku &#124; Java &#124; Scala &#124; Cloud &#124; Open Source &#124; Linux</description>
	<lastBuildDate>Mon, 06 Feb 2012 16:48:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Video: Running Java Web Apps on the Cloud</title>
		<link>http://www.jamesward.com/2011/09/14/video-running-java-web-apps-on-the-cloud?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=video-running-java-web-apps-on-the-cloud</link>
		<comments>http://www.jamesward.com/2011/09/14/video-running-java-web-apps-on-the-cloud#comments</comments>
		<pubDate>Wed, 14 Sep 2011 19:57:30 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Heroku]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=2638</guid>
		<description><![CDATA[Here is a quick screencast that shows how to instantly deploy Java web applications on the cloud with Heroku. If you want more than a quick introduction check out a recording of my presentation at JavaZone. And visit heroku.com/java for more details on how to get started running Java apps on Heroku.]]></description>
			<content:encoded><![CDATA[<p>Here is a quick screencast that shows how to instantly deploy Java web applications on the cloud with Heroku.</p>
<p><iframe width="640" height="510" src="http://www.youtube.com/embed/PqLkjJvEMko?hd=1" frameborder="0" allowfullscreen></iframe></p>
<p>If you want more than a quick introduction check out a <a href="http://vimeo.com/28803302">recording of my presentation at JavaZone</a>.  And visit <a href="http://www.heroku.com/java">heroku.com/java</a> for more details on how to get started running Java apps on Heroku.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2011/09/14/video-running-java-web-apps-on-the-cloud/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dreamforce 2011</title>
		<link>http://www.jamesward.com/2011/08/10/dreamforce-2011?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dreamforce-2011</link>
		<comments>http://www.jamesward.com/2011/08/10/dreamforce-2011#comments</comments>
		<pubDate>Wed, 10 Aug 2011 17:15:24 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=2511</guid>
		<description><![CDATA[I&#8217;m very excited to be presenting at Dreamforce (salesforce.com&#8217;s anual conference) this year! On Thursday, September 1, from 1:15 pm to 2:15 pm I will be presenting: Developing Java Cloud Apps The cloud makes it easy to deploy highly scalable apps in an instant. This session will walk you through the steps to build your [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m very excited to be presenting at <a href="http://www.salesforce.com/dreamforce/DF11/">Dreamforce</a> (salesforce.com&#8217;s anual conference) this year!  On Thursday, September 1, from 1:15 pm to 2:15 pm I will be presenting:</p>
<blockquote><p><strong>Developing Java Cloud Apps</strong><br />
The cloud makes it easy to deploy highly scalable apps in an instant. This session will walk you through the steps to build your first Java app for the cloud. You&#8217;ll also learn best practices for building mission-critical and horizontally scalable Java cloud apps.</p></blockquote>
<p>Then on Friday, September 2, from 10:00 am to 11:00 am I will be hosting a panel discussion:</p>
<blockquote><p><strong>Fireside Chat: Java on the Cloud</strong><br />
Come join the Java on the cloud product managers, architects, and experts for a casual, unscripted chat to find out how Java developers can best take advantage of the cloud. The session will be a mix of preselected and audience-provided questions. So bring all your tough, interesting, and quirky questions to this Fireside Chat.</p></blockquote>
<p>I hope to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2011/08/10/dreamforce-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Architectural Evolution: From Middleware to The Cloud</title>
		<link>http://www.jamesward.com/2011/07/12/architectural-evolution-from-middleware-to-the-cloud?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=architectural-evolution-from-middleware-to-the-cloud</link>
		<comments>http://www.jamesward.com/2011/07/12/architectural-evolution-from-middleware-to-the-cloud#comments</comments>
		<pubDate>Tue, 12 Jul 2011 18:10:22 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=2455</guid>
		<description><![CDATA[You&#8217;ve heard it said that &#8220;all things old are new again.&#8221; That statement can certainly be applied to the current Cloud hype. But each time the old becomes new it gets a bit better because of what was learned the last time around. If we look back ten years at enterprise application development in Java [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve heard it said that &#8220;all things old are new again.&#8221;  That statement can certainly be applied to the current Cloud hype.  But each time the old becomes new it gets a bit better because of what was learned the last time around.  If we look back ten years at enterprise application development in Java things were quite different than they are today.  EJB was &#8220;the way&#8221; to build scalable systems from a vast abundance of components.  But things didn&#8217;t work out as well as the vendors planned.</p>
<p><strong>EJB Component Architecture</strong></p>
<p>I remember back in the early days of enterprise Java everyone was talking about &#8220;Components.&#8221;  Application complexity would be greatly reduced because there would be components for everything!  Need to connect your app to Exchange?  Well, there&#8217;s a component for that.  Does your app need to send email?  No problem, there are twenty components for that!  Component marketplaces flourished with VC funding galore.</p>
<p>The official way to build reusable Java components became standardized as <em>Enterprise Java Beans</em> (EJB).  These &#8220;beans&#8221; could be accessed either locally or remotely!  Vendors led us to believe this was the panacea of Lego-style application development.  Just grab pieces from every-which place and hook them together.  Hooking the components together required a heavyweight &#8220;Middleware&#8221; server.  Here is what Monolithic Middleware with EJBs looks like:<br />
<img src="http://www.jamesward.com/wp/uploads/2011/07/MiddlewaretoCloudServices_j2ee.png" alt="" title="J2EE Architecture" width="526" height="314" class="alignnone size-full wp-image-2456" /></p>
<p>But the EJB Component Architecture didn&#8217;t work.  Billions of dollars were spent on components and the middleware to tie them all together.  And now I bet you can&#8217;t find a single person that doesn&#8217;t regret going that route.  Why?  Three primary reasons&#8230;</p>
<ol>
<li>The programming model was too hard.  The EJB programming model consisted of too much boilerplate code (&#8220;solved&#8221; through code-gen tools like xdoclet).  EJB&#8217;s also required configuration which was often middleware server-specific.  The EJB Component Architecture creates too many layers of indirection (<a href="http://java.sun.com/blueprints/corej2eepatterns/">Core J2EE Patterns</a> anyone?).</li>
<li>Scalability was too hard.  EJBs can either run inside your container (using what is called a &#8220;Local Interface&#8221;) or somewhere else (a &#8220;Remote Interface&#8221;).  Using Local Interfaces is fast but causes middleware to run into memory limits and scaling bloated app servers is challenging.  Using Remote Interfaces leads to massive serialization and routing overhead and whatever is on the remote end of the wire is still a pain to scale.</li>
<li>Deployment was too hard.  Remember the days when starting up an app server / middleware container took minutes not seconds?</li>
</ol>
<p>If you need further proof that the middleware model didn&#8217;t work then just try to name one place you can still go to buy an EJB component today.  Obviously we needed another way to compose the parts of an application.</p>
<p><strong>POJO Component Architecture</strong></p>
<p>SpringSource deserves a lot of credit for pulling us out of the EJB muck.  They created a model where the application pieces are <em>Plain Old Java Objects</em> (POJOs) injected into an application.  This led to better testability, much easier deployment, and a much better programming model.  Essentially the revolution of Spring was to make all those app pieces injectable dependencies.  This was a huge step forward.  But there are still some limitations with this model that are currently being addressed by the next revolution.  The three primary challenges with the POJO Component Architecture are:</p>
<ol>
<li>Isolation is too hard.  It is now very easy to throw a bunch of components together into a single Web application ARchive (WAR).  But at some point all of these pieces being stacked on top of each other make our application brittle and difficult to piece together.  What do you do when the version of Hibernate you want to use requires a different version of an Apache Commons library than the version of XFire that you want to use?  Or when two libraries that your app needs actually require conflicting dependencies.  Sometimes isolating the pieces of an application is actually simpler than injecting them.  And unfortunately with POJOs you may not be able to easily switch from using a &#8220;Local Interface&#8221; to an external &#8220;Remote Interface&#8221; like you can with EJBs.</li>
<li>Polyglot is too hard.  The POJO components we use today in our systems are not inherently supportive of a Polyglot world where different parts of a system may be built using different technologies.  Suppose your system has a rules engine and you want to access it from a Java-based application and a Ruby-based application.  Today the only way to do that is to proxy that component and expose it through an easily serialization protocol (likely XML or JSON over HTTP).  This will likely add unnecessary complexity to your system.  When the high-level functional pieces of a system are technology-specific the entire system may be forced to use that technology or those pieces may exist multiple times to support the Polyglot nature of today&#8217;s systems.</li>
<li>Scaling is still too hard.  As we continue to stack more pieces on top of each other it becomes harder to stick with simple, lightweight share-nothing architectures where each piece is individually horizontally scalable.</li>
</ol>
<p><strong>Cloud Component Architecture</strong></p>
<p>The emerging solution to the challenges we have faced with the EJB and POJO Component Architectures is the Cloud Component Architecture.  Instead of bundling components for things like search indexing, distributed caching, SMTP, and NoSQL data storage into your application those high level functions can instead be used as Cloud Components.  There are already numerous vendors providing &#8220;Component as a Service&#8221; products like MongoDB, Redis, CouchDB, Lucene Search, SMTP, and Memcache.</p>
<p>SMTP / outbound email is a simple example where the Cloud Component Architecture makes a lot of sense.  With the EJB and POJO Component Architectures I&#8217;d find a SMTP component that simply sends email.  Then configure my server to be able to send emails that aren&#8217;t considered spam.  I&#8217;d also need to deal with constant blacklisting challenges and a larger management surface.  Or in a Cloud Component Architecture I could simply sign-up with one of the SMTP as a Service providers like <a href="http://www.authsmtp.com/">AuthSMTP</a> or <a href="http://sendgrid.com/">SendGrid</a> and then just use the Component as a Service.</p>
<p>Here is what the new Cloud Component Architecture for application composition looks like:<br />
<img src="http://www.jamesward.com/wp/uploads/2011/07/MiddlewaretoCloudServices_csa.png" alt="" title="Cloud Component Architecture" width="512" height="369" class="alignnone size-full wp-image-2457" /></p>
<p>The top six benefits of the Cloud Component Architecture are:</p>
<ol>
<li>Simple scalability.  By making each functional piece of an application an independent and lightweight service they can each be horizontally scaled without impacting the overall application architecture or configuration.  If you chose to use a vendor&#8217;s Component as a Service then they will handle the scalability of those pieces.  Then you only need to scale a very thin web layer.  Composing Cloud Components also makes it easier to stick with a share-nothing architecture that is much easier to scale than the traditional architectures.</li>
<li>Rapid composition.  Cloud Components are flourishing!  Most of the basic building blocks that applications need are now provided &#8220;as a Service&#8221; by vendors who maintain and enhance them.  This is a much more erosion-resistant way to assemble applications when compared to the typical abandon-ware which is prevalent with many Java components.  Many of the emerging Cloud Components also provide client libraries for multiple platforms and RESTful APIs to support easy composition in Polyglot systems.</li>
<li>Reduced management surface.  With Cloud Components you can reduce the number of pieces you must manage down to only the stuff that is unique to your app.  Each Cloud Component you add doesn&#8217;t enlarge the management surface like it does in typical component models where you own the implementation of the component.</li>
<li>Simple Deployment.  One of the biggest benefits of using the Cloud is the ease of deployment.  Partitioning the functional pieces of an application makes it thinner and easier to deploy.  With Cloud Components you can also setup development and staging instances that make it easy to simulate the production environment.  Then moving from one environment to another is simply a matter of configuration.</li>
<li>Better Security.  In most application architectures today there is one layer of security.  This would be like a bank without a vault.  There are a few ways into the bank that are wrapped with security (doors with locks) but as soon as someone has found a way in, they have access to everything.  With Cloud Components security can be more easily distributed to provide multiple layers of security.</li>
<li>Manageable costs.  With Cloud Components your costs can scale with your usage.  This means it&#8217;s easy to get started and grow rather than make large up-front investments.</li>
</ol>
<p>The Cloud Component Architecture may seem similar in ways to the old EJB and POJO Component Architectures because it is similar!  The wheel has not been reinvented, just improved.  The dream of Lego-style application assembly is now being realized because we&#8217;ve come full circle on some old ideas from twenty years ago (<a href="http://en.wikipedia.org/wiki/Corba">CORBA</a> anyone?).  This time around those ideas are reality thanks to the evolution of many independent pieces like REST, Polyglot, and the Share-Nothing pattern.  Cloud Components are the foundation of a new era of application development.  My only question is&#8230;  How long before we see the <a href="http://en.wikipedia.org/wiki/UDDI">UDDI</a> idea again?  ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2011/07/12/architectural-evolution-from-middleware-to-the-cloud/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Getting Started with Node.js on The Cloud</title>
		<link>http://www.jamesward.com/2011/06/21/getting-started-with-node-js-on-the-cloud/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-started-with-node-js-on-the-cloud</link>
		<comments>http://www.jamesward.com/2011/06/21/getting-started-with-node-js-on-the-cloud/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 17:21:22 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Heroku]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=2376</guid>
		<description><![CDATA[In my new job at salesforce.com I&#8217;m incredibly exited about getting into Heroku, a Platform as a Service provider / Cloud Application Platform. In a future blog post I&#8217;ll provide more details on what Heroku is and how it works. But if you are like me the first thing you want to do when learning [...]]]></description>
			<content:encoded><![CDATA[<p>In my new job at salesforce.com I&#8217;m incredibly exited about getting into <a href="http://www.heroku.com">Heroku</a>, a Platform as a Service provider / Cloud Application Platform.  In a future blog post I&#8217;ll provide more details on what Heroku is and how it works.  But if you are like me the first thing you want to do when learning a new technology is to take it for a test drive.  I decided to take my Heroku test drive using the <a href="http://devcenter.heroku.com/articles/node-js">recently announced Node.js support</a>.  I&#8217;m new to Node.js, but at least I know JavaScript.  Heroku also offers Ruby / Rails support but I don&#8217;t know Ruby &#8211; yet.  So let me walk you through the steps I took (and that you can follow) to get started with Node.js on the Heroku Cloud.</p>
<p>(If you have already signed up for Heroku, installed the heroku command line client, and installed git then <a href="#step6">skip ahead to Step 6</a>.)</p>
<p>Step 1) <a href="http://www.heroku.com/signup">Sign up for Heroku</a></p>
<p>Step 2) Install the heroku command line client</p>
<p>All of the Heroku management tasks are exposed through a RESTful API.  The easiest way to call those APIs is using the <a href="https://github.com/heroku/heroku">heroku open source command line</a> Ruby app.  To install the heroku command line I first had to install Ruby.  I&#8217;m on Ubuntu Linux so this process will be slightly different if you are on Windows or Mac but the <a href="http://devcenter.heroku.com/articles/quickstart">Heroku Dev Center</a> provides more information on how to do this on Windows and Mac.  On Ubuntu you can install Ruby with apt-get (or various other tools):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ruby</pre></div></div>

<p>Now <a href="http://rubygems.org/pages/download">download RubyGems</a>, unpack, and then install it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> ruby setup.rb</pre></div></div>

<p>This installs the gem utility at /usr/bin/gem1.8 but I also created a symlink to it so I can run it with just the &#8220;gem&#8221; command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem</pre></div></div>

<p>Now the heroku gem can be installed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> heroku</pre></div></div>

<p>Heroku should now run from the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku</pre></div></div>

<p>You should see something like:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Usage: heroku COMMAND [--app APP] [command-specific-options]
&nbsp;
Primary help topics, type &quot;heroku help TOPIC&quot; for more details:
&nbsp;
  auth      # authentication (login, logout)
  apps      # manage apps (create, destroy)
  ps        # manage processes (dynos, workers)
  run       # run one-off commands (console, rake)
  addons    # manage addon resources
  config    # manage app config vars
  releases  # view release history of an app
  domains   # manage custom domains
  logs      # display logs for an app
  sharing   # manage collaborators on an app
&nbsp;
Additional topics:
&nbsp;
  account      # manage heroku account options
  db           # manage the database for an app
  help         # list commands and display help
  keys         # manage authentication keys
  maintenance  # toggle maintenance mode
  pg           # manage heroku postgresql databases
  pgbackups    # manage backups of heroku postgresql databases
  plugins      # manage plugins to the heroku gem
  ssl          # manage ssl certificates for an app
  stack        # manage the stack for an app
  version      # display version</pre></div></div>

<p>Step 3) Login to Heroku via the command line</p>
<p>You can verify that everything is setup correctly by logging into Heroku through the heroku command line.  This will save an API key into a ~/.heroku/credentials file.  That key will be used for authenticating you on subsequent requests. Just run the following command and enter your Heroku credentials:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku auth:<span style="color: #c20cb9; font-weight: bold;">login</span></pre></div></div>

<p>Step 4) Install git</p>
<p>The git tool is used to transfer apps to Heroku.  On Ubuntu I installed it by doing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">git</span></pre></div></div>

<p>Step 5) Setup your SSH key</p>
<p>Heroku uses SSH keys to authenticate you when you push files through git.  If you don&#8217;t already have a SSH key then you will need to generate one (I used ssh-keygen).</p>
<p><a name="step6"></a><br />
Step 6) Create an app on Heroku</p>
<p>A new app needs to be provisioned on Heroku.  Since Heroku supports multiple application provisioning stacks you will need to tell it the stack you want to use, unless it&#8217;s the default.  For Node.js we need to use the &#8220;cedar&#8221; stack which is not the default since it&#8217;s still in beta.  To do that run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku create <span style="color: #660033;">-s</span> cedar</pre></div></div>

<p>A default / random app name is automatically assigned to your app.  It will be somethingunique.herokuapp.com.  You can change the name either through the <a href="https://api.heroku.com/myapps">Heroku web admin</a> or via the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku apps:rename <span style="color: #660033;">--app</span> somethingunique hellofromnodejs</pre></div></div>

<p>When the app was created your SSH key should have also been uploaded to Heroku for git access.  You can manage the keys associated with an app using the &#8220;heroku keys&#8221; commands.  Check out &#8220;heroku help keys&#8221; for more details.</p>
<p>Now that the app is provisioned it needs something to actually run!  So lets build a Node.js app and then upload it to Heroku.</p>
<p>Step 7) Install Node.js</p>
<p>On Ubuntu I installed Node.js through apt-get.  But first I had to add a PPA so that I could get the latest version.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> apt-add-repository ppa:jerome-etienne<span style="color: #000000; font-weight: bold;">/</span>neoip
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> nodejs</pre></div></div>

<p>For other platforms, check out the <a href="http://nodejs.org/#download">Node.js Download page</a>.</p>
<p>Step 8) Create a Node.js app</p>
<p>I started by building a very simple &#8220;hello, world&#8221; Node.js app.  In a new project directory I created two new files.  First is the package.json file which specifies the app metadata and dependencies:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
  <span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;heroku_hello_world&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #3366CC;">&quot;version&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;0.0.1&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #3366CC;">&quot;dependencies&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;express&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2.2.0&quot;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then the actual app itself contained in a file named web.js:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> express <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'express'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> app <span style="color: #339933;">=</span> express.<span style="color: #660066;">createServer</span><span style="color: #009900;">&#40;</span>express.<span style="color: #660066;">logger</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;
app.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  response.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hello, world'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> port <span style="color: #339933;">=</span> process.<span style="color: #660066;">env</span>.<span style="color: #660066;">PORT</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">3000</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Listening on &quot;</span> <span style="color: #339933;">+</span> port<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
app.<span style="color: #660066;">listen</span><span style="color: #009900;">&#40;</span>port<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This app simply maps requests to &#8220;/&#8221; to a function that sends a simple string back in the response.  You will notice that the port to listen on will first try to see if it has been specified through an environment variable and then fallback to port 3000.  This is important because Heroku can tell our app to run on a different port just by giving it an environment variable.</p>
<p>Step 9) Install the Node.js app dependencies</p>
<p>My simple Node.js app requires the <a href="http://expressjs.com/">Express Node.js library</a>.  In order to install Express, the <a href="http://npmjs.org/">Node Package Manager</a> (npm) is required.  Installing npm on Ubuntu was a bit trickey because I didn&#8217;t feel the regular method followed good security practices.  So I followed the alternative install instructions by just cloning npm from github and then installed it from source:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>isaacs<span style="color: #000000; font-weight: bold;">/</span>npm.git
<span style="color: #7a0874; font-weight: bold;">cd</span> npm
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Now we can install the node dependencies into the local project directory.  Just run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">npm <span style="color: #c20cb9; font-weight: bold;">install</span> .</pre></div></div>

<p>This uses the package.json to figure out what dependencies the app needs and then copies them into a &#8220;node_modules&#8221; directory.</p>
<p>Step 10) Try to run the app locally</p>
<p>From the command line run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">node web.js</pre></div></div>

<p>You should see &#8220;Listening on 3000&#8243; to indicate that the Node.js app is running!  Try to open it in your browser:<br />
<a href="http://localhost:3000/">http://localhost:3000/</a></p>
<p>Hopefully you will see &#8220;hello, world&#8221;.  </p>
<p>Step 11) Create a Procfile</p>
<p>Heroku uses a &#8220;Procfile&#8221; to determine how to actually run your app.  Here I will just use a Procfile to tell Heroku what to run in the &#8220;web&#8221; process.  But the Procfile is really the foundation for telling Heroku how to run your stuff.  I won&#8217;t go into detail here since Adam Wiggins has done a great <a href="http://blog.heroku.com/archives/2011/6/20/the_new_heroku_1_process_model_procfile/">blog post about the purpose and use of a Procfile</a>.  Create a file named &#8220;Procfile&#8221; in the project directory with the following contents:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">web<span style="color: #339933;">:</span> node web.<span style="color: #660066;">js</span></pre></div></div>

<p>This will instruct Heroku to run the web app using the node command and the web.js file as the main app.  Heroku can also run workers (non-web apps) but for now we will just deal with web processes.</p>
<p>Note: Once you have a Procfile you can <a href="http://devcenter.heroku.com/articles/procfile#developing_locally_with_foreman">run your application locally using Foreman</a>.  This allows you to simulate locally how Heroku will run your app based on your Procfile.</p>
<p>Step 12) Store the project files in a local git repo</p>
<p>In order to send the app to Heroku the files must be in a local git repository.  Of course you can also put them in a remote git repo (like github.com).  To create the local git repo run the following inside of your project directory:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> init</pre></div></div>

<p>Now add the three files you&#8217;ve created to the git repo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> add package.json Procfile web.js</pre></div></div>

<p>Note: Make sure you don&#8217;t add the node_modules directory to the git repo!  You can have git ignore it by creating a .gitignore file containing just &#8220;node_modules&#8221;.</p>
<p>And commit the files to the local repo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;initial commit&quot;</span></pre></div></div>

<p>Step 13) Push the project files to Heroku</p>
<p>Now we need to tell git about the remote repository on Heroku which we will push the app to.  When you provisioned the app on Heroku it gave you a web URL and a git URL.  If you don&#8217;t have the git URL anymore you can determine it either by running the &#8220;heroku apps&#8221; command or by navigating to the <a href="https://api.heroku.com/myapps">app on heroku.com</a>.  The git URL will be something like &#8220;git@heroku.com:somethingunique.git&#8221; where the &#8220;somethingunique&#8221; is your app&#8217;s name on Heroku.  Once you have the git URL add the remote repo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> remote add heroku <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>heroku.com:somethingunique.git</pre></div></div>

<p>Note: If we had created the git repo before creating the Heroku app then the heroku command line client would have automatically added the remote repo to your git configuration.</p>
<p>Now you can push your app to Heroku!  Just run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> push heroku master</pre></div></div>

<p>You should see something like:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 617 bytes, done.
Total 6 (delta 0), reused 6 (delta 0)
&nbsp;
-----&gt; Heroku receiving push
-----&gt; Node.js app detected
-----&gt; Vendoring node 0.4.7
-----&gt; Installing dependencies with npm 1.0.8
       express@2.2.0 ./node_modules/express 
       ├── mime@1.2.2
       ├── connect@1.4.4
       └── qs@0.1.0
       Dependencies installed
-----&gt; Discovering process types
       Procfile declares types -&gt; web
-----&gt; Compiled slug size is 3.1MB
-----&gt; Launching... done, v4
       http://somethingunique.herokuapp.com deployed to Heroku
&nbsp;
To git@heroku.com:somethingunique.git
 * [new branch]      master -&gt; master</pre></div></div>

<p>Now you should be able to connect to your app in the browser!  You can also get some diagnostic information out of the heroku command line.  To see your app logs (provisioning, management, scaling, and system out messages) run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku logs</pre></div></div>

<p>To see your app processes run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku <span style="color: #c20cb9; font-weight: bold;">ps</span></pre></div></div>

<p>And best of all, if you want to add more Dynos* just run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku scale <span style="color: #007800;">web</span>=<span style="color: #000000;">2</span></pre></div></div>

<p>* Dynos are the isolated containers that run your web and other processes.  They are managed by the Heroku Dyno Manifold.  <a href="http://devcenter.heroku.com/articles/dynos">Learn more about Dynos</a>.</p>
<p>That increases the number of Dynos running the app from one to two.  Automatically Heroku will distribute the load across those two Dynos, detect dead Dynos, restart them, etc!  That is seriously easy app scalability!</p>
<p>There is much more to Heroku and I&#8217;ll be continuing to write about it here.  But in the meantime, check out all of the great docs in the <a href="http://devcenter.heroku.com/">Heroku Dev Center</a>.  And please let me know if you have any questions or problems.  Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2011/06/21/getting-started-with-node-js-on-the-cloud/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>New Adventures on The Cloud</title>
		<link>http://www.jamesward.com/2011/06/05/new-adventures-on-the-cloud/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-adventures-on-the-cloud</link>
		<comments>http://www.jamesward.com/2011/06/05/new-adventures-on-the-cloud/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 00:47:25 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=2345</guid>
		<description><![CDATA[When I started doing professional software development almost 15 years ago I was focused on the server-side. I started with Perl / CGI web apps &#8211; some of which are still in production today. Then I dove into Java web development with Java Web Server 1.0, Struts, JBoss, Tomcat and many other game changing technologies. [...]]]></description>
			<content:encoded><![CDATA[<p>When I started doing professional software development almost 15 years ago I was focused on the server-side.  I started with Perl / CGI web apps &#8211; some of which are still in production today.  Then I dove into Java web development with Java Web Server 1.0, Struts, JBoss, Tomcat and many other game changing technologies.</p>
<p>In 2004 I started getting into Macromedia Flex.  I was amazed at how easy it was to retrieve and nicely render data from a Java back-end.  In 2005 I began evangelizing Flex + Java.  Following the acquisition of Macromedia by Adobe, Flex has really flourished.  Adobe Flex is now the dominant RIA technology and it has been so fun to be a part of that!</p>
<p>Over the past seven years I&#8217;ve had so many great adventures on the client-side, but when a new opportunity on the server-side came my way I couldn&#8217;t pass it up.  Starting June 6th I&#8217;ll be stepping back into the Java world to evangelize the Cloud for Salesforce.com.  I&#8217;m excited to dive into some of the emerging Java/JVM technologies like Scala, Play Framework, and Clojure!</p>
<p>This change is certainly bittersweet for me.  Flex continues to make app development easier.  With things like Android support in Flex 4.5 and iOS support coming soon, the future of Flex is bright.  I&#8217;ve been very privileged to be a part of the Flex community for the past seven years. This group of passionate and creative developers have taught me so many new things.  Learning how to do runtime bytecode modification and co-creating <a href="http://www.jamesward.com/2011/04/26/introducing-mixing-loom-runtime-actionscript-bytecode-modification/">Mixing Loom</a> has certainly been one of the highlights!</p>
<p>As I begin this new adventure on the Cloud I&#8217;m excited about what lies ahead for Flex and for the Cloud.  Both continue to help us developers build better software.  I&#8217;ve hopefully helped you learn how to build great UIs with Flex.  Now I will help you learn how to build solid and scalable back-ends on the Cloud!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2011/06/05/new-adventures-on-the-cloud/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>Dreamforce 2010 and Cloudstock</title>
		<link>http://www.jamesward.com/2010/11/30/dreamforce-2010-and-cloudstock/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dreamforce-2010-and-cloudstock</link>
		<comments>http://www.jamesward.com/2010/11/30/dreamforce-2010-and-cloudstock/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 16:24:09 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Salesforce.com]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=2096</guid>
		<description><![CDATA[I&#8217;ll be speaking at Dreamforce again this year! I have two sessions that are going to be super fun! First is a panel called &#8220;Cloud Mobility: Taking Critical Business Functions With You, Whenever, Wherever&#8221; on Wednesday at 3:15 PM. Then on Thursday at 11am I&#8217;ll be co-presenting a session on &#8220;Building Rich User Interfaces with [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be speaking at <a href="http://www.salesforce.com/dreamforce/DF10/home/">Dreamforce</a> again this year!  I have two sessions that are going to be super fun!  First is a panel called &#8220;Cloud Mobility: Taking Critical Business Functions With You, Whenever, Wherever&#8221; on Wednesday at 3:15 PM.  Then on Thursday at 11am I&#8217;ll be co-presenting a session on &#8220;Building Rich User Interfaces with Adobe Flash Builder for Force.com&#8221; with Markus Spohn from Salesforce.com.</p>
<p>Preceding Dreamforce is the <a href="http://www.cloudstockevent.com">Cloudstock</a> event where you can see some other great presentations related to Flex and RIAs.  <a href="http://blog.theflashblog.com/">Lee Brimelow</a> will be doing a presentation on &#8220;Flex and Flash Platform on the Cloud&#8221; that is guaranteed to entertain and educate.  There will also be presentations from Nigel Pegg on Real-time Apps and Keith Sutton on &#8220;Adobe’s Cloud Offerings for Developers and Enterprises&#8221;.</p>
<p>It&#8217;s going to be a great week!  I hope to see you at Dreamforce 2010!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2010/11/30/dreamforce-2010-and-cloudstock/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Webinar Tomorrow: Building Client/Cloud Apps with Flex and Force.com</title>
		<link>http://www.jamesward.com/2010/09/27/webinar-tomorrow-building-clientcloud-apps-with-flex-and-force-com/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=webinar-tomorrow-building-clientcloud-apps-with-flex-and-force-com</link>
		<comments>http://www.jamesward.com/2010/09/27/webinar-tomorrow-building-clientcloud-apps-with-flex-and-force-com/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 14:12:26 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Salesforce.com]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=2031</guid>
		<description><![CDATA[I will co-presenting a free webinar tomorrow (September 28th, 2010) on building Client/Cloud Apps with Flex and Force.com. There are two times you can choose from: September 28, 2010 &#124; 6:00 a.m. PDT &#124; 2:00 p.m. GMT &#124; 6:30 p.m. IST September 28, 2010 &#124; 10:00 a.m. PDT This session will walk through how you [...]]]></description>
			<content:encoded><![CDATA[<p>I will co-presenting a <a href="https://www.developerforce.com/events/flash_builder_webinar/registration.php?d=70130000000FNwb">free webinar</a> tomorrow (September 28th, 2010) on building Client/Cloud Apps with Flex and Force.com.  There are two times you can choose from:</p>
<ul>
<li>September 28, 2010 | 6:00 a.m. PDT | 2:00 p.m. GMT | 6:30 p.m. IST</li>
<li>September 28, 2010 | 10:00 a.m. PDT</li>
</ul>
<p>This session will walk through how you can get started building applications for the web, desktop, and mobile devices using Flex and Force.com.  Salesforce.com and Adobe have worked together on an extension to the Flash Builder tool which enables developers to quickly build applications on top of the Force.com Cloud platform.  I hope you can join me tomorrow!  <a href="https://www.developerforce.com/events/flash_builder_webinar/registration.php?d=70130000000FNwb">Sign up now!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2010/09/27/webinar-tomorrow-building-clientcloud-apps-with-flex-and-force-com/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Bay Area Event: Building RIAs using Flash Builder for Force.com</title>
		<link>http://www.jamesward.com/2010/08/17/bay-area-event-building-rias-using-the-flash-builder-for-force-com/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bay-area-event-building-rias-using-the-flash-builder-for-force-com</link>
		<comments>http://www.jamesward.com/2010/08/17/bay-area-event-building-rias-using-the-flash-builder-for-force-com/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 17:05:10 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Salesforce.com]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=1959</guid>
		<description><![CDATA[Salesforce.com is putting on a great event on August 25 in San Mateo, California where you can learn about how to build RIAs on the Cloud with Flash Builder for Force.com. This will be a great opportunity to meet the team that built the tool and learn how to use it! If you can&#8217;t make [...]]]></description>
			<content:encoded><![CDATA[<p>Salesforce.com is putting on a <a href="https://www.developerforce.com/events/sanmateo_developer_meetup/registration.php">great event</a> on August 25 in San Mateo, California where you can learn about how to build RIAs on the Cloud with <a href="http://developer.force.com/flashbuilder">Flash Builder for Force.com</a>.  This will be a great opportunity to meet the team that built the tool and learn how to use it!  If you can&#8217;t make it then check out the article I recently published &#8220;<a href="http://www.jamesward.com/2010/07/26/building-client-cloud-apps-with-flash-builder-for-force-com/">Building Client / Cloud Apps with Flash Builder for Force.com</a>&#8220;.  But if you are in the Bay Area and want to get up to speed quickly on building Client / Cloud apps then <a href="https://www.developerforce.com/events/sanmateo_developer_meetup/registration.php">Register Now</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2010/08/17/bay-area-event-building-rias-using-the-flash-builder-for-force-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Client / Cloud Apps with Flash Builder for Force.com</title>
		<link>http://www.jamesward.com/2010/07/26/building-client-cloud-apps-with-flash-builder-for-force-com/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-client-cloud-apps-with-flash-builder-for-force-com</link>
		<comments>http://www.jamesward.com/2010/07/26/building-client-cloud-apps-with-flash-builder-for-force-com/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 19:15:25 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Salesforce.com]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=1894</guid>
		<description><![CDATA[I have a theory. The majority of people who use enterprise software today use old school Client / Server apps. We&#8217;ve been trying to move these apps to the web for more than ten years. The ease of deployment of web apps is a clear motivator. Yet the client capabilities of the plain old web [...]]]></description>
			<content:encoded><![CDATA[<p>I have a theory.  The majority of people who use enterprise software today use old school Client / Server apps.  We&#8217;ve been trying to move these apps to the web for more than ten years.  The ease of deployment of web apps is a clear motivator.  Yet the client capabilities of the plain old web browser have not been sufficient for many apps to make the leap.  This is why I love Flex and the Flash Platform.  It provides a way to use web technologies and the web deployment model but adds many of the critical things needed for mission critical apps that people use all day long.</p>
<p>But no one wants to go back to the Client / Server architecture.  We want to embrace Cloud Computing architectures but not lose the client capabilities.  What we really need is the Client / Cloud architecture.  We need a web deployment model that provides ease of deployment but also the ability to install applications on our desktops and mobile devices.</p>
<p>This is why I&#8217;m so excited about the new <a href="http://developer.force.com/flashbuilder">Adobe Flash Builder for Force.com</a>.  In a nutshell this is a tool that Adobe and Salesforce.com built together to enable developers to build great software using Flex for the UI and Force.com for the Cloud back-end.  It&#8217;s a wonderful combination of technologies that will help many Client / Server apps make the switch to Client / Cloud.</p>
<p>Applications created with Flash Builder for Force.com can be run in the browser, on the desktop, and on mobile devices.  These applications can be assembled from the hundreds of Flex components that are out there (check out many of them in <a href="http://flex.org/tour">Tour de Flex</a>).</p>
<p>Check out this video to see how to use Flash Builder for Force.com to build a simple app:</p>
<p><object width="640" height="385"><param name="movie" value="http://images.tv.adobe.com/swf/player.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="FlashVars" value="fileID=7230&#038;context=64&#038;embeded=true&#038;environment=production"></param><embed src="http://images.tv.adobe.com/swf/player.swf" flashvars="fileID=7230&#038;context=64&#038;embeded=true&#038;environment=production" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p>As you can see, it&#8217;s very easy to get started.  But I wanted to go a step further and try to build something real&#8211;something that shows a genuine use case for extending beyond the out-of-the-box Salesforce.com UI.  I wanted to keep it really simple so that I could post the code here.  What I came up with is this (in user story form):</p>
<ul>
<li>As a Salesforce.com user I want to take a photo, using my phone, of one of my contacts so that the photo can be saved to their contact record for future reference.</li>
<li>As a Salesforce.com user I want to see photos I&#8217;ve taken of my contacts so that I can be reminded of what they look like.</li>
</ul>
<p>Simple enough.  So here is what I came up with:</p>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/RIUwh6wk8cY&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/RIUwh6wk8cY&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></p>
<p>To build these two apps I first downloaded and installed <a href="https://www.developerforce.com/events/flashbuilder/registration.php">Flash Builder for Force.com</a>.  I used the <a href="http://www.adobe.com/go/airbetasignup">Adobe AIR for Android prerelease</a> to build the mobile app.  Here is how I created these apps.</p>
<p>First I added a new field to Contact to store the photo.  Salesforce.com doesn&#8217;t have a binary field so I used a large text field (32k limit).  I&#8217;ll store the photo Base64 encoded.</p>
<p>Then in Salesforce.com I saved my enterprise.wsdl file. Check out a <a href="http://wiki.developerforce.com/index.php/Demo_Building_Desktop_Client_for_the_Cloud">great video from Dave Carroll</a> to see how to do this.</p>
<p>Now in Flash Builder for Force.com I created a new Force.com Flex Project for the mobile app.  If you do this on your own and want to run on a mobile device then you will need to overlay the AIR for Android SDK on top of a Flex 4.1 SDK.  Select Desktop Application as the app type.  Replace WindowedApplication with just Application.  And replace the F3DesktopApplication with F3WebApplication since F3DesktopApplication uses APIs that are not available on AIR for Android.  (BTW: Flash Builder, Flex, and Force.com Flex Projects do not officially support mobile deployment yet.  It works but there is no support and no guarantees.)  If you are building a standard Web Application or Desktop Application then you can just leave the generated code as is.</p>
<p>Using the Data/Services wizard I connected to Salesforce.com using my enterprise.wsdl file.  After the services and value objects have been generated I modified the Contact object and added a Bindable account property.  The generated application already included the F3DesktopApplication Declaration used to connect to Salesforce.  Due to an incompatibility with that API and AIR for Android I switched it to use F3WebApplication.  In F3WebApplication&#8217;s loginComplete event handler I query Salesforce.com for Accounts and then Contacts, associate contacts with their account, and then store the contacts:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">app.<span style="color: #006600;">wrapper</span>.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;select Id, Name from Account&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:ArrayCollection, token:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    accounts = <span style="color: #0066CC;">data</span>;
    app.<span style="color: #006600;">wrapper</span>.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;select Id, AccountId, FirstName, LastName, Phone, MobilePhone, Email, Title, Department, MailingCity, photoData__c from Contact&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:ArrayCollection, token:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> contact:Contact <span style="color: #b1b100;">in</span> <span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> account:Account <span style="color: #b1b100;">in</span> accounts<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>account.<span style="color: #006600;">Id</span> == contact.<span style="color: #006600;">AccountId</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#123;</span>
                    contact.<span style="color: #006600;">account</span> = account;						
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        contacts = <span style="color: #0066CC;">data</span>;
    <span style="color: #66cc66;">&#125;</span>, handleError<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>, handleError<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Notice in the query that I&#8217;m fetching photoData__c, which is the custom field I created on Contact to store the photo.</p>
<p>In the renderer for a contact I need to either display the photo if there is one or let the user add one.  Here is the simple UI code to handle that:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> width=<span style="color: #ff0000;">&quot;92&quot;</span> height=<span style="color: #ff0000;">&quot;92&quot;</span> top=<span style="color: #ff0000;">&quot;8&quot;</span> right=<span style="color: #ff0000;">&quot;8&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> width=<span style="color: #ff0000;">&quot;92&quot;</span> height=<span style="color: #ff0000;">&quot;92&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColor</span> color=<span style="color: #ff0000;">&quot;#cccccc&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> id=<span style="color: #ff0000;">&quot;addPhoto&quot;</span> text=<span style="color: #ff0000;">&quot;Add a photo&quot;</span> width=<span style="color: #ff0000;">&quot;92&quot;</span> height=<span style="color: #ff0000;">&quot;92&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> textAlign=<span style="color: #ff0000;">&quot;center&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BitmapImage</span> id=<span style="color: #ff0000;">&quot;photo&quot;</span> width=<span style="color: #ff0000;">&quot;92&quot;</span> height=<span style="color: #ff0000;">&quot;92&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>When the contact is set I check to see if there is a photo and if so display it:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>contact.<span style="color: #006600;">photoData__c</span> == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    photo.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
    <span style="color: #b1b100;">return</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> decoder:Base64Decoder = <span style="color: #000000; font-weight: bold;">new</span> Base64Decoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
decoder.<span style="color: #006600;">decode</span><span style="color: #66cc66;">&#40;</span>contact.<span style="color: #006600;">photoData__c</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    photo.<span style="color: #006600;">source</span> = event.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span>;
    photo.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">loadBytes</span><span style="color: #66cc66;">&#40;</span>decoder.<span style="color: #006600;">toByteArray</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>The data from the photoData__c field is Base64 decoded and then displayed using the Flex BitmapImage component.</p>
<p>Now when the user clicks on the photo or empty photo box I use the AIR for Android CameraUI to grab a photo, resize it, covert it to a PNG, Base64 encode it, set it on the contact, and then save the contact to Salesforce.com:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>CameraUI.<span style="color: #006600;">isSupported</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    cameraUI = <span style="color: #000000; font-weight: bold;">new</span> CameraUI<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    cameraUI.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MediaEvent.<span style="color: #006600;">COMPLETE</span>, <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event:MediaEvent<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> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>event.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">file</span>.<span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event:Event<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> bitmap:Bitmap = event.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span> as Bitmap;
&nbsp;
            <span style="color: #000000; font-weight: bold;">var</span> result:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">46</span>, <span style="color: #cc66cc;">46</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #000000; font-weight: bold;">var</span> matrix:Matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            matrix.<span style="color: #006600;">scale</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">46</span> <span style="color: #66cc66;">/</span> bitmap.<span style="color: #0066CC;">width</span>, <span style="color: #cc66cc;">46</span> <span style="color: #66cc66;">/</span> bitmap.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
            result.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>bitmap, matrix<span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #000000; font-weight: bold;">var</span> pngEncoder:PNGEncoder = <span style="color: #000000; font-weight: bold;">new</span> PNGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #000000; font-weight: bold;">var</span> pngBytes:ByteArray = pngEncoder.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #000000; font-weight: bold;">var</span> base64Encoder:Base64Encoder = <span style="color: #000000; font-weight: bold;">new</span> Base64Encoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            base64Encoder.<span style="color: #006600;">encodeBytes</span><span style="color: #66cc66;">&#40;</span>pngBytes<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #000000; font-weight: bold;">var</span> encodedImage:<span style="color: #0066CC;">String</span> = base64Encoder.<span style="color: #0066CC;">flush</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            contact.<span style="color: #006600;">photoData__c</span> = encodedImage;
&nbsp;
            displayPhoto<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            F3WebApplication.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">wrapper</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>contact, <span style="color: #000000; font-weight: bold;">new</span> AsyncResponder<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:<span style="color: #0066CC;">Object</span>, token:<span style="color: #0066CC;">Object</span>=<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: #66cc66;">&#125;</span>, FlexGlobals.<span style="color: #006600;">topLevelApplication</span>.<span style="color: #006600;">handleError</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
    cameraUI.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ErrorEvent.<span style="color: #0066CC;">ERROR</span>, <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event:ErrorEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
        FlexGlobals.<span style="color: #006600;">topLevelApplication</span>.<span style="color: #006600;">handleError</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
    cameraUI.<span style="color: #006600;">launch</span><span style="color: #66cc66;">&#40;</span>MediaType.<span style="color: #006600;">IMAGE</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>That&#8217;s it for the mobile app!  I compiled it, exported it to an Android app, and then copied it to my phone.  Pretty simple and as you can see it works!  One limitation with my approach is the 32k limit of the photoData__c field.  However, I think I could easily get around that by striping the Base64 encoded data across multiple fields.  It&#8217;s not ideal but it would work.</p>
<p>To display the photo when I view a contact on Salesforce.com I created a very simple Flex app using another Force.com Flex Project.  I could have also added photo upload to this application but chose to keep it simple.  All it does is display the selected contact&#8217;s photo.  Here is the complete code (after generating the required services in Flash Builder):</p>

<div class="wp_syntax"><div 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;s:Application</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">    xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">    xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">    xmlns:flexforforce=<span style="color: #ff0000;">&quot;http://flexforforce.salesforce.com&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>		
    import mx.rpc.AsyncResponder;
    import mx.utils.Base64Decoder;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;flexforforce:F</span>3WebApplication id=<span style="color: #ff0000;">&quot;app&quot;</span> requiredTypes=<span style="color: #ff0000;">&quot;Contact&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;flexforforce:loginComplete</span><span style="color: #7400FF;">&gt;</span></span>
                app.wrapper.query(&quot;select photoData__c from Contact where Id = '&quot; + this.parameters.contactId + &quot;'&quot;, new AsyncResponder(function(data:Object, token:Object):void {
                    if (data.length == 1)
                    {
                        if (data[0].photoData__c == null)
                        {
                            photo.visible = false;
                            noPhoto.visible = true;
                            return;
                        }
&nbsp;
                        var decoder:Base64Decoder = new Base64Decoder();
                        decoder.decode(data[0].photoData__c);
&nbsp;
                        var loader:Loader = new Loader();
                        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(event:Event):void {
                            photo.source = event.target.content;
                            photo.visible = true;
                        });
                        loader.loadBytes(decoder.toByteArray());
                    }
                }, function(fault:Object):void {
                    // ignored
                }));
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/flexforforce:loginComplete</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/flexforforce:F</span>3WebApplication<span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:applicationComplete</span><span style="color: #7400FF;">&gt;</span></span>
        app.serverUrl = this.parameters.serverUrl;
        app.loginBySessionId(this.parameters.sessionId);
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:applicationComplete</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> width=<span style="color: #ff0000;">&quot;92&quot;</span> height=<span style="color: #ff0000;">&quot;92&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColor</span> color=<span style="color: #ff0000;">&quot;#cccccc&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> id=<span style="color: #ff0000;">&quot;noPhoto&quot;</span> text=<span style="color: #ff0000;">&quot;No Photo&quot;</span> width=<span style="color: #ff0000;">&quot;92&quot;</span> height=<span style="color: #ff0000;">&quot;92&quot;</span> textAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> visible=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BitmapImage</span> id=<span style="color: #ff0000;">&quot;photo&quot;</span> width=<span style="color: #ff0000;">&quot;92&quot;</span> height=<span style="color: #ff0000;">&quot;92&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Finally I created a custom S-Control to run the Flex app:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">classid</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ContactPhoto&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;92&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;92&quot;</span> </span>
<span style="color: #009900;"><span style="color: #000066;">codebase</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab&quot;</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;movie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{!Scontrol.JavaArchive}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flashvars&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sessionId={!API.Session_ID}&amp;serverUrl={!API.Partner_Server_URL_90}&amp;contactId={!Contact.Id}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> 
    <span style="color: #009900;">&lt;embed <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{!Scontrol.JavaArchive}&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;92&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;92&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ContactPhoto&quot;</span> </span>
<span style="color: #009900;">flashvars<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sessionId={!API.Session_ID}&amp;serverUrl={!API.Partner_Server_URL_90}&amp;contactId={!Contact.Id}&quot;</span> </span>
<span style="color: #009900;"><span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;application/x-shockwave-flash&quot;</span> </span>
<span style="color: #009900;">pluginspage<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.adobe.com/go/getflashplayer&quot;</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>embed&gt;</span> 
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">object</span>&gt;</span></pre></div></div>

<p>I uploaded the compiled Flex app to the S-Control and added it to the Contact page.  And that&#8217;s it!  In just a few hours I extended Force.com and built a cool mobile app.  I could also have easily created a desktop widget for browsing contacts and adding photos.  If you are looking for a fun project to use as a way to learn this stuff that would be a good one!  :)</p>
<p>Here are some resources to help you get started with Flash Builder for Force.com:</p>
<ul>
<li><a href="http://wiki.developerforce.com/index.php/Force.com_Flex_Quick_Start_Tutorial">Force.com Flex Quick Start Tutorial</a></li>
<li><a href="http://developerforce.s3.amazonaws.com/website/afb/docs/ASDoc_Flex/index.html">Force.com Flex Project APIs for Web Applications</a></li>
<li><a href="http://developerforce.s3.amazonaws.com/website/afb/docs/ASDoc_AIR/index.html">Force.com Flex Project APIs for Desktop Applications</a></li>
<li><a href="http://developer.force.com/flashbuilder">Numerous other demo applications and tutorials</a></li>
<li><a href="http://github.com/jamesward/MobileContacts">Source code for my mobile contacts demo</a></li>
<li><a href="http://github.com/jamesward/WebContactSControl">Source code for my web contact photo viewer demo</a></li>
</ul>
<p>Have fun building the next generation of software!  Let me know how it goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2010/07/26/building-client-cloud-apps-with-flash-builder-for-force-com/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Flex at the Austin JUG and Stir Trek in Columbus</title>
		<link>http://www.jamesward.com/2010/04/26/flex-at-the-austin-jug-and-stir-trek-in-columbus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-at-the-austin-jug-and-stir-trek-in-columbus</link>
		<comments>http://www.jamesward.com/2010/04/26/flex-at-the-austin-jug-and-stir-trek-in-columbus/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 22:07:10 +0000</pubDate>
		<dc:creator>James Ward</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.jamesward.com/?p=1697</guid>
		<description><![CDATA[Tomorrow night I&#8217;ll be in Austin, Texas speaking at the Java User Group about Better Software with Java and Flex (Try the Google Cache Page in case the site is not working). And then next week I&#8217;ll be at Stir Trek in Columbus, Ohio presenting about Flex and the Cloud. I hope to see some [...]]]></description>
			<content:encoded><![CDATA[<p>Tomorrow night I&#8217;ll be in Austin, Texas speaking at the Java User Group about <a href="http://www.austinjug.org/index.jsp?p=events-20100427">Better Software with Java and Flex</a> (Try the <a href="http://74.125.155.132/search?q=cache:QJI7olGFWdoJ:www.austinjug.org/index.jsp%3Fp%3Devents-20100427+http://www.austinjug.org/index.jsp%3Fp%3Devents-20100427&#038;hl=en&#038;gl=us&#038;strip=1">Google Cache Page</a> in case the site is not working).  And then next week I&#8217;ll be at Stir Trek in Columbus, Ohio presenting about <a href="http://stirtrek.com/Sessions.aspx">Flex and the Cloud</a>.  I hope to see some of you at these events!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesward.com/2010/04/26/flex-at-the-austin-jug-and-stir-trek-in-columbus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

