<?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>Technophile Blog</title>
	<atom:link href="http://gordondickens.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://gordondickens.com/wordpress</link>
	<description>Random geek topics on open source Java technologies</description>
	<lastBuildDate>Mon, 16 Apr 2012 17:35:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>What is in my Cloud Environment?</title>
		<link>http://gordondickens.com/wordpress/2012/04/16/what-is-in-my-cloud-environment/</link>
		<comments>http://gordondickens.com/wordpress/2012/04/16/what-is-in-my-cloud-environment/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 17:21:32 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[CloudBees]]></category>
		<category><![CDATA[Heroku]]></category>
		<category><![CDATA[Jelastic]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring Roo]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[Environment]]></category>
		<category><![CDATA[jelastic]]></category>
		<category><![CDATA[spring framework]]></category>
		<category><![CDATA[springframework]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1389</guid>
		<description><![CDATA[I put together Java sample applications using Spring 3.1. Using Spring&#8217;s Environment abstractions, we can gather details about the underlying platform. See the following sample pages Jelastic: http://petclinic.jelastic.servint.net/clinic/environment Heroku: http://evening-window-9861.herokuapp.com/environment CloudBees: http://roobees.gdickens.cloudbees.net/environment Environment Bean package com.gordondickens.roobees.util; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; &#8230; <a href="http://gordondickens.com/wordpress/2012/04/16/what-is-in-my-cloud-environment/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I put together Java sample applications using Spring 3.1.  Using Spring&#8217;s Environment abstractions, we can gather details about the underlying platform.</p>
<p>See the following sample pages</p>
<ul>
<li>Jelastic: <a href="http://petclinic.jelastic.servint.net/clinic/environment">http://petclinic.jelastic.servint.net/clinic/environment</a></li>
<li>Heroku: <a href="http://evening-window-9861.herokuapp.com/environment">http://evening-window-9861.herokuapp.com/environment</a></li>
<li>CloudBees: <a href="http://roobees.gdickens.cloudbees.net/environment">http://roobees.gdickens.cloudbees.net/environment</a></li>
</ul>
<h3>Environment Bean</h3>
<pre class="brush:java;">
package com.gordondickens.roobees.util;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.StandardEnvironment;

import javax.annotation.PostConstruct;
import java.util.*;

public class MyEnvironment {
  private static final Logger logger = LoggerFactory.getLogger(MyEnvironment.class);
  @Value("#{ systemProperties['user.language'] }")
  private String varOne;

  @Value("#{ systemProperties }")
  private Properties systemProperties;

  @Value("#{ systemEnvironment }")
  private Properties systemEnvironment;

  @Value("#{ environment }")
  private StandardEnvironment environment;

  @Override
  public String toString() {
    return "\n\n********************** MyEnvironment: ["
      + "\n\tsystemProperties=" + formatMe(systemProperties.toString())
      + ", \n\n\tsystemEnvironment=" + formatMe(systemEnvironment.toString())
      + ", \n\n\tenvironment=" + formatMe(environment.toString()) + "]";
  }

  private static String formatMe(final String in) {
    String out = in;
    out = in.replace("{", "{\n\t\t");
    out = out.replace(", ", "\n\t\t");
    return out;
  }

  @PostConstruct
  public void afterInstantiation() {
    logger.debug(this.toString());
  }

  public StandardEnvironment getEnvironment() {
    return environment;
  }

  public Properties getSystemEnvironment() {
    return systemEnvironment;
  }

  public Map&lt;String,String&gt; getSortedSystemEnvironment() {
    Properties p = systemEnvironment;
    Object[] keys = p.keySet().toArray();
    Arrays.sort(keys);
    Map&lt;String, String&gt; treeMap = new TreeMap&lt;String, String&gt;();
    treeMap.putAll((Map) p);
    return treeMap;
  }

  public Properties getSystemProperties() {
    return systemProperties;
  }

  public Map&lt;String,String&gt; getSortedSystemProperties() {
    Properties p = systemProperties;
    Object[] keys = p.keySet().toArray();
    Arrays.sort(keys);
    Map&lt;String, String&gt; treeMap = new TreeMap&lt;String, String&gt;();
    treeMap.putAll((Map) p);
    return treeMap;
  }

  public List&lt;String&gt; getServletConfigInitParams() {
    return getPropertyList("servletConfigInitParams");
  }

  public List&lt;String&gt; getServletContextInitParams() {
    return getPropertyList("servletContextInitParams");
  }

  public List&lt;String&gt; getJndiProperties() {
    return getPropertyList("jndiProperties");
  }

  private List&lt;String&gt; getPropertyList(String propSrcName) {
    if (environment.getPropertySources().contains(propSrcName)) {
      PropertySource ps = environment.getPropertySources().get(propSrcName);
      String results = ReflectionToStringBuilder.toString(ps, ToStringStyle.SHORT_PREFIX_STYLE);
      List&lt;String&gt; resultList = Arrays.asList(StringUtils.split(results, ','));
      Collections.sort(resultList);
      return resultList;
    } else
        return null;
  }
}
</pre>
<h3>Wire in the Bean</h3>
<p>If you want the environment information logged, then invoke the <code>afterInstantiation</code> method.  It is marked as <code>@PostConstruct</code>, so it will automatically invoke if you use <code>&lt;context:annotation-config/&gt;</code> or <code>&lt;context:component-scan ... /&gt;</code> as long as component-scan includes the package, or package parents of the class.</p>
<pre class="brush:xml">
&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;

...

  &lt;bean id="myEnvironment"
      class="com.gordondickens.roobees.util.MyEnvironment"
      init-method="afterInstantiation"/&gt;

...

&lt;/beans&gt;
</pre>
<h3>Source Code</h3>
<p><a href="https://github.com/gordonad/gordonad-roo-1.2-cloudbees">See my Roo CloudBees Demo Code &#8211; https://github.com/gordonad/gordonad-roo-1.2-cloudbees</a></p>
<h3>My Cloud Presentations</h3>
<ul>
<li><a href="http://prezi.com/9vhpoykemuag/java-ee-in-the-cloud/">Java EE in the Cloud</a></li>
<li><a href="http://prezi.com/3rb6jwnpldmz/java-enterprise-applications-in-the-cloud-fast-fun-easier-than-ever/">Rapid Java Enterprise Applications in the Cloud</a></li>
</ul>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2012/04/16/what-is-in-my-cloud-environment/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2012/04/16/what-is-in-my-cloud-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Spring Roo for Java 7</title>
		<link>http://gordondickens.com/wordpress/2012/04/05/configuring-spring-roo-for-java-7/</link>
		<comments>http://gordondickens.com/wordpress/2012/04/05/configuring-spring-roo-for-java-7/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 20:02:13 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[AOP]]></category>
		<category><![CDATA[AspectJ]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java 7]]></category>
		<category><![CDATA[JDK7]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Roo]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring AOP]]></category>
		<category><![CDATA[Spring Data]]></category>
		<category><![CDATA[Spring MVC]]></category>
		<category><![CDATA[java 7]]></category>
		<category><![CDATA[java7]]></category>
		<category><![CDATA[jdk7]]></category>
		<category><![CDATA[maven-aspectj-plugin]]></category>
		<category><![CDATA[Spring Roo]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1384</guid>
		<description><![CDATA[When creating a Roo project with the &#8220;project&#8221; command, we have the option to specify the Java Version $ roo roo> project --topLevelPackage com.gordondickens.myproj --java 6 --projectName testapp If we choose Java 7 with Roo 1.2.1, the code will not &#8230; <a href="http://gordondickens.com/wordpress/2012/04/05/configuring-spring-roo-for-java-7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When creating a Roo project with the &#8220;project&#8221; command, we have the option to specify the Java Version</p>
<pre class="brush:bash">
$ roo
roo> project --topLevelPackage com.gordondickens.myproj --java 6 --projectName testapp
</pre>
<p>If we choose Java 7 with Roo 1.2.1, the code will not compile with AspectJ included.</p>
<p>Steps to change to Java 7:</p>
<ul>
<li>Change the Java version to 1.7</li>
<li>Set the AspectJ version to 1.7.0.M1 or higher</li>
<li>Set the Maven AspectJ Plugin to 1.4 or higher</li>
<li>If using Hypersonic, change the version to 2.2.8 or higher</li>
<li>Change the Hibernate version to 4.1.2 or higher</li>
<li>(optional) Change the Hibernate Entity Manager to 4.1.2 or higher</li>
</ul>
<pre class="brush:xml">
&lt;properties&gt;
  &lt;aspectj.version&gt;1.7.0.M1&lt;/aspectj.version&gt;
  &lt;java.version&gt;1.7&lt;/java.version&gt;
  &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
  &lt;roo.version&gt;1.2.1.RELEASE&lt;/roo.version&gt;
  &lt;slf4j.version&gt;1.6.4&lt;/slf4j.version&gt;
  &lt;spring.version&gt;3.1.1.RELEASE&lt;/spring.version&gt;
&lt;/properties&gt;
...
&lt;dependency&gt;
  &lt;groupId&gt;org.hsqldb&lt;/groupId&gt;
  &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
  &lt;version&gt;2.2.8&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
  &lt;version&gt;4.1.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
  &lt;version&gt;4.1.2&lt;/version&gt;
  &lt;exclusions&gt;
    &lt;exclusion&gt;
      &lt;groupId&gt;cglib&lt;/groupId&gt;
      &lt;artifactId&gt;cglib&lt;/artifactId&gt;
    &lt;/exclusion&gt;
    &lt;exclusion&gt;
      &lt;groupId&gt;dom4j&lt;/groupId&gt;
      &lt;artifactId&gt;dom4j&lt;/artifactId&gt;
    &lt;/exclusion&gt;
  &lt;/exclusions&gt;
&lt;/dependency&gt;
...
&lt;plugin&gt;
  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
  &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
      &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
      &lt;version&gt;${aspectj.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
      &lt;artifactId&gt;aspectjtools&lt;/artifactId&gt;
      &lt;version&gt;${aspectj.version}&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;goals&gt;
        &lt;goal&gt;compile&lt;/goal&gt;
        &lt;goal&gt;test-compile&lt;/goal&gt;
      &lt;/goals&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
  &lt;configuration&gt;
    &lt;outxml&gt;true&lt;/outxml&gt;
    &lt;aspectLibraries&gt;
      &lt;aspectLibrary&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
      &lt;/aspectLibrary&gt;
    &lt;/aspectLibraries&gt;
    &lt;source&gt;${java.version}&lt;/source&gt;
    &lt;target&gt;${java.version}&lt;/target&gt;
  &lt;/configuration&gt;
&lt;/plugin&gt;
...
</pre>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2012/04/05/configuring-spring-roo-for-java-7/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2012/04/05/configuring-spring-roo-for-java-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Install Open Source Apps on Mac OSX</title>
		<link>http://gordondickens.com/wordpress/2012/02/16/quick-install-open-source-apps-on-mac-osx/</link>
		<comments>http://gordondickens.com/wordpress/2012/02/16/quick-install-open-source-apps-on-mac-osx/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 21:19:00 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[HomeBrew]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[lion]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1359</guid>
		<description><![CDATA[A quick way to install many of your Open Source applications &#38; tools on the Mac OSX is with HomeBrew. More and more, I am finding HomeBrew &#8220;recipes&#8221; for my commonly used applications, tools, etc. such as: Applications activemq gradle &#8230; <a href="http://gordondickens.com/wordpress/2012/02/16/quick-install-open-source-apps-on-mac-osx/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A quick way to install many of your Open Source applications &amp; tools on the Mac OSX is with <a href="http://mxcl.github.com/homebrew/">HomeBrew</a>.</p>
<p>More and more, I am finding HomeBrew &#8220;recipes&#8221; for my commonly used applications, tools, etc. such as:</p>
<h3>Applications</h3>
<ul>
<li>activemq</li>
<li>gradle</li>
<li>grails</li>
<li>groovy</li>
<li>rabbitmq</li>
<li>spring-roo</li>
</ul>
<h3>Tools</h3>
<ul>
<li>cmake</li>
<li>curl</li>
<li>git</li>
<li>gnupg</li>
<li>hub</li>
<li>libyaml</li>
<li>subversion</li>
<li>tree</li>
<li>wget</li>
</ul>
<h3>Languages</h3>
<ul>
<li>clojure</li>
<li>erlang</li>
<li>scala</li>
</ul>
<h3>Databases</h3>
<ul>
<li>mongodb</li>
<li>mysql</li>
<li>postgresql</li>
<li>redis</li>
</ul>
<hr/>
<h2>Installation</h2>
<p><a href="https://github.com/mxcl/homebrew/wiki/Installation">HomeBrew Installation Instructions</a>.</p>
<h3>Finding a Recipe (application)</h3>
<p>$ <code>brew search subversion</code></p>
<h3>Installing a Recipe</h3>
<p>$ <code>brew install spring-roo</code></p>
<h3>Updating a Recipe</h3>
<p>$ <code>brew upgrade spring-roo</code></p>
<h3>Trouble?</h3>
<p>$ <code>brew doctor</code></p>
<p><a href="https://github.com/mxcl/homebrew/wiki/The-brew-command">More Brew Commands</a></p>
<hr/>
<h2>Setting Up the Environment</h2>
<p>Paths to the executables are setup, to configure the home directories many of the projects are configured using the &#8220;libexec&#8221; subdir.</p>
<pre class="brush:bash">
export ACTIVEMQ_HOME=/usr/local/Cellar/activemq/5.5.1/libexec
export ACTIVEMQ_BASE=$ACTIVEMQ_HOME
export GRADLE_HOME=/usr/local/Cellar/gradle/1.0-milestone-8/libexec
export GRAILS_HOME=/usr/local/Cellar/grails/2.0.1/libexec
export GROOVY_HOME=/usr/local/Cellar/groovy/1.8.5/libexec
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
export M2_HOME=/usr/local/Cellar/maven/3.0.4/libexec
export M2_REPO=~/.m2
export MAVEN_HOME=$M2_HOME
export MYSQL_HOME=/usr/local/Cellar/mysql/5.5.19
export PGSQL_HOME=/usr/local/Cellar/postgresql/9.1.2
export RABBITMQ_HOME=/usr/local/Cellar/rabbitmq/2.7.1
export ROO_HOME=/usr/local/Cellar/spring-roo/1.2.1
export SVN_HOME=/usr/local/Cellar/subversion/1.7.3/libexec

#################################
# ###  HOMEBREW Essentials  ### #
#################################
export HOMEBREW_LIBRARY_PATH=$HOMEBREW_LIBRARY_PATH:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/local/lib/python:$PYTHONPATH
export LDFLAGS=-L/usr/local/Cellar/readline/6.2.2/lib
export CPPFLAGS=-I/usr/local/Cellar/readline/6.2.2/include
export TMPDIR=~/tmp
</pre>
<h3>IntelliJ IDEA Users</h3>
<p>Set the home variables (as above) in the <code>~/.MacOSX/environment.plist</code> file.  This file can be edited with Xcode or other plist editors.</p>
<h3>Essential Recipes</h3>
<p>$ <code>brew install wget cmake libyaml --universal</code></p>
<h3>Python Goodies</h3>
<p>See the environment variables above, but first install the python <code>pip</code> package manager, mercurial &amp; pyyaml.<br />
$ <code>sudo easy_install pip</code><br />
$ <code>sudo pip install mercurial pyyaml</code></p>
<h3>The Path</h3>
<p>Ensure the gcc and bin directories are in your path.<br />
<code>export PATH=/Developer/usr/llvm-gcc-4.2:/Developer/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/X11/bin:.:$PATH</code></p>
<hr/>
<h2>Survival Tips</h2>
<h3>Brew DOs</h3>
<ul>
<li>When updating use <code>brew upgrade</code></li>
<li><a href="https://developer.apple.com/xcode/">Install XCode</a></li>
<li>Do NOT use <code>macports</code></li>
<li>After installing each Recipe, check by running the app command with <code>--version</code>, i.e. <code>roo --version</code></li>
</ul>
<h3>Brew DON&#8217;Ts</h3>
<ul>
<li>Do NOT use <code>brew update</code> &#8211; does not always work, use brew upgrade</li>
<li>Do NOT use sudo</li>
<li>Do NOT use <a href="http://www.macports.org/">macports</a></li>
</ul>
<h2>Want More?</h2>
<ul>
<li><a href="https://github.com/mxcl/homebrew/wiki/External-Commands">HomeBrew External Commands</a></li>
</ul>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2012/02/16/quick-install-open-source-apps-on-mac-osx/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2012/02/16/quick-install-open-source-apps-on-mac-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing and Configuring RabbitMQ</title>
		<link>http://gordondickens.com/wordpress/2012/01/31/installing-and-configuring-rabbitmq/</link>
		<comments>http://gordondickens.com/wordpress/2012/01/31/installing-and-configuring-rabbitmq/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 15:51:08 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[AMQP]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[HomeBrew]]></category>
		<category><![CDATA[RabbitMQ]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1250</guid>
		<description><![CDATA[RabbitMQ and AMQP (Advanced Message Queuing Protocol) are gaining momentum in the market. One of the main reasons for that momentum is because, in enterprise development, the client is not always Java specific. With RabbitMQ, we can configure a scalable, &#8230; <a href="http://gordondickens.com/wordpress/2012/01/31/installing-and-configuring-rabbitmq/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://gordondickens.com/wordpress/wp-content/uploads/2012/01/rabbitmq_logo_strap.png"><img src="http://gordondickens.com/wordpress/wp-content/uploads/2012/01/rabbitmq_logo_strap.png" alt="rabbitmq logo" title="RabbitMQ" width="361" height="76" class="alignleft size-full wp-image-1340" /></a><br/></p>
<p>RabbitMQ and AMQP (Advanced Message Queuing Protocol) are gaining momentum in the market.  One of the main reasons for that momentum is because, in enterprise development, the client is not always Java specific.  With RabbitMQ, we can configure a scalable, fault-tolerant, open-source messaging solution for polyglot clients, <a href="http://www.rabbitmq.com/devtools.html" target="_blank">click here to see a list of client language support.</a></p>
<p>Follow the steps below to install and configure <a href="http://www.rabbitmq.com" target="_blank">RabbitMQ v1.7.x</a> on a MAC with OSX Lion. <a href="http://www.rabbitmq.com/configure.html" target="_blank">Click here for installation instructions for Windows and other platforms</a>.</p>
<p><br/></p>
<h3>1.  Installing RabbitMQ</h3>
<p>Mac OSX Lion Installation</p>
<p><a href="http://mxcl.github.com/homebrew/" target="_blank">Install HomeBrew</a></p>
<p style="font-weight:bold">From the terminal prompt:</p>
<pre class="brush:text">
$ brew install rabbitmq
</pre>
<p>We do NOT need to install Erlang, however, if desired use Brew as follows:</p>
<pre class="brush:text">
$ brew install erlang
</pre>
<p>HomeBrew RabbitMQ Directories</p>
<ul>
<li>Logs: <code>/usr/local/var/log/rabbitmq</code></li>
<li>Config: <code>/usr/local/etc/rabbitmq</code></li>
<li>Mnesia Database: /<code>usr/local/var/lib/rabbitmq/mnesia</code></li>
<li>Erlang cookie: <code>&lt;homedir&gt;/.erlang.cookie</code></li>
</ul>
<p>Mnesia is a NoSql database that stores RabbitMQ configuration data &#8211; <a href="http://www.erlang.org/doc/apps/mnesia/" target="_blank">Mnesia Reference Manual</a>.  </p>
<p><br/></p>
<h3>2. Configuring RabbitMQ Server</h3>
<p>When RabbitMQ is installed, not all of the configuration files exist.
<p style="font-style:italic">Do not be concerned if the install does not contain the files mentioned, simply create the text files and use the contents provided below as a base.</p>
<p>In the <code>rabbitmq-env.conf</code> file, any variables referenced can be set using an environment variable with the prefix <code>RABBITMQ_</code>, for example <code>NODE_PORT=5672</code> can be set as an environment variable <code>export RABBITMQ_NODE_PORT=5672</code></p>
<p>N.B. the system name in the examples is &#8220;Technophiliac&#8221;. In configuring your system, simply change all references from &#8220;Technophiliac&#8221; to your system name.</p>
<h4>RabbitMQ Environment Configuration File</h4>
<p style="font-weight:bold">Create or edit <code>/usr/local/etc/rabbitmq/rabbitmq-env.conf</code></p>
<div  style="font-size:smaller;">
<pre class="brush:bash">
# ##############################
# RABBITMQ SERVER CONFIGURATION
#
# All of the parameters below can also
#   be set as environment variables
#   using the prefix "RABBIT_"
#   i.e.  export RABBITMQ_NODE_PORT=5672
## ##############################

# ##########################
# Defaults to the empty string
#   meaning bind to all network interfaces
# Change to bind to one network interface only
# ##########################
# NODE_IP_ADDRESS=
# NODE_PORT=5672

# ##########################
# Unix, Linux: `env hostname`
# MacOSX: `env hostname -s`
# The name of the current machine
# ##########################
# HOSTNAME=

# ##########################
# The name of the current machine
# ##########################
# COMPUTERNAME=

# ##########################
# This base directory contains sub-directories for
#   server's db and log files
# Alternatively, set MNESIA_BASE and LOG_BASE individually
# ##########################
# BASE=

# ##########################
# Mac/Unix: rabbit@$HOSTNAME
# The node name should be unique per erlang-node-and-machine combination
# To run multiple nodes, see the clustering guide
# ##########################
# NODENAME=

# ##########################
# Mac: /usr/local/etc/rabbitmq/rabbitmq
# If the configuration file is present it is used by the server
# The .config extension is automatically appended
# This file is also used to auto-configure RabbitMQ clusters
# Example:
#   Config file location and new filename bunnies.config
#   CONFIG_FILE=/usr/local/etc/rabbitmq/bunnies
# ##########################
CONFIG_FILE=/usr/local/etc/rabbitmq/rabbitmq

# ##########################
# Mac: /usr/local/var/lib/rabbitmq/mnesia
# The Mnesia database files directory
#
# MNESIA_DIR will be assembled as MNESIA_BASE/NODENAME
# ##########################
# MNESIA_BASE=
# MNESIA_DIR=

# ##########################
# Mac: /usr/local/var/log/rabbitmq
# Log files generated by the server will be placed in this directory.
# ##########################
# LOG_BASE=/usr/local/var/log/rabbitmq

# ##########################
# The plugins directory
# ##########################
PLUGINS_DIR=/usr/local/Cellar/rabbitmq/2.7.1/lib/rabbitmq/erlang/lib/rabbitmq-2.7.1/plugins

# ##########################
# Mac: /usr/local/etc/rabbitmq/enabled_plugins
# This file declares explicitly enabled plugins
# ##########################
ENABLED_PLUGINS_FILE=/usr/local/etc/rabbitmq/enabled_plugins
</pre>
</div>
<h4>RabbitMQ Server Configuration File</h4>
<p style="font-weight:bold">Create or edit the file <code>/usr/local/etc/rabbitmq/rabbitmq.config</code></p>
<div  style="font-size:smaller;">
<pre class="brush:text">
[{auth_backends,[rabbit_auth_backend_internal]},
 {auth_mechanisms,['PLAIN','AMQPLAIN']},
 {backing_queue_module,rabbit_variable_queue},
 {cluster_nodes,[]},
 {collect_statistics,fine},
 {collect_statistics_interval,5000},
 {default_permissions,[&lt;&lt;".*"&gt;&gt;,&lt;&lt;".*"&gt;&gt;,&lt;&lt;".*"&gt;&gt;]},
 {default_user,&lt;&lt;"guest"&gt;&gt;},
 {default_user_tags,[administrator]},
 {default_vhost,&lt;&lt;"/"&gt;&gt;},
 {delegate_count,16},
 {error_logger,{file,"/usr/local/var/log/rabbitmq/rabbit@Technophiliac.log"}},
 {frame_max,131072},
 {hipe_compile,false},
 {included_applications,[]},
 {msg_store_file_size_limit,16777216},
 {msg_store_index_module,rabbit_msg_store_ets_index},
 {queue_index_max_journal_entries,262144},
 {sasl_error_logger,{file,"/usr/local/var/log/rabbitmq/rabbit@Technophiliac-sasl.log"}},
 {server_properties,[]},
 {ssl_listeners,[]},
 {ssl_options,[]},
 {tcp_listen_options,
   [binary,
     {packet,raw},
     {reuseaddr,true},
     {backlog,128},
     {nodelay,true},
     {exit_on_close,false}]},
 {tcp_listeners,[5672]},
 {trace_vhosts,[&lt;&lt;"/"&gt;&gt;]},
 {vm_memory_high_watermark,0.4}]
</pre>
</div>
<p><br/></p>
<h3>3. Configuring RabbitMQ Console Plugins</h3>
<h4>RabbitMQ Console Plugins File</h4>
<p style="font-weight:bold">Create or edit the text file <code>/usr/local/etc/rabbitmq/enabled_plugins</code></p>
<p>Include the following content (don&#8217;t forget the period at the end)</p>
<pre class="brush:text" style="font-size:smaller;">
[rabbitmq_jsonrpc_channel,
 rabbitmq_jsonrpc_channel_examples,
 rabbitmq_management,
 rabbitmq_management_visualiser,
 rabbitmq_tracing].
</pre>
<p><br/></p>
<h3>4. Set Environment Variables</h3>
<div style="font-size:smaller;">
<pre class="brush:bash">
export RABBITMQ_HOME=/usr/local/Cellar/rabbitmq/2.7.1
export HOMEBREW_LIBRARY_PATH=$HOMEBREW_LIBRARY_PATH:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/local/lib/python:$PYTHONPATH
export LDFLAGS=-L/usr/local/Cellar/readline/6.2.2/lib
export CPPFLAGS=-I/usr/local/Cellar/readline/6.2.2/include
</pre>
</div</p>
<p><br/></p>
<h3>5. Starting RabbitMQ</h3>
<pre class="brush:text">
$ sudo rabbitmq-server
</pre>
<p>We will see the following console output:</p>
<div style="font-size:smaller;">
<pre class="brush:text;gutter:false;toolbar:false">
Activating RabbitMQ plugins ...
12 plugins activated:
* amqp_client-0.0.0
* mochiweb-1.3-rmq0.0.0-git
* rabbitmq_jsonrpc-0.0.0
* rabbitmq_jsonrpc_channel-0.0.0
* rabbitmq_jsonrpc_channel_examples-0.0.0
* rabbitmq_management-0.0.0
* rabbitmq_management_agent-0.0.0
* rabbitmq_management_visualiser-0.0.0
* rabbitmq_mochiweb-0.0.0
* rabbitmq_tracing-0.0.0
* rfc4627_jsonrpc-0.0.0-git
* webmachine-1.7.0-rmq0.0.0-hg

+---+   +---+
|   |   |   |
|   |   |   |
|   |   |   |
|   +---+   +-------+
|                   |
| RabbitMQ  +---+   |
|           |   |   |
|   v2.7.1  +---+   |
|                   |
+-------------------+
AMQP 0-9-1 / 0-9 / 0-8
Copyright (C) 2007-2011 VMware, Inc.
Licensed under the MPL.  See http://www.rabbitmq.com/

node           : rabbit@Technophiliac
app descriptor : /usr/local/Cellar/rabbitmq/2.7.1/lib/rabbitmq/erlang/lib/rabbitmq-2.7.1/ebin/rabbit.app
home dir       : /Users/gordondickens
config file(s) : /usr/local/etc/rabbitmq/rabbitmq.config
cookie hash    : VBuPLzEtAR8Sdq9eR1g36w==
log            : /usr/local/var/log/rabbitmq/rabbit@Technophiliac.log
sasl log       : /usr/local/var/log/rabbitmq/rabbit@Technophiliac-sasl.log
database dir   : /usr/local/var/lib/rabbitmq/mnesia/rabbit@Technophiliac
erlang version : 5.8.5

-- rabbit boot start
starting file handle cache server                                     ...done
starting worker pool                                                  ...done
starting database                                                     ...done
starting codec correctness check                                      ...done
-- external infrastructure ready
starting plugin registry                                              ...done
starting auth mechanism cr-demo                                       ...done
starting auth mechanism amqplain                                      ...done
starting auth mechanism plain                                         ...done
starting statistics event manager                                     ...done
starting logging server                                               ...done
starting exchange type direct                                         ...done
starting exchange type fanout                                         ...done
starting exchange type headers                                        ...done
starting exchange type topic                                          ...done
-- kernel ready
starting alarm handler                                                ...done
starting node monitor                                                 ...done
starting cluster delegate                                             ...done
starting guid generator                                               ...done
starting memory monitor                                               ...done
-- core initialized
starting empty DB check                                               ...done
starting management agent                                             ...done
starting exchange, queue and binding recovery                         ...done
starting mirror queue slave sup                                       ...done
starting adding mirrors to queues                                     ...done
-- message delivery logic ready
starting error log relay                                              ...done
starting networking                                                   ...done
starting direct_client                                                ...done
starting notify cluster nodes                                         ...done

broker running
** Found 0 name clashes in code paths
</pre>
</div>
<p><!-- ************************************** --><br />
<!-- ************************************** --></p>
<p style="font-weight:bold">The Console</p>
<p>After RabbitMQ starts, go to the console <a href="http://localhost:55672/" target="_blank">http://localhost:55672/</a><br />
NOTE: The default user id/password is guest/guest.</p>
<p><br/></p>
<h3>Summary</h3>
<p>In this blog we saw the steps to install and configure RabbitMQ to run locally on Mac OSX Lion. In the next blog, I&#8217;ll introduce the concepts of AMQP exchanges, routes and queues, using Groovy Scripts to create and test them.  We will also discover how to visualize those components and their relationships within the console.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2012/01/31/installing-and-configuring-rabbitmq/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2012/01/31/installing-and-configuring-rabbitmq/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unit Testing Spring with Mockito &amp; PowerMock</title>
		<link>http://gordondickens.com/wordpress/2011/10/22/unit-testing-spring-with-mockito-powermock/</link>
		<comments>http://gordondickens.com/wordpress/2011/10/22/unit-testing-spring-with-mockito-powermock/#comments</comments>
		<pubDate>Sat, 22 Oct 2011 17:45:05 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[LogBack]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mocking]]></category>
		<category><![CDATA[Mockito]]></category>
		<category><![CDATA[PowerMock]]></category>
		<category><![CDATA[SLF4J]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[Spring MVC]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[powermock]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[springframework]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1230</guid>
		<description><![CDATA[Unit Testing Spring with Mockito &#038; PowerMock I&#8217;ve updated my Spring Mockito Demo app that I demonstrate when teaching with a PowerMock of a final class with a static method. Demo Features Maven 3.0 Maven Enforcer plugin restricting use of &#8230; <a href="http://gordondickens.com/wordpress/2011/10/22/unit-testing-spring-with-mockito-powermock/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Unit Testing Spring with Mockito &#038; PowerMock</h3>
<p>I&#8217;ve updated my Spring Mockito Demo app that I demonstrate when teaching with a PowerMock of a final class with a static method.</p>
<p><br/><br />
<h4>Demo Features</h4>
<ul>
<li><a href="http://maven.apache.org/">Maven 3.0</a></li>
<li><a href="http://maven.apache.org/plugins/maven-enforcer-plugin/">Maven Enforcer plugin</a> restricting use of commons-logging, log4j, slf4j > 1.5, maven version range &#038; java 1.6</li>
<li>All Maven plugin and java dependency versions are current and managed in properties of pom.xml</li>
<li><a href="http://mojo.codehaus.org/versions-maven-plugin/">Maven Versions plugin</a> for evaluating current configuration for any version updates of dependencies
<ul>
<li><code>mvn versions:display-dependency-updates</code> scans dependencies and reports dependencies with newer versions</li>
<li><code>mvn versions:display-plugin-updates</code> scans plugins and reports plugins with newer versions</li>
<li>To get the version changes w/o the ones that haven&#8217;t changed : <code>mvn versions:display-dependency-updates | grep " -> "</code></li>
</ul>
</li>
<li><a href="http://logback.qos.ch/">Logback</a> configuration with <a href="http://www.slf4j.org/">SLF4J</a></li>
<li><a href="http://code.google.com/p/mockito/">Mockito</a> tests of the controller layer (services are mocked)</li>
<li><a href="http://code.google.com/p/powermock/">PowerMock</a> configuration testing a final class with static method</li>
<li>All tests are true Unit tests, no use of Spring Context in tests, including the context creates integration tests</li>
</ul>
<h4>Code Repository</h4>
<p><a href="https://github.com/gordonad/core-spring-demos/tree/master/demos/mockitodemo">https://github.com/gordonad/core-spring-demos/tree/master/demos/mockitodemo</a></p>
<p><br/><br />
<hr/>
<h3>Want to Learn More?</h3>
<p>Learn more about Spring by attending a <a href="http://chariotsolutions.com/education">Spring Training</a> class at Chariot, or contact us for onsite training.</p>
<p><br/> </p>
<div style="text-align: center;font-size:200%;background-color:#C0C0C0;border-style:solid;border-color:SteelBlue;border-radius: 40px; -moz-border-radius: 40px; -webkit-border-radius: 40px;"><a href="http://chariotsolutions.com/education">Chariot Education Calendar</a></div>
<p><br/></p>
<h3  style="text-align: center;color:SteelBlue;font-size:125%"><a href="http://twitter.com/#!/chariotsolution"><img src="http://gordondickens.com/wordpress/wp-content/uploads/2011/04/twitter-simple-t.png" alt="" title="twitter-simple-t" width="32" height="32" class="aligncenter size-full wp-image-818" /></a>Follow <a href="http://twitter.com/#!/chariotsolution">Chariot Education on Twitter</a></h3>
<h3  style="text-align: center;color:SteelBlue;font-size:125%">for Special Training offers</h3>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2011/10/22/unit-testing-spring-with-mockito-powermock/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2011/10/22/unit-testing-spring-with-mockito-powermock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buzzing the Cloud with CloudBees and Roo</title>
		<link>http://gordondickens.com/wordpress/2011/09/26/buzzing-the-cloud-with-cloudbees-and-roo/</link>
		<comments>http://gordondickens.com/wordpress/2011/09/26/buzzing-the-cloud-with-cloudbees-and-roo/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 21:57:14 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[CloudBees]]></category>
		<category><![CDATA[Roo]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring Roo]]></category>
		<category><![CDATA[roo]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1220</guid>
		<description><![CDATA[Looking to try out CloudBees for your Spring application? Here is how you can get started quickly with CloudBees Run@Cloud platform. 05-Mar-12 &#8211; Updated for Spring Roo 1.2.1 Get a CloudBees Account Configure a MySql instance on CloudBees Build a &#8230; <a href="http://gordondickens.com/wordpress/2011/09/26/buzzing-the-cloud-with-cloudbees-and-roo/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Looking to try out CloudBees for your Spring application?</h3>
<p>Here is how you can get started quickly with CloudBees Run@Cloud platform.</p>
<p>05-Mar-12 &#8211; Updated for Spring Roo 1.2.1</p>
<ol>
<li><a href="http://www.cloudbees.com/platform-overview.cb" title="CloudBees Cloud Signup">Get a CloudBees Account</a></li>
<li><a href="https://run.cloudbees.com">Configure a MySql instance on CloudBees</a></li>
<li>Build a Spring Roo application<br/>see script below</li>
<li>Create a <code>cloudbees-web.xml</code> file in <code>WEB-INF</code><br/>same directory as <code>web.xml</code></li>
<li>Add Maven CloudBees Plugin</li>
<li>Build and deploy with Maven<br/>mvn clean install bees:deploy</li>
</ol>
<p><br/></p>
<h4>Roo 1.2.1 Script</h4>
<p>Here is a simple item manager application script you can use/customize to create your application.</p>
<ul>
<li>NOTE: Provide MySQL credentials in the &#8220;<code>jpa setup</code>&#8221; line.
<li></ul>
<pre class="brush:text">
# FOR SPRING ROO 1.2.1 - Spring Data JPA and Service Layer

development mode --enabled true

project --topLevelPackage com.gordondickens.roobees --java 6 --projectName roobees

jpa setup --provider HIBERNATE --database MYSQL --userName yourmysqluserid --databaseName yourmysqlinstancename --password yourmysqlpasswd

entity jpa --class ~.domain.Item --activeRecord false

field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item
field string --fieldName description --sizeMax 255 --class ~.domain.Item

repository jpa --interface ~.repository.ItemRepository --entity ~.domain.Item

service --interface ~.service.ItemService --entity ~.domain.Item

web mvc setup
web mvc all --package ~.web

logging setup --level DEBUG
</pre>
<p><br/></p>
<h4>Roo 1.1.5 Script</h4>
<p>Here is a simple item manager application script you can use/customize to create your application</p>
<pre class="brush:text">
# FOR SPRING ROO 1.1.5

development mode --enabled true

project --topLevelPackage com.gordondickens.roobees --java 6 --projectName roobees

persistence setup --provider HIBERNATE --database MYSQL --userName yourmysqluserid --databaseName yourmysqlinstancename --password yourmysqlpasswd

entity --class ~.domain.Item

field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item
field string --fieldName description --sizeMax 255 --class ~.domain.Item

web mvc setup
web mvc all --package ~.web

logging setup --level DEBUG
</pre>
<p><br/></p>
<h4>cloudbees-web.xml</h4>
<pre class="brush:xml">
&lt;?xml version="1.0"?&gt;
&lt;cloudbees-web-app xmlns="http://www.cloudbees.com/xml/webapp/1"&gt;
  &lt;appid&gt;roobees&lt;/appid&gt;
  &lt;context-param&gt;
    &lt;param-name&gt;application.environment&lt;/param-name&gt;
    &lt;param-value&gt;prod&lt;/param-value&gt;
  &lt;/context-param&gt;
&lt;/cloudbees-web-app&gt;
</pre>
<p><br/></p>
<h4>Maven CloudBees Plugin</h4>
<p>Add the CloudBees repository to the <code>pluginRepositories</code> section.</p>
<pre class="brush:xml">
&lt;pluginRepositories&gt;
  ...
  &lt;pluginRepository&gt;
    &lt;id&gt;bees-plugins-snapshots&lt;/id&gt;
    &lt;url&gt;http://repository-cloudbees.forge.cloudbees.com/public-snapshot/&lt;/url&gt;
    &lt;releases&gt;
      &lt;enabled&gt;false&lt;/enabled&gt;
    &lt;/releases&gt;
    &lt;snapshots&gt;
      &lt;enabled&gt;true&lt;/enabled&gt;
    &lt;/snapshots&gt;
  &lt;/pluginRepository&gt;
  ...
&lt;/pluginRepositories&gt;
</pre>
<p>Add the CloudBees Maven plugin to the <code>plugins</code> section.</p>
<pre class="brush:xml">
&lt;plugins&gt;
  ...
  &lt;plugin&gt;
    &lt;groupId&gt;com.cloudbees&lt;/groupId&gt;
    &lt;artifactId&gt;bees-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;configuration&gt;
       &lt;!-- your username/appname --&gt;
      &lt;appid&gt;youruserid/roobees&lt;/appid&gt;
      &lt;!-- your api key --&gt;
      &lt;apikey&gt;BEBEBE2CEBEBEFBE&lt;/apikey&gt;
      &lt;!-- your secret key --&gt;
      &lt;secret&gt;GEE0GERE0E-JE0EQETEHEPET+33MEIEIEI0EEZEEIEE00+&lt;/secret&gt;
      &lt;message&gt;Roo ItemManager on CloudBees by Gordon Dickens&lt;/message&gt;
    &lt;/configuration&gt;
  &lt;/plugin&gt;
  ...
&lt;/plugins&gt;
</pre>
<p><br/></p>
<h4>Database Properties File</h4>
<p>Edit the /src/main/resources/META-INF/spring/database.properties file.<br />
Set the <code>database.url</code> to <code>jdbc:cloudbees://<em>yourmysqlinstance</em></code>.<br />
Set the <code>database.driverClassName</code> to <code>com.cloudbees.jdbc.Driver</code>.</p>
<pre class="brush:text">
database.username=yourmysqluserid
database.password=yourmysqlpasswd

database.url=jdbc:cloudbees://yourmysqlinstancename
database.driverClassName=com.cloudbees.jdbc.Driver
</pre>
<h4>Download the Demo App</h4>
<p>The demo app is in Git <a href="https://github.com/gordonad/gordonad-roo-1.2-cloudbees">https://github.com/gordonad/gordonad-roo-1.2-cloudbees</a> for Spring Roo 1.2.</p>
<p><br/></p>
<hr/>
<table style="margin-left:auto;margin-right:auto;">
<tr>
<td style="vertical-align:center;font-family:Arial,sans-serif;font-weight:bold;"><a href="http://manning.com/rimple">Get Your Copy&nbsp;&#45;&#45;&gt;<br/>Get it NOW!&nbsp;&#45;&#45;&gt;</a></td>
<td><a href="http://manning.com/rimple"><img src="http://manning.com/rimple/rimple_cover150.jpg" alt="Spring Roo in Action Image" /></a></td>
<td style="vertical-align:center;font-family:Arial,sans-serif;font-weight:bold;"><a href="http://manning.com/rimple">&lt;&#45;&#45;&nbsp;All the cool kids have one<br/>&lt;&#45;&#45;&nbsp;You gotta have it!</a></td>
</tr>
</table>
<p><br/><br />
<hr/>
<h3>Want to Learn More?</h3>
<p>Learn more about Spring by attending a <a href="http://chariotsolutions.com/education">Spring Training</a> class at Chariot, or contact us for onsite training.</p>
<p><br/> </p>
<div style="text-align: center;font-size:200%;background-color:#C0C0C0;border-style:solid;border-color:SteelBlue;border-radius: 40px; -moz-border-radius: 40px; -webkit-border-radius: 40px;"><a href="http://chariotsolutions.com/education">Chariot Education Calendar</a></div>
<p><br/></p>
<h3  style="text-align: center;color:SteelBlue;font-size:125%"><a href="http://twitter.com/#!/chariotsolution"><img src="http://gordondickens.com/wordpress/wp-content/uploads/2011/04/twitter-simple-t.png" alt="" title="twitter-simple-t" width="32" height="32" class="aligncenter size-full wp-image-818" /></a>Follow <a href="http://twitter.com/#!/chariotsolution">Chariot Education on Twitter</a></h3>
<h3  style="text-align: center;color:SteelBlue;font-size:125%">for Special Training offers</h3>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2011/09/26/buzzing-the-cloud-with-cloudbees-and-roo/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2011/09/26/buzzing-the-cloud-with-cloudbees-and-roo/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Rocket to the Cloud Fast with Roo</title>
		<link>http://gordondickens.com/wordpress/2011/09/23/rocket-to-the-cloud-fast-with-roo/</link>
		<comments>http://gordondickens.com/wordpress/2011/09/23/rocket-to-the-cloud-fast-with-roo/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 16:39:07 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[CloudFoundry]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Roo]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring Data]]></category>
		<category><![CDATA[Spring Roo]]></category>
		<category><![CDATA[Cloud Foundry]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[roo]]></category>
		<category><![CDATA[Spring Data JPA]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1172</guid>
		<description><![CDATA[Want to build a Spring 3 application FAST and run it on the Cloud? It is incredibly easy to do with Spring Roo and CloudFoundry! This post on using Postgres on CloudFoundry helped me get started, however I tried using &#8230; <a href="http://gordondickens.com/wordpress/2011/09/23/rocket-to-the-cloud-fast-with-roo/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h4>Want to build a Spring 3 application FAST and run it on the Cloud?</h4>
<p>It is incredibly easy to do with <a href="http://www.springsource.org/roo">Spring Roo</a> and <a href="http://cloudfoundry.com/">CloudFoundry</a>!</p>
<p><a href="http://blog.springsource.com/2011/08/30/using-postgres-on-cloud-foundry/">This post on using Postgres on CloudFoundry</a> helped me get started, however I tried using the 1.2.M1 with the <a href="http://cloudfoundry.com/">CloudFoundry</a> addon, but was unable to install it successfully in either 1.1.5.RELEASE or 1.2.0.M1.</p>
<p>Recently, <a href="http://www.springsource.org/roo">Spring Roo</a> <a href="https://github.com/SpringSource/spring-roo">moved to GitHub</a></p>
<p><br/></p>
<h4>Steps</h4>
<ol>
<li><a href="http://cloudfoundry.com/">Get a Free CloudFoundry Account</a></li>
<li>Clone the <a href="https://github.com/SpringSource/spring-roo">Spring Roo Git Repository</a></li>
<li>Configure GPG/PGP setup<br/>see <code>/spring-roo/readme.txt</code></li>
<li>Build Spring Roo with Maven<br/><code>mvn&nbsp;-U&nbsp;clean&nbsp;install&nbsp;-Dgpg.passphrase=<em>yourpassphrase</em></code></li>
<li>Link the Roo startup script<br/>see <code>/spring-roo/readme.txt</code></li>
</ol>
<p><br/></p>
<h4>Creating a Project</h4>
<ol>
<li>Make a directory for your SimpleItem project<br/><code>mkdir /SimpleItem</code></li>
<li>Go to the directory<br/><code>cd /SimpleItem</code></li>
<li>Create the script file <code>simpleitem.roo</code> in the <code>/SimpleItem</code> directory<br/>(see the contents below)</li>
<li>Start <code>roo-dev</code></li>
<li>Type the command<br/><code>script --file simpleitem.roo</code></li>
<li>Go To: <a href="http://mysimpleitem.cloudfoundry.com/">http://mysimpleitem.cloudfoundry.com/</a></li>
</ol>
<p><br/></p>
<h4>The <code>simpleitem.roo</code> script file</h4>
<pre class="brush:text">
development mode &#45;&#45;enabled true
project &#45;&#45;topLevelPackage com.gordondickens.simpleitem &#45;&#45;java 6 &#45;&#45;projectName SimpleItem
jpa setup &#45;&#45;provider HIBERNATE &#45;&#45;database POSTGRES
entity &#45;&#45;class &#126;.domain.Item &#45;&#45;testAutomatically &#45;&#45;activeRecord false
field string &#45;&#45;fieldName name &#45;&#45;sizeMin 3 &#45;&#45;sizeMax 30 &#45;&#45;class &#126;.domain.Item
field string &#45;&#45;fieldName description &#45;&#45;sizeMax 255 &#45;&#45;class &#126;.domain.Item
field date &#45;&#45;fieldName visitDate &#45;&#45;type java.util.Date &#45;&#45;notNull &#45;&#45;past
repository jpa &#45;&#45;interface &#126;.repository.ItemRepository &#45;&#45;entity &#126;.domain.Item
service &#45;&#45;interface &#126;.service.ItemService &#45;&#45;entity &#126;.domain.Item
finder add &#45;&#45;finderName findItemsByName &#45;&#45;class &#126;.domain.Item
finder add &#45;&#45;finderName findVisitsByDescriptionLike
web mvc setup
web mvc all &#45;&#45;package &#126;.web
web mvc finder all
logging setup &#45;&#45;level DEBUG
perform package
download accept terms of use
pgp automatic trust

&#35; &#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;
&#35; NOTE&#58; Provide your credentials here, or perform these steps at the Roo prompt
&#35; &#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;
cloud foundry login &#45;&#45;email you&#64;mycompany.com &#45;&#45;password n00n3w1llgu3ss

&#35; &#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;
&#35; NOTE&#58; The war file is the "&#45;&#45;projectName" specified above
&#35; &#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;
cloud foundry deploy &#45;&#45;appName mysimpleitem &#45;&#45;path &#47;target&#47;SimpleItem&#45;0.1.0.BUILD-SNAPSHOT.war &#45;&#45;memory 512
cloud foundry create service &#45;&#45;serviceName mysimpleitem-postgres &#45;&#45;serviceType postgresql
cloud foundry bind service &#45;&#45;serviceName mysimpleitem-postgres &#45;&#45;appName mysimpleitem
cloud foundry start app &#45;&#45;appName mysimpleitem

&#35; &#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;&#35;
&#35; Go to URL&#58; http&#58;&#47;&#47;mysimpleitem.cloudfoundry.com&#47;
</pre>
<p><br/><br />
<h4>NOTE CloudFoundry is Public</h4>
<p>Since CloudFoundry is public, you may run into an issue deploying the application with the name above.  You should change the <code>&#45;&#45;projectName</code> to something unique with your name in it such as <em>yourname-simpleitem</em>.</p>
<p><a href="http://blog.springsource.com/2011/09/22/rapid-cloud-foundry-deployments-with-maven/">Gunnar Hillert&#8217;s Blog explains this well.</a></p>
<p><br/><br />
<h4>Adding <a href="http://cloudfoundry.com/">CloudFoundry</a> Plugin to Maven</h4>
<p>Thanks to <a href="http://blog.springsource.com/2011/09/22/rapid-cloud-foundry-deployments-with-maven/">Gunnar Hillert&#8217;s post</a>, we can add to our project&#8217;s Maven <code>pom.xml</code> file the CloudFoundry Plugin.</p>
<pre class="brush:xml">
&lt;plugins&gt;
  ...
  &lt;plugin&gt;
    &lt;groupId&gt;org.cloudfoundry&lt;/groupId&gt;
    &lt;artifactId&gt;cf-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;1.0.0.M1&lt;/version&gt;
    &lt;configuration&gt;
      &lt;server&gt;mycloudfoundry-instance&lt;/server&gt;
      &lt;target&gt;http://api.cloudfoundry.com&lt;/target&gt;
      &lt;url&gt;${project.name}.cloudfoundry.com&lt;/url&gt;
      &lt;memory&gt;256&lt;/memory&gt;
    &lt;/configuration&gt;
  &lt;/plugin&gt;
  ...
&lt;/plugins&gt;
</pre>
<p><br/><br />
<h4>Add <a href="http://cloudfoundry.com/">CloudFoundry</a> Credentials</h4>
<p>Add credentials to our <code><em>userhome</em>/.m2/settings.xml</code></p>
<pre class="brush:xml">
&lt;servers&gt;
  ...
  &lt;server&gt;
    &lt;id&gt;mycloudfoundry-instance&lt;/id&gt;
    &lt;username&gt;you@mycompany.com&lt;/username&gt;
    &lt;password&gt;n00n3w1llgu3ss&lt;/password&gt;
  &lt;/server&gt;
  ...
&lt;/servers&gt;
</pre>
<p>To push (deploy) the code to <a href="http://cloudfoundry.com/">CloudFoundry</a> type <code>mvn cf:push</code><br />
For more plugin details type <code>mvn cf:help</code></p>
<p><br/></p>
<hr/>
<table style="margin-left:auto;margin-right:auto;">
<tr>
<td style="vertical-align:center;font-family:Arial,sans-serif;font-weight:bold;"><a href="http://manning.com/rimple">Get Your Copy&nbsp;&#45;&#45;&gt;<br/>Get it NOW!&nbsp;&#45;&#45;&gt;</a></td>
<td><a href="http://manning.com/rimple"><img src="http://manning.com/rimple/rimple_cover150.jpg" alt="Spring Roo in Action Image" /></a></td>
<td style="vertical-align:center;font-family:Arial,sans-serif;font-weight:bold;"><a href="http://manning.com/rimple">&lt;&#45;&#45;&nbsp;All the cool kids have one<br/>&lt;&#45;&#45;&nbsp;You gotta have it!</a></td>
</tr>
</table>
<p><br/><br />
<hr/>
<h3>Want to Learn More?</h3>
<p>Learn more about Spring by attending a <a href="http://chariotsolutions.com/education">Spring Training</a> class at Chariot, or contact us for onsite training.</p>
<p><br/> </p>
<div style="text-align: center;font-size:200%;background-color:#C0C0C0;border-style:solid;border-color:SteelBlue;border-radius: 40px; -moz-border-radius: 40px; -webkit-border-radius: 40px;"><a href="http://chariotsolutions.com/education">Chariot Education Calendar</a></div>
<p><br/></p>
<h3  style="text-align: center;color:SteelBlue;font-size:125%"><a href="http://twitter.com/#!/chariotsolution"><img src="http://gordondickens.com/wordpress/wp-content/uploads/2011/04/twitter-simple-t.png" alt="" title="twitter-simple-t" width="32" height="32" class="aligncenter size-full wp-image-818" /></a>Follow <a href="http://twitter.com/#!/chariotsolution">Chariot Education on Twitter</a></h3>
<h3  style="text-align: center;color:SteelBlue;font-size:125%">for Special Training offers</h3>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2011/09/23/rocket-to-the-cloud-fast-with-roo/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2011/09/23/rocket-to-the-cloud-fast-with-roo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SyntaxHighlighter Missing XRegExp.js</title>
		<link>http://gordondickens.com/wordpress/2011/09/23/syntaxhighlighter-missing-xregexp-js/</link>
		<comments>http://gordondickens.com/wordpress/2011/09/23/syntaxhighlighter-missing-xregexp-js/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 14:07:17 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SyntaxHighlighter]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[shCore.js]]></category>
		<category><![CDATA[Syntax Highlighter]]></category>
		<category><![CDATA[syntaxhighlighter]]></category>
		<category><![CDATA[XRegExp.js]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1166</guid>
		<description><![CDATA[I just ran into an issue when I updated my javascript files for SyntaxHighlighter. Looked at the error console and discovered that shCore.js could not find XRegExp.js. This blog link was a great start. Additional Details Syntax Highlighter Git Repo &#8230; <a href="http://gordondickens.com/wordpress/2011/09/23/syntaxhighlighter-missing-xregexp-js/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just ran into an issue when I updated my javascript files for SyntaxHighlighter.</p>
<p>Looked at the error console and discovered that <code>shCore.js</code> could not find <code>XRegExp.js</code>.</p>
<p><a href="http://nixd3v.com/entry/fixing-syntax-highlighter-XRegExp-errors">This blog link was a great start.</a><br />
<br/></p>
<h4>Additional Details</h4>
<ol>
<li><a href="https://github.com/alexgorbatchev/SyntaxHighlighter">Syntax Highlighter Git Repo</a></li>
<li>Get the XRegExp.js from the scripts directory: <code>/SyntaxHighlighter/scripts/XRegExp.js</code></li>
<li>In your page above the <code>shCore.js</code> add <code>XRegExp.js</code></li>
</ol>
<h4>Page Header Example</h4>
<pre class="brush:xml; highlight: [2, 3]">
&lt;script src='js/jquery-1.6.3.min.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/syntaxhighlighter/XRegExp.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/syntaxhighlighter/shCore.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/syntaxhighlighter/shBrushPlain.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/syntaxhighlighter/shBrushJava.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/syntaxhighlighter/shBrushGroovy.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/syntaxhighlighter/shBrushXml.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/syntaxhighlighter/shBrushCss.js"&gt;&lt;/script&gt;
&lt;link href="css/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;
&lt;link href="css/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;
</pre>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2011/09/23/syntaxhighlighter-missing-xregexp-js/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2011/09/23/syntaxhighlighter-missing-xregexp-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tcServer Logging with Logback &amp; SLF4J</title>
		<link>http://gordondickens.com/wordpress/2011/08/16/tcserver-logging-with-logback-slf4j/</link>
		<comments>http://gordondickens.com/wordpress/2011/08/16/tcserver-logging-with-logback-slf4j/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 01:18:41 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[Jakarta Commons Logging]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Util Logging]]></category>
		<category><![CDATA[LogBack]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[SLF4J]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring Insight]]></category>
		<category><![CDATA[tcServer]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Logback]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[slf4j]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1142</guid>
		<description><![CDATA[Logback and SLF4J provide better logging for java applications. To configure VMware vFabric tcServer to take advantage of the speed and flexibility of Logback use the following steps as a starting point. Download the tcServer Developer Edition free: http://www.springsource.com/developer/tcserver This &#8230; <a href="http://gordondickens.com/wordpress/2011/08/16/tcserver-logging-with-logback-slf4j/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Logback and SLF4J provide better logging for java applications.  To configure VMware vFabric tcServer to take advantage of the speed and flexibility of Logback use the following steps as a starting point.</p>
<p>Download the tcServer Developer Edition free: <a href="http://www.springsource.com/developer/tcserver">http://www.springsource.com/developer/tcserver</a><br />
This comes with Spring Insight: <a href="http://www.springsource.org/insight">http://www.springsource.org/insight</a> an awesome tool for inspecting application performance, see those expensive sql queries, etc.</p>
<p><br/><br />
<h3>1. Add JMX options</h3>
<p>File: <code>&lt;appname&gt;/bin/setenv.sh</code></p>
<pre class="brush:text">
CATALINA_OPTS="-Dcom.sun.management.jmxremote"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
</pre>
<p><br/><br />
<h3>2.  Enable JMX</h3>
<p>File: <code>&lt;appname&gt;/conf/server.xml</code></p>
<p># In the &lt;service&gt; section:</p>
<pre class="brush:xml">
&lt;Connector port="8050"
  handler.list="mx"
  mx.enabled="true"
  mx.httpHost="localhost"
  mx.httpPort="8082"
  protocol="AJP/1.3" /&gt;
</pre>
<p><br/><br />
<h3>3.  If using JNDI, add JNDI Configuration support for Logback</h3>
<p>File: <code>&lt;appname&gt;/bin/setenv.sh</code></p>
<pre class="brush:text">
JAVA_OPTS="$JAVA_OPTS -Dlogback.ContextSelector=JNDI"
</pre>
<p><br/><br />
<h3>4.  Add Server Logging using Logback</h3>
<p>File: <code>&lt;appname&gt;/conf/server.xml</code></p>
<p>#In the &lt;Hosts&gt; Section:</p>
<pre class="brush:xml">
&lt;Valve className="ch.qos.logback.access.tomcat.LogbackValve" /&gt;
</pre>
<p><br/><br />
<h3>5. Create <code>logback-access.xml</code> file in <code>&lt;appname&gt;/conf/</code> directory</h3>
<pre class="brush:xml">
&lt;configuration&gt;
  &lt;statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" /&gt;

  &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
    &lt;encoder&gt;
      &lt;pattern&gt;combined&lt;/pattern&gt;
    &lt;/encoder&gt;
  &lt;/appender&gt;

  &lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
    &lt;file&gt;myApp.log&lt;/file&gt;
    &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
      &lt;fileNamePattern&gt;myApp-%d{yyyy-MM-dd}.%i.txt&lt;/fileNamePattern&gt;
      &lt;timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
        &lt;maxFileSize&gt;5MB&lt;/maxFileSize&gt;
      &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
    &lt;/rollingPolicy&gt;
    &lt;encoder&gt;
      &lt;pattern&gt;combined&lt;/pattern&gt;
    &lt;/encoder&gt;
  &lt;/appender&gt;

  &lt;logger name="com.MYAPP.MYPKG" level="debug" /&gt;
  &lt;logger name="org.springframework.web" level="debug" /&gt;
  &lt;logger name="org.springframework.beans" level="debug" /&gt;
  &lt;logger name="org.springframework.orm" level="debug" /&gt;
  &lt;logger name="org.springframework.web" level="debug" /&gt;
  &lt;logger name="net.sf.ehcache" level="error" /&gt;
  &lt;logger name="org.hibernate.cache" level="error" /&gt;

  &lt;root level="info"&gt;
    &lt;appender-ref ref="FILE" /&gt;
    &lt;appender-ref ref="STDOUT" /&gt;
  &lt;/root&gt;
&lt;/configuration&gt;
</pre>
<p><br/><br />
<h3>6.  In the <code>&lt;tomcatdir&gt;/lib</code> directory, add the following jars</h3>
<p>By including JCL-over-SLF4J, we handle Apache Commons Logging through SLF4J (JCL = Jakarta Commons Logging)<br />
By including JUL-to-SLF4J, we handle Java Util Logging through SLF4J</p>
<ul>
<li>jcl-over-slf4j-1.6.2.jar</li>
<li>jul-to-slf4j-1.6.2.jar</li>
<li>slf4j-api-1.6.2.jar</li>
<li>logback-access-0.9.30.jar</li>
<li>logback-classic-0.9.30.jar</li>
<li>logback-core-0.9.30.jar</li>
</ul>
<p><br/><br />
<h3>7.   Configure the application for Logging Separation</h3>
<p>See: <a href="http://logback.qos.ch/manual/loggingSeparation.html">http://logback.qos.ch/manual/loggingSeparation.html</a></p>
<pre class="brush:xml">
&lt;env-entry&gt;
  &lt;description&gt;JNDI logging context for this app&lt;/description&gt;
  &lt;env-entry-name&gt;logback/context-name&lt;/env-entry-name&gt;
  &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;
  &lt;env-entry-value&gt;yourAppHere&lt;/env-entry-value&gt;
&lt;/env-entry&gt;

&lt;env-entry&gt;
  &lt;description&gt;URL for configuring logback context&lt;/description&gt;
  &lt;env-entry-name&gt;logback/configuration-resource&lt;/env-entry-name&gt;
  &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;
  &lt;env-entry-value&gt;logback.xml&lt;/env-entry-value&gt;
&lt;/env-entry&gt;

&lt;listener&gt;
  &lt;listener-class&gt;ch.qos.logback.classic.selector.servlet.ContextDetachingSCL&lt;/listener-class&gt;
&lt;/listener&gt;

&lt;filter&gt;
  &lt;filter-name&gt;LoggerContextFilter&lt;/filter-name&gt;
  &lt;filter-class&gt;ch.qos.logback.classic.selector.servlet.LoggerContextFilter&lt;/filter-class&gt;
&lt;/filter&gt;

&lt;filter-mapping&gt;
  &lt;filter-name&gt;LoggerContextFilter&lt;/filter-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
</pre>
<p><br/><br />
<h3>8. Optional &#8211; To add a servlet to view the logback events</h3>
<p>File: <code>&lt;application&gt;/src/main/webapp/WEB-INF/web.xml</code><br />
See: <a href="http://logback.qos.ch/manual/configuration.html">http://logback.qos.ch/manual/configuration.html</a><br />
Status Messages will be available: http://yourWebapp/lbClassicStatus</p>
<pre class="brush:xml">
&lt;servlet&gt;
  &lt;servlet-name&gt;ViewStatusMessages&lt;/servlet-name&gt;
  &lt;servlet-class&gt;ch.qos.logback.classic.ViewStatusMessagesServlet&lt;/servlet-class&gt;
&lt;/servlet&gt;

&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;ViewStatusMessages&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/lbClassicStatus&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
</pre>
<p><br/><br />
<h3>Summary</h3>
<p>Using tcServer with Insight provides us developers with a valuable resource for code inspection at runtime.  Logback and SLF4J provides us with fast, flexible logging configuration and the logging separation for our application instances.</p>
<p><br/><br />
<hr/>
<h3>Want to Learn More?</h3>
<p>Learn more about Spring by attending a <a href="http://chariotsolutions.com/education">Spring Training</a> class at Chariot, or contact us for onsite training.</p>
<p><br/> </p>
<div style="text-align: center;font-size:200%;background-color:#C0C0C0;border-style:solid;border-color:SteelBlue;border-radius: 40px; -moz-border-radius: 40px; -webkit-border-radius: 40px;"><a href="http://chariotsolutions.com/education">Chariot Education Calendar</a></div>
<p><br/></p>
<h3  style="text-align: center;color:SteelBlue;font-size:125%"><a href="http://twitter.com/#!/chariotsolution"><img src="http://gordondickens.com/wordpress/wp-content/uploads/2011/04/twitter-simple-t.png" alt="" title="twitter-simple-t" width="32" height="32" class="aligncenter size-full wp-image-818" /></a>Follow <a href="http://twitter.com/#!/chariotsolution">Chariot Education on Twitter</a></h3>
<h3  style="text-align: center;color:SteelBlue;font-size:125%">for Special Training offers</h3>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2011/08/16/tcserver-logging-with-logback-slf4j/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2011/08/16/tcserver-logging-with-logback-slf4j/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Queries to Spring Data-JPA</title>
		<link>http://gordondickens.com/wordpress/2011/08/02/adding-queries-to-spring-data-jpa/</link>
		<comments>http://gordondickens.com/wordpress/2011/08/02/adding-queries-to-spring-data-jpa/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 17:55:08 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://gordondickens.com/wordpress/?p=1124</guid>
		<description><![CDATA[In my previous post, Simpler JPA with Spring Data-JPA I showed how to configure a repository interface which Spring Data will implement for us. Let me show how easy it is to add queries. Modify the Repository Interface Simply define &#8230; <a href="http://gordondickens.com/wordpress/2011/08/02/adding-queries-to-spring-data-jpa/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In my previous post, <a href="http://gordondickens.com/wordpress/2011/08/01/simpler-jpa-with-spring-data-jpa/">Simpler JPA with Spring Data-JPA</a> I showed how to configure a repository interface which Spring Data will implement for us.  Let me show how easy it is to add queries.</p>
<p><br/><br />
<h3>Modify the Repository Interface</h3>
<p>Simply define the method interface and use the <code>@Query</code> annotation to define the OQL.
<pre class="brush:java">
package com.gordondickens.myapp.repository;

import org.springframework.data.repository.CrudRepository;
import com.gordondickens.myapp.entity.Product;

public interface ProductRepository
   extends CrudRepository&lt;Product, Long&gt; {

	@Query("FROM Product")
	List&lt;Product&gt; findAllProducts();
}
</pre>
<h3>Modifying Queries</h3>
<ul>
<li>Parameters can be marked by position with ?1, ?2, etc.</li>
<li>Parameters can be marked by name with :paramName and annotation <code>@Param("paramName")</code></li>
<li>Modifying method signature can only return <code>void</code>, <code>Integer</code> or <code>int</code></li>
<li>Updating queries MUST be transactional, mark with <code>@Transactional</code></li>
<li>Spring Data will drop all non-flushed changes pending in the <code>EntityManager</code>, change with <code>@Modifying(clearAutomatically=false)</code></li>
</ul>
<pre class="brush:java">
package com.gordondickens.myapp.repository;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

@Transactional(readOnly=true)
public interface ProductRepository
   extends CrudRepository&lt;Product, Long&gt; {

   @Query("FROM Product")
   List&lt;Product&gt; findAllProducts();

   // Example with positional params
   @Modifying
   @Transactional(readOnly=false)
   @Query("update Product p set p.description = ?2 where p.productId = ?1")
   Integer setNewDescriptionForProduct(String productId, String description);

   // Example with named params
   @Modifying
   @Query("update Product p set p.description = :description where p.productId = :productId")
   Integer setNewDescriptionForProduct(@Param("productId") String productId,
      @Param("description") String description);
}
</pre>
<p><br/><br />
<h3>Automatic Query Generation</h3>
<p>The <code>&lt;jpa:repositories/&gt;</code> has an option <code>query-lookup-strategy </code>which defaults to &#8220;<code>create-if-not-found</code>&#8221; which will generate queries for us.</p>
<p>The default is &#8220;<code>create-if-not-found</code>&#8220;.  Other options are &#8220;<code>create</code>&#8221; or &#8220;<code>use-declared-query</code>&#8220;.</p>
<pre class="brush:xml">
   &lt;jpa:repositories base-package="com.gordondickens.myapp.repository"
		query-lookup-strategy="create-if-not-found"/&gt;
</pre>
<p>To create a find method that effectively does <code>@Query("FROM Product p where p.productId = :productId")</code></p>
<pre class="brush:java">
public interface ProductRepository extends CrudRepository&lt;Product, Long&gt; {
   ...

   @Query
   Product findByProductId(String productId);

   ...
</pre>
<p><br/><br />
<h3>Summary</h3>
<p>We see how simple interface additions provide custom methods based on query language.  We can query either by positional or named parameters.</p>
<p><br/><br />
<hr/>
<h3>Want to Learn More?</h3>
<p>Learn more about Spring by attending a <a href="http://chariotsolutions.com/education">Spring Training</a> class at Chariot, or contact us for onsite training.</p>
<p><br/> </p>
<div style="text-align: center;font-size:200%;background-color:#C0C0C0;border-style:solid;border-color:SteelBlue;border-radius: 40px; -moz-border-radius: 40px; -webkit-border-radius: 40px;"><a href="http://chariotsolutions.com/education">Chariot Education Calendar</a></div>
<p><br/></p>
<h3  style="text-align: center;color:SteelBlue;font-size:125%"><a href="http://twitter.com/#!/chariotsolution"><img src="http://gordondickens.com/wordpress/wp-content/uploads/2011/04/twitter-simple-t.png" alt="" title="twitter-simple-t" width="32" height="32" class="aligncenter size-full wp-image-818" /></a>Follow <a href="http://twitter.com/#!/chariotsolution">Chariot Education on Twitter</a></h3>
<h3  style="text-align: center;color:SteelBlue;font-size:125%">for Special Training offers</h3>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://gordondickens.com/wordpress/2011/08/02/adding-queries-to-spring-data-jpa/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://gordondickens.com/wordpress/2011/08/02/adding-queries-to-spring-data-jpa/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

