<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>IT Bits and Pieces</title>
	<atom:link href="http://jpddevelopment.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jpddevelopment.wordpress.com</link>
	<description>Miscellaneous Collection of IT Thoughts</description>
	<lastBuildDate>Thu, 30 Jun 2011 08:39:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jpddevelopment.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>IT Bits and Pieces</title>
		<link>http://jpddevelopment.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jpddevelopment.wordpress.com/osd.xml" title="IT Bits and Pieces" />
	<atom:link rel='hub' href='http://jpddevelopment.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Deploying Adobe Flex into Google AppEngine</title>
		<link>http://jpddevelopment.wordpress.com/2009/04/18/deploying-adobe-flex-into-google-appengine/</link>
		<comments>http://jpddevelopment.wordpress.com/2009/04/18/deploying-adobe-flex-into-google-appengine/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 19:45:46 +0000</pubDate>
		<dc:creator>jpd6</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Google AppEngine]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jpddevelopment.wordpress.com/?p=78</guid>
		<description><![CDATA[In the right hands, Adobe Flex is a powerful tool that can create very powerful user interfaces. There are lots of examples that can be found here. However, Flex isn&#8217;t perfect and does have its faults in particular with accessibility which can also be said of Java Applets and JavaFX. JSPs and Servlets don&#8217;t have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=78&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the right hands, Adobe Flex is a powerful tool that can create very powerful user interfaces. There are lots of examples that can be found <a href="http://flex.org/showcase/">here</a>. However, Flex isn&#8217;t perfect and does have its faults in particular with accessibility which can also be said of Java Applets and JavaFX.  JSPs and Servlets don&#8217;t have the same limitations, but the effort to build a powerful UI in Flex is considerably quicker. I&#8217;ve found that Java is great at &#8216;back-end&#8217; development and not so good at &#8216;front-end&#8217; whereas Flex is the opposite, very good for &#8216;front-end&#8217; development. Both technologies complement each other. That led me to think,  AppEngine can host &#8216;static&#8217; files; this combination should work in AppEngine? The answer is yes!</p>
<p>If you want to try this, I&#8217;ve provided some small test code that uses the &#8216;guestbook&#8217; demo project that comes with AppEngine.</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad1.png?w=548&#038;h=91" alt="" width="548" height="91" /></p>
<p>The screenshot below shows what the &#8216;guestbook&#8217; demo looks like.</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad2.png?w=720" alt="" /></p>
<p>And deploying a test Flex application with the Java project, we get the screenshot below.</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad3.png?w=720" alt="" /></p>
<p>First, build a new &#8216;Flex Project&#8217; using the following code. The key configuration within this code is the &#8216;HTTPService&#8217; that will call a Java servlet which in turn returns the XML of the guestbook postings.</p>
<p><pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:jw=&quot;components.*&quot; applicationComplete=&quot;guestbook.send();&quot;&gt;
&lt;mx:Script&gt;
import mx.rpc.Fault;
import mx.rpc.events.*;
import mx.controls.Alert;

public function faultHandler(event:FaultEvent):void
{  Alert.show(event.fault.faultString, &quot;Error&quot;);  }

public function resultHandler(event:ResultEvent):void
{  }
&lt;/mx:Script&gt;

&lt;mx:HTTPService id=&quot;guestbook&quot; url=&quot;/greetings&quot;	method=&quot;GET&quot; resultFormat=&quot;e4x&quot;
  fault=&quot;faultHandler(event);&quot; result=&quot;resultHandler(event);&quot; /&gt;

&lt;mx:Panel id=&quot;panel&quot; title=&quot;Guest Book&quot;&gt;
  &lt;mx:DataGrid id=&quot;dataGrid&quot; dataProvider=&quot;{guestbook.lastResult.post}&quot; editable=&quot;false&quot;&gt;
     &lt;mx:columns&gt;
       &lt;mx:DataGridColumn id=&quot;nicknameColumn&quot; width=&quot;100&quot; dataField=&quot;nickname&quot; headerText=&quot;Nickname&quot; /&gt;
       &lt;mx:DataGridColumn id=&quot;contentColumn&quot; width=&quot;200&quot; dataField=&quot;content&quot; headerText=&quot;Content&quot; /&gt;
       &lt;mx:DataGridColumn id=&quot;dateColumn&quot; width=&quot;100&quot; dataField=&quot;date&quot; headerText=&quot;Date&quot; /&gt;
      &lt;/mx:columns&gt;
     &lt;/mx:DataGrid&gt;
&lt;/mx:Panel&gt;
&lt;/mx:Application&gt;
</pre></p>
<p>Within the &#8216;Guest Book&#8217; project, create a new servlet &#8216;GreetingXMLServlet.java&#8217;.</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad4.png?w=720" alt="" /></p>
<p>Paste the following code that creates the XML file to be returned to the Flex application. This servlet queries the object datastore for all the guestbook postings.</p>
<p><pre class="brush: java;">
package guestbook;
import java.util.List;
import javax.jdo.PersistenceManager;
import guestbook.Greeting;
import guestbook.PMF;
import java.io.IOException;
import javax.servlet.http.*;
@SuppressWarnings(&quot;serial&quot;)
public class GreetingsXMLServlet extends javax.servlet.http.HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
resp.setContentType(&quot;text/xml&quot;);
PersistenceManager pm = PMF.get().getPersistenceManager();
String query = &quot;select from &quot; + Greeting.class.getName() + &quot; order by date desc range 0,5&quot;;
List&lt;Greeting&gt; greetings = (List&lt;Greeting&gt;) pm.newQuery(query).execute();
if (!greetings.isEmpty())
{
resp.getWriter().println(&quot;&lt;greetings&gt;&quot;);
for (Greeting g : greetings)
{
resp.getWriter().println(&quot;
&lt;post&gt;&quot;);
if (g.getAuthor() == null)
resp.getWriter().println(&quot;&lt;nickname&gt;Anonymous&lt;/nickname&gt;&quot;);
else
resp.getWriter().println(&quot;&lt;nickname&gt;&quot; + g.getAuthor().getNickname() + &quot;&lt;/nickname&gt;&quot;);
resp.getWriter().println(&quot;&lt;content&gt;&quot; + g.getContent() + &quot;&lt;/content&gt;&quot;);
resp.getWriter().println(&quot;&lt;date&gt;&quot; + g.getDate() + &quot;&lt;/date&gt;&quot;);
resp.getWriter().println(&quot;&lt;/post&gt;&quot;);
}
resp.getWriter().println(&quot;&lt;/greetings&gt;&quot;);
}
pm.close();
}
} </pre></p>
<p>Paste the following into &#8216;war/WEB-INF/lib/web.xml&#8217; to configure the servlet.</p>
<p><pre class="brush: xml;">
&lt;servlet&gt;
&lt;servlet-name&gt;greetings&lt;/servlet-name&gt;
&lt;servlet-class&gt;guestbook.GreetingsXMLServlet&lt;/servlet-class&gt;
&lt;/servlet&gt;

