<?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>Ghosted Notes &#187; Java</title>
	<atom:link href="http://ghostednotes.com/category/java/feed" rel="self" type="application/rss+xml" />
	<link>http://ghostednotes.com</link>
	<description>The writings of a technology ronin</description>
	<lastBuildDate>Thu, 05 Aug 2010 19:18:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Neo4j Graph Databases With ColdFusion</title>
		<link>http://ghostednotes.com/2010/04/29/using-neo4j-graph-databases-with-coldfusion</link>
		<comments>http://ghostednotes.com/2010/04/29/using-neo4j-graph-databases-with-coldfusion#comments</comments>
		<pubDate>Thu, 29 Apr 2010 21:56:31 +0000</pubDate>
		<dc:creator>Brian Panulla</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[neo4j]]></category>

		<guid isPermaLink="false">http://ghostednotes.com/?p=135</guid>
		<description><![CDATA[After last week,  I decided to put off picking a new frontend platform for my Semantic  Web rubric project and focus a bit on the server backend.
Since this is just a proof-of-concept project at this point I can afford to take some risks in  choosing technologies. I&#8217;ve been following the developments  [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="/2010/04/21/losing-my-religion" target="_blank">last week</a>,  I decided to put off picking a new frontend platform for my Semantic  Web rubric project and focus a bit on the server backend.</p>
<p>Since this is just a proof-of-concept project at this point I can afford to take some risks in  choosing technologies. I&#8217;ve been following the developments  around using <a href="http://en.wikipedia.org/wiki/Graph_database" target="_blank"><em>graph databases</em></a> for storing data, especially for Semantic Web applications. One project that kept coming up was <a href="http://neo4j.org/" target="_blank">Neo4j</a>, a graph database engine built in Java. I figured now was a good time to try it out. My server-side logic is built in <a href="http://en.wikipedia.org/wiki/ColdFusion" target="_blank">ColdFusion</a>, and integrating open source Java projects like Neo4j into CF applications is generally a snap.</p>
<p>Aside from one hiccup, porting Neo4j&#8217;s <a href="http://wiki.neo4j.org/content/Getting_Started_In_One_Minute_Guide" target="_blank">1-minute Java &#8220;Hello World&#8221; example</a> to CFML proved to be fairly straightforward. The process I used to get this working is detailed below. I&#8217;d suggest that you skim over the <a href="http://wiki.neo4j.org/content/Getting_Started_In_One_Minute_Guide" target="_blank">Java example</a> before continuing &#8211; I&#8217;m sure I left out some of the exposition.</p>
<p>First add the Neo4j Jar files to the ColdFusion server:</p>
<ul>
<li>Download the Neo4j &#8220;Apoc&#8221; distribution and unpack it somewhere convenient. I&#8217;m using Mac OS X, so I put things like this in <strong>~/lib/neo4j-apoc-1.0</strong></li>
<li>Add the Neo4j JAR files to the ColdFusion classpath. Log into your ColdFusion Administrator, and select <strong>Server Settings -&gt; Java and JVM</strong>. Enter the path to the <strong>lib</strong> folder in your Neo4j distribution in <strong>ColdFusion Class Path<br />
</strong></li>
<li>Restart your ColdFusion server. If you&#8217;re at all nervous, log back in to the ColdFusion Administrator and verify that the Neo4j jars are indeed listed on your classpath.</li>
</ul>
<p>Once this is complete, you can initialize a new database for your ColdFusion app. Decide where you want the CF server to create the Neo4j data files and pass that to the object&#8217;s init() method. I put mine in a folder under /tmp on Mac OS X.</p>
<pre>&lt;cfset dbroot = "/tmp/neo4jtest/" /&gt;

&lt;cfset graphDb = createObject('java',
                  "org.neo4j.kernel.EmbeddedGraphDatabase") /&gt;
&lt;cfset graphDb.init(dbroot &amp; "var/graphdb") /&gt;</pre>
<p><em>[Aside for non-ColdFusion folks: CF doesn't instantiate Java objects quite how you'd expect. The call to CreateObject() just gets a handle on the class itself. Calling init() on the resulting handle actually instantiates the class via the appropriate constructor.]</em></p>
<p>Just as in the Java example, it&#8217;s good to surround your connection with a try/catch block that will close your database connection if you throw an error. As I was working with Neo4j I would periodically lock up my database and not be able to connect without restarting CF. Adding a CFTRY/CFCATCH block cleared this right up.</p>
<pre>&lt;cftry&gt;
   &lt;cfset tx = graphDb.beginTx() /&gt;

   &lt;cfscript&gt;
     tx.success();
     WriteOutput("Success.");
   &lt;/cfscript&gt;

   &lt;cfset tx.finish() /&gt;

  &lt;cfcatch type="any"&gt;
     &lt;cfset graphDb.shutdown() /&gt;
     &lt;cfdump var="#cfcatch#"&gt;
   &lt;/cfcatch&gt;
&lt;/cftry&gt;

&lt;cfset graphDb.shutdown() /&gt;
</pre>
<p>Where things got really sticky was the use of Java enumerations to declare the available relationship types for the graph:</p>
<pre> /* Java code */
 public enum  MyRelationshipTypes implements RelationshipType
 {
    KNOWS
 }
</pre>
<p>To my knowledge there&#8217;s no way to declare something like this in standard CFML. I likely could have wrapped this in a Java class of some sort and loaded it through CreateObject(), but that wouldn&#8217;t have been true to the spirit of ColdFusion. So I dug around in the Neo4j docs and found an answer: relationships can be created dynamically at runtime from a static method on the class <strong>org.neo4j.graphdb.DynamicRelationshipType</strong>. I created an instance of DynamicRelationshipType for the &#8220;KNOWS&#8221; relationship and loaded it into a Struct, anticipating caching them in Application scope for a real application.</p>
<pre> relationship = CreateObject("java",
                             "org.neo4j.graphdb.DynamicRelationshipType");
 MyRelationshipTypes = structNew();
 MyRelationshipTypes.KNOWS = relationship.withName( "KNOWS" );
</pre>
<p>It might be interesting to see if these relationship enumerations could be generated and compiled by something like <a href="http://javaloader.riaforge.org/" target="_blank">JavaLoader</a>. I&#8217;m not yet aware of any downsides with dynamic relationships besides the obvious lack of compile-time checking.</p>
<p>The rest of the exercise follows without any real suprises:</p>
<pre> firstNode = graphDb.createNode();
 secondNode = graphDb.createNode();
 relationship = firstNode.createRelationshipTo( secondNode,
                                         MyRelationshipTypes.KNOWS );

 firstNode.setProperty( "message", "Hello, " );
 secondNode.setProperty( "message", "world!" );
 relationship.setProperty( "message", "brave Neo4j " );

 WriteOutput( firstNode.getProperty( "message" ) );
 WriteOutput( relationship.getProperty( "message" ) );
 WriteOutput( secondNode.getProperty( "message" ) );
</pre>
<p>And there you have it! A quick and dirty Neo4j application built with CFML.</p>
<p>I&#8217;ve put a little work into developing a Neo4j helper class that hides some of these warts in a nice clean CFC. As soon as I can get eGit to behave I&#8217;ll <a href="http://github.com/bpanulla/cf_neo4j" target="_blank">post the files on GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ghostednotes.com/2010/04/29/using-neo4j-graph-databases-with-coldfusion/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Speaking tonight on the Semantic Web</title>
		<link>http://ghostednotes.com/2010/02/16/Talking-about-the-Semantic-Web</link>
		<comments>http://ghostednotes.com/2010/02/16/Talking-about-the-Semantic-Web#comments</comments>
		<pubDate>Tue, 16 Feb 2010 21:02:00 +0000</pubDate>
		<dc:creator>Brian Panulla</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[The New Web]]></category>

		<guid isPermaLink="false">http://ghostednotes.com/2010/02/16/Talking-about-the-Semantic-Web</guid>
		<description><![CDATA[The Semantic Web has been a strong interest of mine over the last two years. When I came across RDF and OWL through a research project at IST back in 2008, a Web Standard no less, I&#8217;d somehow been completely oblivious to its existence.
If you&#8217;ve never heard of the Semantic Web, here&#8217;s a quick intro [...]]]></description>
			<content:encoded><![CDATA[<p>The Semantic Web has been a strong interest of mine over the last two years. When I came across RDF and OWL through a research project at <a href="http://ist.psu.edu" target="_blank">IST</a> back in 2008, a <a href="http://www.w3.org/2004/OWL/">Web Standard</a> no less, I&#8217;d somehow been completely oblivious to its existence.</p>
<p>If you&#8217;ve never heard of the Semantic Web, here&#8217;s a <a href="http://blog.digitalbazaar.com/2007/12/26/semantic-web-intro/" target="_blank">quick intro video</a>. I&#8217;ll wait here.</p>
<p>Everybody back? Okay! The concepts behind OWL seemed to solve a few thorny design issues I&#8217;d come across in a decade of building relational databases-backed Web 1.0 apps, and do so in a really elegant way. Working with OWL fuses aspects of relational database modeling, information architecture, and object oriented design into a new set of technologies and techniques.</p>
<p>As I started talking to members of the developer community at <a href="http://www.psu.edu" target="_blank">Penn State</a> about the Semantic Web, I got a lot of blank stares and misunderstandings (&#8220;Isn&#8217;t that just XML?&#8221;). And yet, every graduate student in IST was exposed to ontologies and semantic modelling as a routine part of the curriculum. The research community had been <a href="http://tomgruber.org/writing/onto-design.htm" target="_blank">working with ontologies for years</a>. Clearly there was a large academic-practitioner gap here to be bridged.</p>
<p>So as I&#8217;ve done many times in the past with a new technology or concept, I started talking about the Semantic Web at user group meetings and conferences, and looking for ways to apply these technologies in low-risk venues.</p>
<p>Tonight is the latest in this series of speaking engagements, and possibly the most challenging thus far. I&#8217;ll be presenting my talk &#8220;An Argument For Semantics&#8221; at the <a href="http://pjug.org/">Portland Java User Group</a>. I&#8217;ve been really impressed by the quality of home grown presenters at PJUG since I started attending. My talk will be very different &#8211; less code, more conceptual &#8211; than usual PJUG speakers, but I&#8217;m hoping the technical experience in the room can generate a good discussion on how and when it makes sense to employ Semantic Web technologies in real world applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://ghostednotes.com/2010/02/16/Talking-about-the-Semantic-Web/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heading to CodeMash &#8216;08</title>
		<link>http://ghostednotes.com/2008/01/06/Heading-to-CodeMash-08</link>
		<comments>http://ghostednotes.com/2008/01/06/Heading-to-CodeMash-08#comments</comments>
		<pubDate>Sun, 06 Jan 2008 16:01:00 +0000</pubDate>
		<dc:creator>Brian Panulla</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Information Sciences]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://ghostednotes.com/2008/01/06/Heading-to-CodeMash-08</guid>
		<description><![CDATA[I&#8217;m really looking forward to CodeMash. The slate of speakers and topics looks fantastic; It&#8217;s really nice to look at a conference schedule and see a lot of topics that are totally new to me.
One thing I&#8217;m curious about is Scala. I&#8217;ve been working with a research group lately on a project using Intelligent Agents, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really looking forward to <a href="http://www.codemash.org/">CodeMash</a>. The slate of speakers and topics looks fantastic; It&#8217;s really nice to look at a conference schedule and see a lot of topics that are totally new to me.</p>
<p>One thing I&#8217;m curious about is <a href="http://www.scala-lang.org/">Scala</a>. I&#8217;ve been working with a research group lately on a project using Intelligent Agents, and through that was introduced to the idea of <a href="http://en.wikipedia.org/wiki/Functional_programming">Functional Programming</a>. Somehow I missed seeing this in my undergraduate days, though I remember my peers complaining about Scheme in one of the senior-level computer science courses.</p>
<p>Some of the talks on <a href="http://groovy.codehaus.org/">Groovy</a> and <a href="http://grails.codehaus.org/">Grails</a> seem interesting, too. The Ruby on Rails movement has certainly sparked some innovation in the Web Development community, and I like seeing those ideas cross-ported into the technologies I have more of an affinity for, such as Java and ColdFusion. Having recently built a somewhat painful full-scale Java application, there may be something useful here.</p>
]]></content:encoded>
			<wfw:commentRss>http://ghostednotes.com/2008/01/06/Heading-to-CodeMash-08/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