&lt;servlet-mapping&gt;
&lt;servlet-name&gt;greetings&lt;/servlet-name&gt;
&lt;url-pattern&gt;/greetings&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
</pre></p>
<p>Finally, import the &#8216;Flex&#8217; release files into the &#8216;war&#8217; folder of the &#8216;Guest Book&#8217;. If you have both projects in Eclipse, drag and drop it!</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad5.png?w=720" alt="" /></p>
<p>The Files are now within the &#8216;Guest Book&#8217; project, and deploy into AppEngine!</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad6.png?w=720" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jpddevelopment.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jpddevelopment.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jpddevelopment.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jpddevelopment.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jpddevelopment.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jpddevelopment.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jpddevelopment.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jpddevelopment.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jpddevelopment.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jpddevelopment.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jpddevelopment.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jpddevelopment.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jpddevelopment.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jpddevelopment.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=78&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jpddevelopment.wordpress.com/2009/04/18/deploying-adobe-flex-into-google-appengine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2296c833e6323e597fdbee6fc69c1ac3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpd6</media:title>
		</media:content>

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad1.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad2.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad3.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad4.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad5.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041809-1945-deployingad6.png" medium="image" />
	</item>
		<item>
		<title>Google Java AppEngine environment from one line of code</title>
		<link>http://jpddevelopment.wordpress.com/2009/04/14/google-java-appengine-environment-from-one-line-of-code/</link>
		<comments>http://jpddevelopment.wordpress.com/2009/04/14/google-java-appengine-environment-from-one-line-of-code/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 20:41:43 +0000</pubDate>
		<dc:creator>jpd6</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Google AppEngine]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jpddevelopment.wordpress.com/2009/04/14/google-java-appengine-environment-from-one-line-of-code/</guid>
		<description><![CDATA[When working on web projects, I always find it useful to capture the &#8216;environment&#8217; of where the application is being hosted and document it. I&#8217;ve found this particularly applicable for .NET projects rather than Java, especially when the application suddenly breaks with no warning! This is more often than not due to a service pack [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=65&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When working on web projects, I always find it useful to capture the &#8216;environment&#8217; of where the application is being hosted and document it. I&#8217;ve found this particularly applicable for .NET projects rather than Java, especially when the application suddenly breaks with no warning! This is more often than not due to a service pack install, security fixes or some software install.</p>
<p>What version information can be gathered from the AppEngine? There&#8217;s a handy function getProperties() that will return all the system properties available to a Java app. The list that is available from the AppEngine JVM is restricted as outlined in the &#8216;Environment&#8217; section of this <a href="http://code.google.com/appengine/docs/java/runtime.html">page</a>. So…. running the following line of code… <em>System.getProperties().list(resp.getWriter());</em>….what do we get?</p>
<p><span style="font-family:Courier New;font-size:10pt;">&#8211; listing properties &#8211;</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.vendor=Sun Microsystems Inc.</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.specification.version=1.6</span><span style="font-family:Courier New;font-size:10pt;"><br />
line.separator=</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.class.version=50.0</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.util.logging.config.file=WEB-INF/logging.properties</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.specification.name=Java Platform API Specification</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.vendor.url=http://java.sun.com/</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.vm.version=1.6.0_13</span><span style="font-family:Courier New;font-size:10pt;"><br />
os.name=Linux</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.version=1.6.0_13</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.vm.specification.version=1.0</span><span style="font-family:Courier New;font-size:10pt;"><br />
user.dir=/base/data/home/apps/versionapp/1.3327&#8230;</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.vm.specification.name=Java Virtual Machine Specification<br />
java.specification.vendor=Sun Microsystems Inc.</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.vm.vendor=Sun Microsystems Inc.</span><span style="font-family:Courier New;font-size:10pt;"><br />
file.separator=/</span><span style="font-family:Courier New;font-size:10pt;"><br />
path.separator=:</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.vm.name=Java HotSpot(TM) Client VM</span><span style="font-family:Courier New;font-size:10pt;"><br />
java.vm.specification.vendor=Sun Microsystems Inc.</span><span style="font-family:Courier New;font-size:10pt;"><br />
file.encoding=ANSI_X3.4-1968<br />
</span></p>
<p>No real surprises, running Java version 6 &#8211; update 13 on Linux. Admittedly, this doesn&#8217;t tell the full story as the &#8216;readme&#8217; file included with the App Engine SDK reveals more.</p>
<p><span style="font-family:Courier New;font-size:10pt;">Google App Engine SDK for Java<br />
Copyright (c) Google, Inc. 2009.  All rights reserved.<br />
Visit Google Code (<a href="http://code.google.com/appengine/">http://code.google.com/appengine/</a>).</span><span style="font-family:Courier New;font-size:10pt;"><br />
This product includes software developed by:<br />
- The Apache Software Foundation (http://www.apache.org/).<br />
- The servlet specification classes: servlet-api-2.5.jar, jsp-api-2.1.jar, el-api-2.1.jar<br />
- Apache Ant (http://ant.apache.org/)<br />
- Jakarta Commons Logging (http://commons.apache.org/logging/)<br />
- Jakarta Commons HttpClient (http://jakarta.apache.org/commons/httpclient/)<br />
- Jakarta Commons Codec (http://commons.apache.org/codec/)<br />
- Jakarta Commons EL (http://commons.apache.org/el/)<br />
- Jakarta Jasper (http://tomcat.apache.org/svn.html)<br />
- Jakarta Taglibs (http://jakarta.apache.org/taglibs/)<br />
- The Apache Geronimo Project (http://geronimo.apache.org/)<br />
- javax/mail with modifications<br />
- javax/activation<br />
- geronimo-servlet_2.5_spec-1.2.jar, geronimo-jsp_2.1_spec-1.0.1.jar, geronimo-el_1.0_spec-1.0.1.jar<br />
- Mort Bay Consulting (http://www.mortbay.org)<br />
- Jetty web server<br />
</span></p>
<p>We can see that Jetty web server and the Geronimo project are used.</p>
<p>Before anybody complains, that technically more than one line of code was used as there is no declaration function for the servlet… here&#8217;s the full one line!</p>
<p><span style="font-family:Courier New;font-size:10pt;"> <pre class="brush: java;">package com.test; public class versionServlet extends javax.servlet.http.HttpServlet { public void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException { System.getProperties().list(resp.getWriter()); } }</pre></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
</span></p>
<p></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jpddevelopment.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jpddevelopment.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jpddevelopment.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jpddevelopment.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jpddevelopment.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jpddevelopment.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jpddevelopment.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jpddevelopment.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jpddevelopment.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jpddevelopment.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jpddevelopment.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jpddevelopment.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jpddevelopment.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jpddevelopment.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=65&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jpddevelopment.wordpress.com/2009/04/14/google-java-appengine-environment-from-one-line-of-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2296c833e6323e597fdbee6fc69c1ac3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpd6</media:title>
		</media:content>
	</item>
		<item>
		<title>Google AppEngine: Measuring Java and Python performance</title>
		<link>http://jpddevelopment.wordpress.com/2009/04/13/google-appengine-java-and-python-performance/</link>
		<comments>http://jpddevelopment.wordpress.com/2009/04/13/google-appengine-java-and-python-performance/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 17:35:52 +0000</pubDate>
		<dc:creator>jpd6</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google AppEngine]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://jpddevelopment.wordpress.com/2009/04/13/google-appengine-java-and-python-performance/</guid>
		<description><![CDATA[Google has recently made available the hosting of Java applications on the Google AppEngine environment which is fantastic! It did get me thinking what would the performance of Java and Python be like when hosted in the Google environment? This is difficult to answer as one of the appealing aspects of AppEngine is that the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=56&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Google has recently made available the hosting of Java applications on the <a href="http://code.google.com/appengine/">Google AppEngine</a> environment which is fantastic! It did get me thinking what would the performance of Java and Python be like when hosted in the Google environment? This is difficult to answer as one of the appealing aspects of AppEngine is that the developer does not need to concern themselves with the hardware environment. This also means that we don&#8217;t know the precise details as to how the applications are clustered or given allocation of CPU. However, one thing that is appealing about the AppEngine is that it is a scalable environment that can grow depending upon the application requirements. So… I thought that I&#8217;ll write a very primitive Java and Python script to run on a local machine and on AppEngine and see what happens.</p>
<p><span style="color:red;">Disclaimer!!</span> &#8211; As with any metric testing, I need to state a disclaimer that a lot of factors can heavily influence the timing, such as other applications running locally, network performance, Java optimization, garbage collection, class loading, caching etc. etc. the list can go on and on. There isn&#8217;t an easy way that I&#8217;m aware of to get precise and fair timings across all environments. In particular as it&#8217;s a hosted environment Google could decide next week to upgrade the hardware thus giving a very different set of results!</p>
<p>I decided to create a bare minimum app that calls math functions that are available in Java and Python. Upload this app to AppEngine without any optimizations to the code or changing any of the default settings in AppEngine. I wanted the code in both apps to be as similar as possible, but another disclaimer Python and Java can&#8217;t be compared fully as they both have differences in their behavior. In particular when using the Math functions in Python it is dependent upon the OS that is hosting it. I.e. running &#8216;<span style="font-family:Courier New;">print math.pow(10,6)&#8217;</span> generates an error in the Google Python environment.</p>
<p>I decided to run three tests using Square Root, Power and Log. Run it 10 times and note the output. The local environment that I ran the tests is a single core Intel Pentium M 2Ghz, Win XP Service Pack 3 with 1Gb RAM.</p>
<p>What happened?<span id="more-56"></span></p>
<p>Before I go any further, the code that I used… yes, yes.. optimizations can be applied etc. but I wanted to use the most basic app out of the box.</p>
<p>Java:</p>
<p><pre class="brush: java;">
import java.io.IOException;
import javax.servlet.http.*;
@SuppressWarnings(&quot;serial&quot;)
public class metric1Servlet extends HttpServlet
{
 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
 {
   resp.setContentType(&quot;text/plain&quot;);

  long start = System.nanoTime();
  int result = 0;
  for (int i = 0; i &lt; Math.pow(10,5); i++)
  {  result += Math.sqrt(i);  }
  long duration = (System.nanoTime() - start) / 1000000;
  resp.getWriter().println(&quot;Test 1: &quot; + duration + &quot;ms&quot;);

  start = System.nanoTime();
  result = 0;
  for (int i = 0; i &lt; Math.pow(10,5); i++)
  { result += Math.pow(Math.E, 2) }
  duration = (System.nanoTime() - start) / 1000000; &lt;
  resp.getWriter().println(&quot;Test 2: &quot; + duration + &quot;ms&quot;); 

  start = System.nanoTime();
  result = 0;
  for (int i = 0; i &lt; Math.pow(10,5); i++) &amp;
  {  result += Math.log(Math.random()); }
  duration = (System.nanoTime() - start) / 1000000;
  resp.getWriter().println(&quot;Test 3: &quot; + duration + &quot;ms&quot;);
 }
}
</pre></p>
<p>Python:</p>
<p><pre class="brush: python;">
import time
import math
import random

print 'Content-Type: text/plain'
print ''

start = time.time()
result=0
for i in range(0,int(math.pow(10,5))):
result =+ math.sqrt(i)
duration = (time.time() - start)*1000
print &quot;Test 1: &quot;, duration ,&quot;ms&quot;

start = time.time()
result=0
for i in range(0,int(math.pow(10,5))):
result += math.pow(math.e, 2)
duration = (time.time() - start)*1000
print &quot;Test 2: &quot;, duration ,&quot;ms&quot;

start = time.time()
result=0
for i in range(0,int(math.pow(10,5))):
result += math.log(random.random())
duration = (time.time() - start)*1000
print &quot;Test 3: &quot;, duration ,&quot;ms&quot;
</pre></p>
<p>I should mention that the AppEngine has a request timeout to kill any page requests taking longer than 30 seconds. The tests had to be quite short thus most disappointingly couldn&#8217;t be used to calculate the &#8216;meaning of life&#8217;. Perhaps next time Google? Anyway, details about the request timer for Java can be found <a href="http://code.google.com/appengine/docs/java/runtime.html">here</a> under &#8216;Request Timer&#8217;.</p>
<p>The output:</p>
<p>Test 1:</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041309-1735-googleappen1.gif?w=720" alt="" /></p>
<p>Test 2:</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041309-1735-googleappen2.gif?w=720" alt="" /></p>
<p>Test 3:</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041309-1735-googleappen3.gif?w=720" alt="" /></p>
<p>The first thing from the results is that running it 10 times really isn&#8217;t enough… when I get the time, I need to run it on a larger scale.</p>
<p>From the data, it&#8217;s interesting to see that Java is fairly consistent overall and there is a performance boost running it on the Google environment which is what I would expect as my local machine isn&#8217;t exactly &#8216;state of the art&#8217;. Test 2 does show some discrepancy for running the Java locally but shows some sign of consistency towards the end.</p>
<p>Python is very different in that running it in the AppEngine environment doesn&#8217;t show anywhere near the consistency of Java. The chart with the averages below shows the differences clearer.</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041309-1735-googleappen4.gif?w=720" alt="" /></p>
<p>Could it be the timing of when I ran the tests, such that the Python servers have more workload and that the Java environment is on a limited rollout? Hard to say… also running Java locally is consistently slower whereas Python in the AppEngine doesn&#8217;t always seem to be faster. Are these results just a one off? I used a clean install of Python when testing locally thus I made no customizations to the Python environment or to the Python App Engine SDK. I think I&#8217;ve raised more questions to myself than answers…hmmm not what I was planning! I think the key thing that I take from these basic tests is that it has shown differences between the two environments and that I really need to do these again on a larger scale.</p>
<p>That lead to another question, is it worth developing everything in Java as it&#8217;s that much faster than Python? I wouldn&#8217;t say so, as the tests don&#8217;t really answer this question sufficiently as both languages have their own strengths and weaknesses. Also, if it is the case that Java is on a limited rollout, the results could be very different when the Java AppEngine is fully available to everyone.</p>
<p>A key point that I take from these tests, is that there are so many &#8216;factors&#8217; involved when the application is being hosted, it&#8217;s got me thinking about how applications can be accurately stress tested and measured when the hardware environment could change any time along with the varying performance of the local internet connectivity. Somebody might already have the answer for this, if they have let me know!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jpddevelopment.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jpddevelopment.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jpddevelopment.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jpddevelopment.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jpddevelopment.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jpddevelopment.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jpddevelopment.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jpddevelopment.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jpddevelopment.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jpddevelopment.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jpddevelopment.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jpddevelopment.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jpddevelopment.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jpddevelopment.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=56&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jpddevelopment.wordpress.com/2009/04/13/google-appengine-java-and-python-performance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2296c833e6323e597fdbee6fc69c1ac3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpd6</media:title>
		</media:content>

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041309-1735-googleappen1.gif" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041309-1735-googleappen2.gif" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041309-1735-googleappen3.gif" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041309-1735-googleappen4.gif" medium="image" />
	</item>
		<item>
		<title>Word Clouding Gmail Junk</title>
		<link>http://jpddevelopment.wordpress.com/2009/04/12/word-clouding-gmail-junk/</link>
		<comments>http://jpddevelopment.wordpress.com/2009/04/12/word-clouding-gmail-junk/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 20:02:47 +0000</pubDate>
		<dc:creator>jpd6</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[GMail]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jpddevelopment.wordpress.com/2009/04/12/word-clouding-gmail-junk/</guid>
		<description><![CDATA[I couldn&#8217;t resist it… I had to know what &#8216;word clouding&#8217; my Gmail junk folder would look like…. I can sleep safely at night as I can see &#8216;unsubscribe&#8217; is very popular. Maybe it&#8217;s time for me to start reading the junk and clicking &#8216;unsubscribe&#8217; and buying watches from my junk mail folder. For those [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=42&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t resist it… I had to know what &#8216;word clouding&#8217; my Gmail junk folder would look like….</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041209-2002-wordcloudin1.png?w=720" alt="" /></p>
<p>I can sleep safely at night as I can see &#8216;unsubscribe&#8217; is very popular.  Maybe it&#8217;s time for me to start reading the junk and clicking &#8216;unsubscribe&#8217; and buying watches from my junk mail folder.</p>
<p>For those who have the morbid curiosity to do the same for their own mailbox, Gmail currently only provides one documented interface for extracting emails and that&#8217;s via POP3/IMAP4. However, an alternative and quicker approach if you use &#8216;offline email&#8217; is to read the local Gmail Gears <a href="http://www.sqlite.org/">sqlite</a> database. Gears uses the database to store the offline data, thus it&#8217;s a case of querying the local database with a Sql statement and writing to a text file. The text file I pass through to the <a href="http://www.alphaworks.ibm.com/tech/wordcloud">word-cloud generator</a>.</p>
<p>The location of the database can vary depending upon the browser you are using and whether you are going through http or https. Look <a href="http://gears.google.com/support/bin/answer.py?answer=79850&amp;topic=13192">here</a> if you want to find the specific location of the database. The code I used to extract the mails is quite short as below.</p>
<p><pre class="brush: java;">
import java.sql.*;
import java.io.*;

public class ReadGMail
{
  public static void main(String[] args) throws Exception
  {
    Class.forName(&quot;org.sqlite.JDBC&quot;);
    Connection conn = DriverManager.getConnection(&quot;gmail.com-GoogleMail#database&quot;);

    FileWriter fstream = new FileWriter(&quot;gmail.txt&quot;);
    BufferedWriter out = new BufferedWriter(fstream);
    Statement stat = conn.createStatement();
    ResultSet rs = stat.executeQuery(&quot;SELECT c0Subject, c1Body  FROM MessagesFT_content;&quot;);
    while (rs.next())
    {
      out.write(rs.getString(&quot;c0Subject&quot;) + &quot;\n&quot;);
      out.write(rs.getString(&quot;c1Body&quot;).replaceAll(&quot;\\&lt;.*?&gt;&quot;,&quot;&quot;) + &quot;\n\n&quot;);
    }
    out.close();
    rs.close();
    conn.close();
  }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jpddevelopment.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jpddevelopment.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jpddevelopment.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jpddevelopment.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jpddevelopment.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jpddevelopment.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jpddevelopment.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jpddevelopment.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jpddevelopment.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jpddevelopment.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jpddevelopment.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jpddevelopment.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jpddevelopment.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jpddevelopment.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=42&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jpddevelopment.wordpress.com/2009/04/12/word-clouding-gmail-junk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2296c833e6323e597fdbee6fc69c1ac3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpd6</media:title>
		</media:content>

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041209-2002-wordcloudin1.png" medium="image" />
	</item>
		<item>
		<title>Cloud Generating a Lotus Notes Mailbox</title>
		<link>http://jpddevelopment.wordpress.com/2009/04/12/cloud-generating-a-lotus-notes-mailbox/</link>
		<comments>http://jpddevelopment.wordpress.com/2009/04/12/cloud-generating-a-lotus-notes-mailbox/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 17:18:53 +0000</pubDate>
		<dc:creator>jpd6</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Lotus Notes]]></category>
		<category><![CDATA[Wordle]]></category>

		<guid isPermaLink="false">http://jpddevelopment.wordpress.com/2009/04/12/cloud-generating-a-lotus-notes-mailbox/</guid>
		<description><![CDATA[&#8220;Wordle&#8221; is a very nice website that allows you to create &#8220;word clouds&#8221; from text as shown below. More examples can be found within the gallery. The code to generate the cloud images is available from the &#8216;Word-Cloud Generator&#8217; project part of IBM alphaWorks. However, what I really wanted to do is to generate a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=34&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8220;Wordle&#8221; is a very nice <a href="http://www.wordle.net/">website</a> that allows you to create &#8220;word clouds&#8221; from text as shown below.</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041209-1718-cloudgenera1.png?w=720" alt="" /></p>
<p>More examples can be found within the <a href="http://www.wordle.net/gallery">gallery</a>. The code to generate the cloud images is available from the &#8216;<a href="http://www.alphaworks.ibm.com/tech/wordcloud">Word-Cloud Generator&#8217;</a> project part of <a href="http://www.alphaworks.ibm.com/tech/wordcloud">IBM alphaWorks</a>. However, what I really wanted to do is to generate a &#8216;cloud&#8217; from a Lotus Notes mailbox. As the tool only requires a text file, it&#8217;s just a case of exporting the subject and body of the emails into a text file. (Initially, I was doing it with DXL and applying a style sheet as it was faster, but DXL crashes too often for my liking!)</p>
<p><span id="more-34"></span>I scheduled a weekly java agent to read the inbox and within the agent I attached the archive &#8216;ibm-word-cloud.jar&#8217; to allow the &#8216;generator&#8217; to run under the Domino JVM. &#8216;Word Cloud&#8217; requires a configuration file that tells it how to generate the image such as fonts, stop words etc. This file is very well commented and included within the word-cloud generator project download. It&#8217;s very interesting seeing mailboxes in a cloud format, thus I would recommend giving it a shot on your own mail file!</p>
<p>Below you&#8217;ll find an amended version of the java agent that I schedule weekly under R8 to send an image via email.</p>
<p><pre class="brush: java;">
import java.io.*;
import java.io.File;
import lotus.domino.*;

public class JavaAgent extends AgentBase
{
    // Work Directory
    private static final String WORK_DIRECTORY=&quot;C:\\temp\\WordCloud\\&quot;;

    // Word Cloud configuration file
    private static final String CONFIG_FILE =WORK_DIRECTORY + &quot;Configuration.txt&quot;;

    // Mail file Output
    private static final String MAIL_TEXT =WORK_DIRECTORY + &quot;mail.txt&quot;;

    // Generated Image
   private static final String TEMP_FILENAME=WORK_DIRECTORY + &quot;temp.png&quot;;

    // Size of Image
    private static final String IMAGE_WIDTH=&quot;800&quot;;
    private static final String IMAGE_HEIGHT=&quot;800&quot;;

    public void NotesMain()
    {
        try
        {
            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();

            Database db = agentContext.getCurrentDatabase();

            // Intentionally processed inbox view only
            // Change the following to db.alldocuments if you want to do the whole database
            View view = db.getView(&quot;($Inbox)&quot;);

            // Write out the mails to text file.
            File outFile = new File(MAIL_TEXT);
            FileWriter fstream = new FileWriter(outFile);
            BufferedWriter out = new BufferedWriter(fstream);

            Document doc = view.getFirstDocument();
            while (doc != null)
            {
                if (doc.hasItem(&quot;Body&quot;))
                {
                    Item body = doc.getFirstItem(&quot;Body&quot;);
                    if (body.getType()==Item.RICHTEXT)
                    {
                        RichTextItem rtbody = (RichTextItem)doc.getFirstItem(&quot;Body&quot;);
                        // Extract subject and body only
                        out.write(doc.getItemValueString(&quot;Subject&quot;));
                        out.write(rtbody.getFormattedText(false, 0, 0) + &quot;\n&quot;);
                    }
                }
            doc = view.getNextDocument(doc);
        }

        out.close();

        // Pass parameters to IBM Word Cloud
        String[] params= new String[10];
        params[0]=&quot;-c&quot;;
        params[1]=CONFIG_FILE;
        params[2]=&quot;-w&quot;;
        params[3]=IMAGE_WIDTH;
        params[4]=&quot;-h&quot;;
        params[5]=IMAGE_HEIGHT;
        params[6]=&quot;-i&quot;;
        params[7]=MAIL_TEXT;
        params[8]=&quot;-o&quot;;
        params[9]=TEMP_FILENAME;

        // There is an additional parameter '-s' for seed. See readme.html file included within IBM Word Cloud package
        com.ibm.wordcloud.Main.main(params);

        // Send the generated image via email
        Document memo = db.createDocument();
        memo.appendItemValue(&quot;Form&quot;, &quot;Memo&quot;);
        memo.appendItemValue (&quot;Subject&quot;, &quot;Wordy output of mailfile&quot;);

        RichTextItem body = memo.createRichTextItem(&quot;Body&quot;);
        body.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, TEMP_FILENAME,null);
        memo.send(&quot;mailinggroup@example.com&quot;);

        // Don't need the image and text file anymore.
       if (outFile.exists())
         outFile.delete();

       File f= new File(TEMP_FILENAME);
       if (f.exists())
          f.delete();

    }
    catch(Exception e)
    {  e.printStackTrace();  }
    }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jpddevelopment.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jpddevelopment.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jpddevelopment.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jpddevelopment.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jpddevelopment.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jpddevelopment.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jpddevelopment.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jpddevelopment.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jpddevelopment.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jpddevelopment.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jpddevelopment.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jpddevelopment.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jpddevelopment.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jpddevelopment.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=34&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jpddevelopment.wordpress.com/2009/04/12/cloud-generating-a-lotus-notes-mailbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2296c833e6323e597fdbee6fc69c1ac3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpd6</media:title>
		</media:content>

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041209-1718-cloudgenera1.png" medium="image" />
	</item>
		<item>
		<title>Office Communicator 2007 SDK Hello World</title>
		<link>http://jpddevelopment.wordpress.com/2009/04/11/ocs-2007-sdk-hello-world/</link>
		<comments>http://jpddevelopment.wordpress.com/2009/04/11/ocs-2007-sdk-hello-world/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 10:24:10 +0000</pubDate>
		<dc:creator>jpd6</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[OCS 2007 SDK]]></category>
		<category><![CDATA[Office Communicator]]></category>

		<guid isPermaLink="false">http://jpddevelopment.wordpress.com/2009/04/11/ocs-2007-sdk-hello-world/</guid>
		<description><![CDATA[When looking at an API, I almost always look at the code samples within the SDK first&#8230; and then read the help if I don&#8217;t understand it! I downloaded the Office Communicator 2007 SDK the other day and to my surprise there are no samples but only header files. There may be sample files somewhere [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=18&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When looking at an API, I almost always look at the code samples within the SDK first&#8230; and then read the help if I don&#8217;t understand it! I downloaded the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ed1cce45-cc22-46e1-bd50-660fe6d2c98c&amp;displaylang=en">Office Communicator 2007 SDK</a> the other day and to my surprise there are no samples but only header files. There may be sample files somewhere but it&#8217;s not obvious. There is plenty of code within the help documentation, but it would have been nice to have included at least a &#8216;hello world&#8217; project. Anyway, I&#8217;ve attached one below for anybody who just wants the bare minimum &#8216;hello world&#8217; for the OC 2007 SDK. The code is copied mostly from within the OCSDK help documentation, with some minor modifications.</p>
<pre><span id="more-18"></span>
<pre class="brush: csharp;">
using System;
using CommunicatorAPI;
using System.Runtime.InteropServices; 

namespace CommunicatorAPIHelloWorld
{
 class Program
 {
  static void Main(string[] args)
  {
   CommunicatorAPISample client = new CommunicatorAPISample();
   Console.WriteLine(&quot;Login&quot;);
   client.Signin(&quot;username&quot;, &quot;password&quot;);
   Console.ReadKey();

   Console.WriteLine(&quot;Start IM Conversation&quot;);
   client.startConversation(&quot;joe.bloggs@example.com&quot;);
   Console.ReadKey();

   Console.WriteLine(&quot;Show contacts&quot;);
   client.ShowContacts();
   Console.ReadKey();

   Console.WriteLine(&quot;Send Message&quot;);
   client.SendTextMessage(&quot;Another Message&quot;);
   Console.ReadKey();

   Console.WriteLine(&quot;Capture IM Window&quot;);
   client.WriteHistory();
   client.Signout();
  }
 }

class CommunicatorAPISample
{
 private long imWindowHandle; // handle to the current conversation window
 private bool connected = false;
 private CommunicatorAPI.Messenger communicator = null;
 private IMessengerConversationWndAdvanced imWindow = null;
 public CommunicatorAPISample()
 { }

 // A simple implementation of signing in.
 public void Signin(string account, string passwd)
 {
    if (connected)
     return;

   if (communicator == null)
   {
     // Create a Messenger object, if necessary
     communicator = new CommunicatorAPI.Messenger();

    // Register event handlers for OnSignin and Signout events
    communicator.OnSignin += new DMessengerEvents_OnSigninEventHandler(communicator_OnSignin);
    communicator.OnSignout += new DMessengerEvents_OnSignoutEventHandler(communicator_OnSignout);
    communicator.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler(communicator_OnIMWindowCreated);
    communicator.OnIMWindowDestroyed += new DMessengerEvents_OnIMWindowDestroyedEventHandler(communicator_OnIMWindowDestroyed);
  }

  if (account == null)
    communicator.AutoSignin();
  else
    communicator.Signin(0, account, passwd);
}

 // Event handler for OnSignin event.
 void communicator_OnSignin(int hr)
 {
   if (hr != 0)
   {
     Console.WriteLine(&quot;Signin failed.&quot;);
     return;
   }
   connected = true;
 }

 void communicator_OnSignout()
 {
    connected = false;

    // Release the unmanaged resource.
   Marshal.ReleaseComObject(communicator);
   communicator = null;
 }

 // Register for IMWindowCreated event to receive the
 // conversation window object. Other window objects can
 // received via this event handling as well.
 void communicator_OnIMWindowCreated(object pIMWindow)
 {
   try
   {
     imWindow = (IMessengerConversationWndAdvanced)pIMWindow;
     if (((IMessengerConversationWndAdvanced)pIMWindow).HWND == imWindowHandle)
       { /* SendTextMessage(&quot;Hello World!&quot;); Could send message here */ }
     else
       { imWindowHandle = imWindow.HWND; }
   }
   catch (COMException comException)
     { throw comException; }
   catch (Exception exception)
     { throw (exception); }
 }

 void communicator_OnIMWindowDestroyed(object pIMWindow)
 {
   try
    { Marshal.ReleaseComObject(pIMWindow); }
   catch (COMException comException)
    { throw comException; }
  catch (Exception exception)
    { throw (exception); }
 }

 public long startConversation(string account)
 {
   object[] sipUris = { account };
   CommunicatorAPI.IMessengerAdvanced msgrAdv = communicator as CommunicatorAPI.IMessengerAdvanced;

  if (msgrAdv != null)
  {
    try
    {
     object obj = msgrAdv.StartConversation(
        CONVERSATION_TYPE.CONVERSATION_TYPE_IM, // Type of conversation
        sipUris, // object array of signin names for having multiple conversations
        null,
        &quot;Testing&quot;,
        &quot;1″,
        null);

     imWindowHandle = long.Parse(obj.ToString());
    }
    catch (COMException ex)
    { Console.WriteLine(ex.ErrorCode); }
  }

  return imWindowHandle;
 }

  // Send text only if the window object matches the desired window handle
  public void SendTextMessage(string msg)
  {
    if (imWindow == null)
      return;

    if (imWindow.HWND == imWindowHandle)
      { imWindow.SendText(msg); }
  }

  public void ShowContacts()
  {
    // Display contacts to a console window(for illustration only).
    foreach (IMessengerContact contact in communicator.MyContacts as IMessengerContacts)
    {
      if (!contact.IsSelf)
       Console.WriteLine(&quot;{0} ({1})&quot;, contact.SigninName, contact.Status);
    }
  }

 public void WriteHistory()
 {
    if (imWindow != null)
   {
     try
      { Console.WriteLine(imWindow.History); }
    catch (COMException CE)
      { Console.WriteLine(&quot;COM Exception &quot; + CE.ErrorCode.ToString()); }
   }
 }

 // A simple implementation of signing out.
 public void Signout()
 {
   if (!connected)
    return;

   if (communicator == null)
    return;

  communicator.Signout();
  }
 }
}
</pre>

If you're after a WinForms sample, a nice VS project can be found <a href="http://blogs.claritycon.com/blogs/george_durzi/archive/2008/03/22/automating-office-communicator-2007-using-the-microsoft-office-communicator-2007-sdk.aspx">here</a>.</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jpddevelopment.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jpddevelopment.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jpddevelopment.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jpddevelopment.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jpddevelopment.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jpddevelopment.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jpddevelopment.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jpddevelopment.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jpddevelopment.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jpddevelopment.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jpddevelopment.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jpddevelopment.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jpddevelopment.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jpddevelopment.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=18&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jpddevelopment.wordpress.com/2009/04/11/ocs-2007-sdk-hello-world/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2296c833e6323e597fdbee6fc69c1ac3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpd6</media:title>
		</media:content>
	</item>
		<item>
		<title>Confusing Dialog Boxes</title>
		<link>http://jpddevelopment.wordpress.com/2009/04/10/confusing-dialog-boxes/</link>
		<comments>http://jpddevelopment.wordpress.com/2009/04/10/confusing-dialog-boxes/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 14:13:45 +0000</pubDate>
		<dc:creator>jpd6</dc:creator>
				<category><![CDATA[Dialog Box]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jpddevelopment.wordpress.com/2009/04/10/confusing-dialog-boxes/</guid>
		<description><![CDATA[Hmmm, what am I meant to do now….. For some strange reason the &#8216;Next&#8217; button wouldn&#8217;t appear until I forced a screen refresh. (I.e. Alt-Tab)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=16&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hmmm, what am I meant to do now…..</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1413-confusingdi1.png?w=720" alt="" /></p>
<p>For some strange reason the &#8216;Next&#8217; button wouldn&#8217;t appear until I forced a screen refresh. (I.e. Alt-Tab)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jpddevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jpddevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jpddevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jpddevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jpddevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jpddevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jpddevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jpddevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jpddevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jpddevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jpddevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jpddevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jpddevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jpddevelopment.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=16&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jpddevelopment.wordpress.com/2009/04/10/confusing-dialog-boxes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2296c833e6323e597fdbee6fc69c1ac3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpd6</media:title>
		</media:content>

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1413-confusingdi1.png" medium="image" />
	</item>
		<item>
		<title>Gmail S/MIME Encryption</title>
		<link>http://jpddevelopment.wordpress.com/2009/04/10/gmail-encryption/</link>
		<comments>http://jpddevelopment.wordpress.com/2009/04/10/gmail-encryption/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 10:52:13 +0000</pubDate>
		<dc:creator>jpd6</dc:creator>
				<category><![CDATA[Email]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[GMail]]></category>
		<category><![CDATA[S/MIME]]></category>

		<guid isPermaLink="false">http://jpddevelopment.wordpress.com/2009/04/10/gmail-encryption/</guid>
		<description><![CDATA[If like me, you use Gmail and send encrypted emails, you will notice at some point that the Gmail interface doesn&#8217;t provide support for S/MIME encryption. This doesn&#8217;t mean that you can&#8217;t send and receive encrypted emails using Gmail; you need to use a different tool to encrypt and read the emails. I won&#8217;t go [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=11&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If like me, you use Gmail and send encrypted emails, you will notice at some point that the Gmail interface doesn&#8217;t provide support for <a href="http://www.faqs.org/rfcs/rfc2633.html">S/MIME</a> encryption. This doesn&#8217;t mean that you can&#8217;t send and receive encrypted emails using Gmail; you need to use a different tool to encrypt and read the emails. I won&#8217;t go into detail how S/MIME works; there are lots of other websites that provide the <a href="http://en.wikipedia.org/wiki/S/MIME">details</a>.</p>
<p>In a very simplified nutshell, the key thing to remember is that S/MIME involves sending an &#8216;encrypted attachment&#8217; called &#8216;smime.p7m&#8217;. You can send this attachment over SMTP and receive it via POP3/IMAP4. When receiving the email, as long as your email client can recognize that there is an attachment &#8216;smime.p7m&#8217;, it will open and decrypt it automatically. (Assuming you have the right certificates installed!)</p>
<p>For instance, Microsoft Outlook has recognized that I have received an encrypted email via Gmail, shown below. I sent this encrypted email from one Gmail account via SMTP and received it in a different Gmail account via IMAP4.<span id="more-11"></span></p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp1.png?w=720" alt="" /></p>
<p>As I have the valid certificates installed, opening the email allows me to read it. (Notice the padlock in the screenshot showing it is encrypted)</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp2.png?w=720" alt="" /></p>
<p>Also works with Thunderbird!</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp3.png?w=720" alt="" /></p>
<p>Outlook Express!</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp4.png?w=720" alt="" /></p>
<p>And even Lotus Notes via IMAP!</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp5.png?w=720" alt="" /></p>
<p>Ah, how about in the Gmail web interface? Gmail knows there is an attachment, but doesn&#8217;t do anything with it.</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp6.png?w=720" alt="" /></p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp7.png?w=720" alt="" /></p>
<p>If you want to view it within the web interface, installing the <a href="https://addons.mozilla.org/en-US/firefox/addon/592">Gmail S/Mime Firefox plugin</a> for Firefox does the trick! This nifty plug-in will also allow you to create and send SMIME emails within the browser interface.</p>
<p><img src="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp8.png?w=720" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jpddevelopment.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jpddevelopment.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jpddevelopment.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jpddevelopment.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jpddevelopment.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jpddevelopment.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jpddevelopment.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jpddevelopment.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jpddevelopment.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jpddevelopment.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jpddevelopment.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jpddevelopment.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jpddevelopment.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jpddevelopment.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jpddevelopment.wordpress.com&amp;blog=7305615&amp;post=11&amp;subd=jpddevelopment&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jpddevelopment.wordpress.com/2009/04/10/gmail-encryption/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2296c833e6323e597fdbee6fc69c1ac3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpd6</media:title>
		</media:content>

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp1.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp2.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp3.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp4.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp5.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp6.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp7.png" medium="image" />

		<media:content url="http://jpddevelopment.files.wordpress.com/2009/04/041009-1051-gmailencryp8.png" medium="image" />
	</item>
	</channel>
</rss>
