<?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>Whitehorses Blog &#187; Enterprise Java</title>
	<atom:link href="http://blog.whitehorses.nl/category/enterprise-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.whitehorses.nl</link>
	<description>Oracle, Java and SOA expertise - Lean thinking, Agile working</description>
	<lastBuildDate>Sat, 07 Jan 2012 19:37:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Devoxx 2011 &#8211; The Groovy Ecosystem</title>
		<link>http://blog.whitehorses.nl/2011/12/14/devoxx-2011-the-groovy-ecosystem/</link>
		<comments>http://blog.whitehorses.nl/2011/12/14/devoxx-2011-the-groovy-ecosystem/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 20:47:25 +0000</pubDate>
		<dc:creator>Roger Goossens</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[griffon]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2573</guid>
		<description><![CDATA[My last talk at Devoxx was the one that perhaps i enjoyed the most and one that I was really impressed by. A lot of neat products based on Groovy were discussed in this talk. They had a lot in common. Besides all being based on Groovy, they also have a very simple installation procedure [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>My last talk at Devoxx was the one that perhaps i enjoyed the most and one that I was really impressed by. A lot of neat products based on Groovy were discussed in this talk. They had a lot in common. Besides all being based on Groovy, they also have a very simple installation procedure in common: just download the product, unzip it, and add the executable to the PATH variable. And voilá, you have a command line tool at your disposal linked to the product you downloaded.</p>
<p>The talk was presented by Andres Almiray. All the products he discussed, he demoed by using a text editor and a command line (and sometimes a web browser), which was pretty cool. It furthermore emphasized the simplicity of working with the different products. Like Andres did in his presentation, I will focus this blog on Grails, Griffon and Gradle and only give a short summary of the other products.</p>
<h3>Grails</h3>
<p>First up was maybe the most widely known product in the Groovy eco-system. <a href="http://grails.org/">Grails</a> is a high-productivity web application framework based on Spring, Hibernate and Sitemesh. It&#8217;s a widely used framework and currently there are over 600 plugins available for Grails, facilitating the addition of custom functionality (like file uploading or integration with soap or rest services) to your web application.</p>
<p>With Grails you bring Rapid Application Web Development to the table. In no time Andres got a CRUD application up an running.</p>
<p>First he created a basic Grails application</p>
<pre class="brush: bash">$ grails create-app devoxx</pre>
<p>Next, he added some domain classes</p>
<pre class="brush: bash">$ grails create-domain-class Author
$ grails create-domain-class Book</pre>
<p>This created the <em>Author.groovy</em> and <em>Book.groovy</em> class files.</p>
<p>The relation between the two classes Andres added manually by adding the following line of code to the <em>Author</em> class:</p>
<pre class="brush: groovy">static hasMany [books:Book]</pre>
<p>With the domain classes in order, we can now create 2 controller classes <em>AuthorController</em> and <em>BookController</em>:</p>
<pre class="brush: ruby">$ grails create-controller Author
$ grails create-controller Book</pre>
<p>Now, to enable auto-generation of the view layer of the application based on the domain classes, we have to enable a feature called scaffolding. The following line of code added to the <em>AuthorController</em> takes care of this:</p>
<pre class="brush: groovy">static scaffold = true</pre>
<p>Now all is in place for running the application:</p>
<pre class="brush: bash">$ grails run-app</pre>
<p>With scaffolding in place all the views for the CRUD app get auto-generated (as .<em>gsp</em> pages). The <em>run-app</em> command furthermore packages the application and bootstraps TomCat. Now you can reach the application at the following url: http://localhost:8080/devoxx/author.</p>
<p>One additional benefit of using these basic commands to rapidly generate a prototype is that every generated class gets to appear in its own default package, given that Grails is based on the configuration by exception paradigm. Scaffolding is based on templates and all these templates can be customized to fit your needs.</p>
<p>After the basics Andres shows some additional Grails features. All of them very easy to add to the application:</p>
<ul>
<li>Adding constraints to domain classes (Grails error messages support i18n);</li>
<li>Creating a taglib: $<em> grails create-taglib</em>;</li>
<li>Launching the Grails <em>console</em>, an interactive playground, similar to the Groovy console: $<em> grails console</em></li>
<li>The grails <em>war</em> command: $ <em>grails war</em>;</li>
<li>Installing the Grails REST plugin: $ <em>grails install-plugin rest;</em></li>
<li>Creating and packaging a custom plugin: $<em> grails create-plugin</em> / $ <em>grails package-plugin</em>.</li>
</ul>
<h3>Griffon</h3>
<p><a href="http://griffon.codehaus.org/">Griffon</a> is similar to Grails. It&#8217;s a high productivity framework for building Desktop applications. Griffon is a relatively new framework. It already has nearly 200 plugins available though.</p>
<p>A lot of the commands in Griffon are similar to the commands used in Grails. Here are some useful commands:</p>
<pre class="brush: bash">$ griffon create-app devoxx
$ griffon run-app
$ griffon run-applet
$ griffon run-webstart</pre>
<p>Views are by convention filed under the <em>view</em> directory in a Griffon project and are named &#8230;View.groovy. Griffon uses bindings to couple fields or properties in the view layer to bean properties in the model layer. Here are some code snippets to illustrate:</p>
<p>DevoxxModel.groovy</p>
<pre class="brush: groovy">@Bindable String input
@Bindable String output</pre>
<p>DevoxxController.groovy</p>
<pre class="brush: groovy">def copy = {
  // model gets injected by Griffon
  model.output = model.input
}</pre>
<p>DevoxxView.groovy</p>
<pre class="brush: groovy">textField(text:bind(target:model,targetProperty:'input'))
textField(text:bind(source:model,targetProperty:'output'))</pre>
<p>The controller copy method copies the input property of the model to the output property. Both properties are bound in the view to text fields.</p>
<p>One of the key concerns that&#8217;s difficult to manage in Swing applications is threading. And this is something in which Griffon really shines. For example if you have a controller method you want to execute in a thread separate from the UI Thread, you add the following annotation:</p>
<pre class="brush: groovy">@Threading(Threading.Policy.OUTSIDE_UITHREAD)</pre>
<p>As an alternative you can make use of the following Griffon methods to execute pieces of code in the threaded manner you want:</p>
<ul>
<li>execAsync: execute the code in the UI Thread asynchronously;</li>
<li>execSync: execute the code in the UI Thread synchronously;</li>
<li>execOutside: execute the code outside the UI Thread.</li>
</ul>
<p>Griffon also supports an event mechanism. You can launch an event called Devoxx and include a list of parameters with the following Griffon code:</p>
<pre class="brush: groovy">app.event('Devoxx',[1,2,3])</pre>
<p>Like the exec method, there&#8217;s also a variant for asynchronous events (<em>app.eentAsync</em>) and one for outside events (<em>app.eventOutside)</em>.</p>
<p>A possible event handler could look like this:</p>
<pre class="brush: groovy">def onDevoxx = { n1,n2,n3 -&gt;
println: "Devoxx $n1,$n2,$n3"
}</pre>
<p>A lot of the create- commands from Griffon also let you generate artifacts in Java instead of Groovy. Simply add <em>fileType=java</em> to the command. One interesting, though not very surprising, fact to note is that the Java files are a lot bigger compared to the same files generated in Groovy.</p>
<h3>Gaelyk</h3>
<p><a href="http://gaelyk.appspot.com/">Gaelyk</a> is a lightweight Groovy toolkit for <a title="Google App Engine Java" href="http://code.google.com/appengine/">Google App Engine Java</a>. Google App Engine is a so called Platform As A Service and provides a Java 6 Runtime Environment.</p>
<h3>Gradle</h3>
<p><a href="http://www.gradle.org/">Gradle</a> is a Groovy alternative to <a title="Maven" href="http://maven.apache.org/">Maven</a>. It&#8217;s a tool for building applications. It uses Groovy DSL (Domain Specific Language) instead of XML and adheres to specific Maven conventions.</p>
<p>This is an example of a simple Gradle build file for a java project (compare that to a simple Maven file):</p>
<p><strong>build.gradle</strong></p>
<pre class="brush: groovy">apply plugin: 'java'</pre>
<p>This is a build file for a java project that uses the same default conventions as Maven does (like java source files are by default placed in the <em>src/main/java</em> directory).<br />
To build a project based on this build file, simply type:</p>
<pre class="brush: bash">$ gradle build</pre>
<p>When you issue this command, Gradle bootstraps and builds the project. When you issue the command a next time and there are no changes, Gradle is able to recognize this and doesn&#8217;t perform an unnecessary second build. You still lose the amount of time needed for bootstrapping Gradle. There&#8217;s also an experimental daemon available, so you can go without even the bootstrapping time. Gradle, like Maven, uses configuration by exception. So, like Maven, you can do without the default structure of a project is that doesn&#8217;t fit your needs. But you have to add additional configuration code to your build file.</p>
<p>Dependency management in Gradle by default uses Maven repositories. For example, to add a compile dependency for <em>commons-lang</em>, your build file would need these additional lines of code:</p>
<pre class="brush: groovy">repositories {
    mavenCentral()
}

dependencies {
    compile 'commons-lang:commons-lang:2.6'
}</pre>
<p>To view a list of dependencies for the current project you can issue the following Gradle command:</p>
<pre class="brush: bash">$ gradle dependencies</pre>
<p>Multiprojects in Gradle are very easy. Assume you have a multi project with two projects <em>multi-core</em> and <em>multi-ext</em>, where <em>multi-ext</em> is dependent on <em>multi-core</em>. You first add a <em>settings.gradle</em> file next to the <em>build.gradle</em> file for the <em>root</em> project:<br />
<strong>settings.gradle</strong></p>
<pre class="brush: groovy">include 'multi-core'
include 'multi-ext'</pre>
<p>Next you add a dependency on <em>multi-core</em> in the <em>build.gradle</em> file of the <em>multi-ext</em> project. And that&#8217;s all there is to it. When you now build the <em>multi-ext</em> project, the <em>multi-core</em> project also gets build. Changes to the <em>multi-core</em> project are also picked up when rebuilding the <em>multi-ext</em> project.</p>
<p>To build a pom file for your current project, issue the following command:</p>
<pre class="brush: bash">$ gradle install</pre>
<p>Like Maven, you can define properties in Gradle in a <em>gradle.properties</em> file.</p>
<p>The open source projects Grails and Griffon both use Gradle as their build tool.</p>
<h3>Gant</h3>
<p><a href="http://gant.codehaus.org/">Gant</a> is a Groovy version of <a title="Ant" href="http://ant.apache.org/">Ant</a>. You have the power of Ant at your disposal but in a Groovy way, thus without the bloated xml.</p>
<h3>easyb</h3>
<p><a href="http://www.easyb.org/">easyb</a> is a behavior driven development (BDD) framework. Stories and specifications are written in Groovy. It is comparable to <a>JBehave</a>, which does the same in Java.</p>
<h3>Spock</h3>
<p><a href="http://code.google.com/p/spock/">Spock</a> is a testing and specification framework for Java and Groovy applications.</p>
<h3>CodeNarc</h3>
<p><a href="http://codenarc.sourceforge.net/">CodeNarc</a> is an equivalent to the java tools <a title="findBugs" href="http://findbugs.sourceforge.net/">findBugs</a> and <a title="checkstyle" href="checkstyle">checkstyle</a>. It&#8217;s a tool for analyzing Groovy code and detecting bugs, coding malpractices and the like. There are plugins available for Grails, Griffon and Gradle.</p>
<h3>GPars</h3>
<p><a href="http://gpars.codehaus.org/">Gpars</a> lastly is a framework aimed to simplify concurrency programming in Java or Groovy.</p>
<h3>References</h3>
<ul>
<li><a title="Slides" href="http://www.slideshare.net/aalmiray/devoxx-the-groovy-ecosystem">Devoxx Slides</a></li>
<li><a title="Griffon slides" href="http://www.slideshare.net/ecspike/introduction-to-griffon">Griffon Slides</a></li>
<li><a title="Grails in Action" href="http://www.manning.com/gsmith/">Grails in Action</a></li>
<li><a title="Griffon in Action" href="http://www.manning.com/almiray/">Griffon in Action</a></li>
<li><a title="GroovyMag" href="http://www.groovymag.com/">GroovyMag</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2011/12/14/devoxx-2011-the-groovy-ecosystem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx 2011 &#8211; Introduction to Apache ActiveMQ, ServiceMix, Camel and CXF</title>
		<link>http://blog.whitehorses.nl/2011/11/27/devox-2011-introduction-to-apache-activemq-servicemix-camel-and-cxf/</link>
		<comments>http://blog.whitehorses.nl/2011/11/27/devox-2011-introduction-to-apache-activemq-servicemix-camel-and-cxf/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 13:23:42 +0000</pubDate>
		<dc:creator>Roger Goossens</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Integration, SOA & BPM]]></category>
		<category><![CDATA[ActiveMQ]]></category>
		<category><![CDATA[Camel]]></category>
		<category><![CDATA[CXF]]></category>
		<category><![CDATA[devoxx2011]]></category>
		<category><![CDATA[ServiceMix]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2525</guid>
		<description><![CDATA[The first talk of day 2 I attended, was about integration. Integration frameworks comes into play when you have to integrate between different technologies (JDBC, HTTP, JMS) or different message formats (XML, EDI, CSV, etc.). Charles Moulliard presented this session in which he discussed a bundle of Apache licensed products used to enable integration: Apache [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The first talk of day 2 I attended, was about integration. Integration frameworks comes into play when you have to integrate between different technologies (JDBC, HTTP, JMS) or different message formats (XML, EDI, CSV, etc.). Charles Moulliard presented this session in which he discussed a bundle of Apache licensed products used to enable integration:</p>
<ul>
<li>Apache <a title="Apache Camel" href="http://camel.apache.org/" target="_blank">Camel</a>: java-based routing and mediation engine;</li>
<li>Apache <a title="Apache CXF" href="http://cxf.apache.org/" target="_blank">CXF</a>: web services framework (SOAP/REST);</li>
<li>Apache <a title="Apache Active MQ" href="http://activemq.apache.org/">ActiveMQ</a>: message broker, a JMS implementation;</li>
<li>Apache <a title="Apache ServiceMix" href="http://servicemix.apache.org/home.html" target="_blank">ServiceMix</a>: an open source ESB, based on JBI (Java Business Integration).</li>
</ul>
<h3>Apache Camel</h3>
<p>Camel is introduced as an open source integration framework enabling the implementation of <a title="Enterprise Integration Patterns" href="http://www.eaipatterns.com/" target="_blank">Enterprise Integration Patterns</a> (EIP). It has the following features:</p>
<ul>
<li>Contrary to a lot of integration frameworks that are out there, with Camel one is able to implement <span style="text-decoration: underline;">all</span> EIP patterns;</li>
<li>Supports Java DSL and Spring based XML configuration to transpose EIP patterns into Java;</li>
<li>It&#8217;s an in-memory bus;</li>
<li>Routes objects (XML, Stream, File, Bytes);</li>
<li>Transactional;</li>
<li>Supports Sync/Async exchanges;</li>
<li>Threads management;</li>
<li>Error and Exception Handling.</li>
</ul>
<p>Routing is implemented via Java DSL (Domain Specific Language). Here is an example for integrating 2 endpoints (A and B) and using a filter in between.</p>
<pre class="brush: java">public class FilterRoute extends RouteBuilder {
    public void configure throws Exception {
        Endpoint A = endpoint("activemq:queue:quote");
        Endpoint B = endpoint("mq:quote");
        Predicate isWidget = xpath("/quote/product = 'widget'");

        from(A).filter(isWidget).to(B);
    }
}</pre>
<p>You can also build a oneliner inside the method that accomplishes the same thing:</p>
<pre class="brush: java">        from(endpoint("activemq:queue:quote")).filter().xpath("/quote/product = 'widget'").to(endpoint("mq:quote"));</pre>
<p>Java DSL is currently supported by all the major IDEs (Netbeans, IntelliJ and Eclipse). When using an IDE you have the added advantage of code completion. You lose this advantage when you switch to Spring XML configuration.</p>
<h3>Apache CXF</h3>
<p>CXF is a webservices framework designed to simplify the creation and deployment of webservices. It&#8217;s a merge of 2 previous frameworks, XFire (an Apache Axis competitor) and Celtic. CXF provides the following features:</p>
<ul>
<li>It has <em>java2wsdl</em> and <em>wsdl2java</em> generation capabilities;</li>
<li>Supports JAX-WS, JAX-RS, SOAP, WSDL, WS-Security, WS-ReliableMessaging, WS-Addressing;</li>
<li>Maven plugin <strong>cxf-codegen-plugin</strong> for code generation (<em>wsdl2java</em>);</li>
<ul>
<li>it uses a spring configuration file for setting specific generation properties;</li>
<li>it generates java classes with JAXB and JAX-WS annotations.</li>
</ul>
</ul>
<h3>Apache ActiveMQ</h3>
<p>The routing done in Apache Camel is all in-memory. This means that exchanges can become lost. Sometimes this is not very desirable. For those situations ActiveMQ provides the solution.</p>
<p>ActiveMQ is based on JMS and supports point-to-point messaging (JMS Queue, one sender, one receiver) as well as publish/subscribe (JMS Topic, one publisher, zero to many subscribers).</p>
<h3>Apache ServiceMix</h3>
<p>Apache ServiceMix is an ESB and supports the exchange of messages and objects between a range of transport layers. It has the following characteristics:</p>
<ul>
<li>provides connectors (endpoints) for receiving messages and sending them on the bus;</li>
<li>separation of business logic and messaging logic;</li>
<li>based on <a title="JBI" href="http://www.jcp.org/en/jsr/detail?id=208" target="_blank">JBI;</a></li>
<li>uses a Normalized Message Router. Components are never directly coupled, there&#8217;s the router in between, which uses a Normalized (based on XML) Message format. This format is a combination of metadata, payload and attachments.</li>
</ul>
<p>Since the JBI standard is a dead standard, ServiceMix had deviated from it and added additional functionality:</p>
<ul>
<li>Modularity based on <a title="OSGI" href="http://www.osgi.org/Main/HomePage" target="_blank">OSGI</a> (ServiceMix4 can use Felix or Equinox as the OSGI kernel);</li>
<li>Adopted Camel as the new routing engine.</li>
</ul>
<h3>Apache Karaf</h3>
<p>At this point Apache <a title="Apache Karaf" href="http://karaf.apache.org/" target="_blank">Karaf</a> is introduced. Karaf is a lightweight container to which Java applications, Camel Routes and CXF services can be deployed. It has an OSGI run-time and supports <a title="Apache Felix" href="http://felix.apache.org/site/index.html" target="_blank">Apache Felix</a> and <a title="Eclipse Equinox" href="http://eclipse.org/equinox/" target="_parent">Eclipse Equinox</a>. It&#8217;s also the heart of Apache ServiceMix. If you don&#8217;t need ESB or NMR features, Karaf is basically all you need. Furthermore, because it&#8217;s a modular container you can choose which options you really need. For example, you can choose only to activate Camel and CXF and do without ActiveMQ.</p>
<p>Apache Karaf has the following characteristics:</p>
<ul>
<li>Admin console is available;</li>
<li>Supports hot deployment and configuration management;</li>
<li>Security integration (JAAS);</li>
<li>Logging management (log4j, Logger, commons logging, etc.).</li>
</ul>
<h3>Fuse IDE</h3>
<p>Fuse IDE is an Eclipse based IDE with built-in support for Apache Camel, ServiceMix, and ActiveMQ. It offers the following:</p>
<ul>
<li>A graphic editor for Camel routes (a graphical representation of the <em>camel-context.xml</em> file, the Spring XML way of defining routes);</li>
<li>Run-time views and statistics of deployed routes;</li>
<li>JMX explorer;</li>
<li>Drag-and-drop of test messages to deployed routes;</li>
<li>And a lot more.</li>
</ul>
<h3>Fuse Fabric</h3>
<p><a title="Fuse Fabrics" href="http://fabric.fusesource.org/" target="_blank">Fuse Fabric</a> is a piece of software that makes it a lot easier to configure, package and deploy the aforementioned applications, be it an Apache ServiceMix project or an Apache Camel route:</p>
<ul>
<li>It helps you with getting the OSGI dependencies right by making use of the Maven dependencies;</li>
<li>It also eases deployment to clouds;</li>
<li>With Fabric you can create and manage instances (Karaf or ServiceMix) locally, remotely (ssh) or in the cloud;</li>
<li>Provides a <em>registry</em> (service and <em>profile</em> repository), based on <a title="Apache ZooKeeper" href="http://zookeeper.apache.org/" target="_blank">Apache ZooKeeper</a>;</li>
<li>Adds an <em>agent</em> to server instances which can act upon these instances by <em>profiles</em>;</li>
<li>A <em>profile</em> is a list of tasks for an agent to do.</li>
</ul>
<h3>Conclusion</h3>
<p>With all the ingredients mentioned above almost any integration challenge can be tackled and any service architecture can be realized. ServiceMix also supports high availability via clustering and master/slave replication. For more information on some of the possible architectures see the slides mentioned in the References section.</p>
<h3>References</h3>
<ul>
<li><a title="Blog Charles Moulliard" href="http://cmoulliard.blogspot.com/" target="_blank">Blog</a> Charles Moulliard</li>
<li><a title="devoxx slides" href="http://www.slideshare.net/cmoulliard/devoxx-2011-integrationcamelcxfservicemixactivemq" target="_blank">Slides</a></li>
<li><a title="apache-activemq-camel-cxf-and-servicemix-overview" href="http://www.slideshare.net/MarceloJabali/apache-activemq-camel-cxf-and-servicemix-overview" target="_blank">Slides</a> (Not the ones from Devoxx)</li>
<li><a title="Hand on lab" href="https://github.com/cmoulliard/Devoxx-2011-HandsOnLab" target="_blank">Hands on lab</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2011/11/27/devox-2011-introduction-to-apache-activemq-servicemix-camel-and-cxf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx 2011 &#8211; Spring Into The Cloud</title>
		<link>http://blog.whitehorses.nl/2011/11/24/devoxx-2011-spring-into-the-cloud/</link>
		<comments>http://blog.whitehorses.nl/2011/11/24/devoxx-2011-spring-into-the-cloud/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 21:38:23 +0000</pubDate>
		<dc:creator>Roger Goossens</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[devoxx2011]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2471</guid>
		<description><![CDATA[The second talk of day 1 I attended, was a mix of NoSQL and Cloud Computing. And more to the point, how to integrate these technologies into Spring Enterprise Applications. The NoSQL part focussed on two popular NoSQL databases, Redis and MongoDB and was done by Chris Richardson, while the cloud part focussed on vmware&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The second talk of day 1 I attended, was a mix of NoSQL and Cloud Computing. And more to the point, how to integrate these technologies into Spring Enterprise Applications. The NoSQL part focussed on two popular NoSQL databases, <a title="Redis" href="http://redis.io/" target="_blank">Redis</a> and <a title="MongoDB" href="http://www.mongodb.org/" target="_blank">MongoDB</a> and was done by Chris Richardson, while the cloud part focussed on vmware&#8217;s <a title="CloudFoundry" href="http://www.cloudfoundry.com/" target="_blank">Cloud Foundry</a>. This part was presented by Josh Long.</p>
<h3>Cloud</h3>
<p>With a little background to the rise of cloud services and why we need them (Big Data, New Clients, Social Networking to name but a few of the reasons), Cloud Foundry is introduced. Cloud Foundry is a so called Platform As A Service (PAAS). A PAAS provider has the benefits of eg. ease of deployment, application management and can be easily scaled up or down.</p>
<h4>Cloud Foundry</h4>
<p>Cloud Foundry gives you:</p>
<ul>
<li>a tomcat server;</li>
<li>a choice of programming languages like Java, Scala and Groovy;</li>
<li>a choice of application services like RabbitMQ, MongoDB, Redis and MySQL;</li>
<li>a choice of frameworks, like Grails and Ruby on Rails</li>
<li>a command line interface (vmc);</li>
<li>an application lifecycle API (lets you eg. start or stop your deployed applications);</li>
<li>integration with the <a title="SpringSource Tool Suite" href="http://www.springsource.com/developer/sts" target="_blank">SpringSource Tool Suite</a> (an IDE based on Eclipse for Spring developers).</li>
</ul>
<p>Cloud Foundry is also avalilable as a free, so called <a title="Micro Cloud" href="http://blog.cloudfoundry.com/post/9331377393/we-shrunk-the-cloud-introducing-micro-cloud-foundry" target="_blank">Micro Cloud</a>, that makes it easy for developers to do some experimenting.</p>
<p>Josh showed a demo of how to deploy applications to Cloudfoundry via the command line interface. For example, with the <strong>vmc push</strong> command you can deploy web applications to Cloud Foundry&#8217;s Tomcat Server and the <strong>vmc update</strong> command is used for updating those apps (only the changed parts in the source code are transfered to the cloud). With the <strong>vmc create-service</strong> command you can create application services on Cloud Foundry, like a mysql database. In another demo Josh showed that all this can also be accomplished graphically by using the SpringSource Tool Suite.</p>
<h4>Cloud Foundry in Spring</h4>
<p>The setup for integrating with Cloud Foundry services is done in the usual Spring style. You declare all the services as Spring beans in a Spring configuration file. For Cloud Foundry services configuration the <a title="Cloud namespace" href="http://blog.springsource.org/2011/11/09/using-cloud-foundry-services-with-spring-applications-part-3-the-cloud-namespace/" target="_blank"><strong>cloud</strong></a> namespace is available. You need to add a Maven dependency to your pom file &#8211; <strong>cloudfoundry-runtime</strong> &#8211; to gain access to this namespace.</p>
<ul>
<li>&lt;cloud:data-source&gt;: A regular RDBMS dataservice available in CloudFoundry (MySQL database), can be injected into regular Spring beans;</li>
<li>&lt;cloud:redis-connection-factory&gt;: Redis application service;</li>
<li>&lt;cloud:mongo&gt;: MongDB application service.</li>
</ul>
<p>You can also make use of a very cool feature called <a title="Auto-reconfiguration" href="http://blog.springsource.org/2011/11/04/using-cloud-foundry-services-with-spring-part-2-auto-reconfiguration/" target="_blank"><strong>auto-reconfiguration</strong></a>. This lets you define a DataSource bean against a local MySQL database or a MongoDbFactory bean against a local MongoDB installation. Once you deploy an application which uses these beans to Cloud Foundry, auto-reconfiguration kicks in and reconfigures those beans to make use of a corresponding Cloud Foundry service.<br />
Furthermore, as of Spring 3.1, you can make use of so-called <a title="Spring profiles" href="http://blog.springsource.org/2011/11/10/using-cloud-foundry-services-with-spring-part-4-%E2%80%93-spring-profiles/" target="_blank"><strong>profiles</strong></a>. You can make a profile with specific service configurations for example for local, testing and cloud deployment. So, when you&#8217;re developing you use the <em>local</em> profile and when you&#8217;re ready for deployment into the cloud you can switch to the cloud profile.</p>
<h3>NoSQL</h3>
<p>NoSQL databases are an alternative for traditional relational databases.RDBMS databases like MySQL, Oracle, etc. have been around for quite a while. Chris mentions a couple of problems related to RDBMS databases:</p>
<ul>
<li>ORM mismatch, it&#8217;s not always easy to map a relational schema to an object oriented model;</li>
<li>Difficult to handle semistructured data;</li>
<li>Difficult to scale;</li>
<li>Poor performance for some use cases.</li>
</ul>
<p>These are some of the problems that led to the rise of NoSQL databases in the past. NoSQL databases offer high performance, high scalability, a richer datamodel and are schema less. This comes at a price. Chris mentions a few of the drawbacks of NoSQL:</p>
<ul>
<li>Limited support for transactions;</li>
<li>Relaxed consistency;</li>
<li>Unconstrained data.</li>
</ul>
<p>As you can see, it depends on the use case, which database to choose. For most use cases RDBMS database are a good choice, but for some specific use cases, NoSQL databases are a way better alternative, eg. when performance is much more important than highly consistent data.</p>
<p>After this introductory talk of NoSQL, two of the more popular NoSQL databases are discussed, Redis and MongoDB. They are both available in Cloud Foundry and can be easily integrated into Spring applications via Spring Templates.</p>
<h4>Redis</h4>
<p>Redis is a so called advanced Key-Value Store. It&#8217;s very fast, persistence is optional and it has support for transactions by the use of optimistic locking. It also supports Master-slave replication. Some of it&#8217;s use cases are as a storage for session state or for high performance queries.</p>
<h4>MongoDB</h4>
<p>MongoDB is a so called document-oriented database. It uses JSON-style documents for storage and retrieval. It&#8217;s fast, has a rich query layer and is highly available an scalable. MongoDB uses query by example.</p>
<h4>NoSQL in Spring</h4>
<p>Spring offers a lot of goodies for integration with a NoSQL database:</p>
<ul>
<li>Template classes</li>
<li>Auto-generation of repositories</li>
<li>Java &lt;-&gt; NoSQL mapping</li>
<li>Cross-Store persistence</li>
<li>Roo Support (<a title="Spring Roo" href="http://www.springsource.org/spring-roo" target="_blank">Spring Roo</a> is a framework for generating Spring apps)</li>
</ul>
<p>For both MongoDB and Redis a Spring Template is available. Spring Templates are java classes that perform the role of an abstraction layer on top of a resource. Templates take away a lot of boilerplate code, transform checked into runtime exceptions and transform underlying errors into common exceptions (eg. when you use the JdbcTemplate, your exception will be same for a unique key violation regardless of whether you use a mysql database, or an Oracle database).</p>
<p>For Redis, the RedisTemplate, is available. Spring also offers Redis-backed collections, like the <em>DefaultRedisSet</em> Set. And there is also caching support via the @Cacheable annotation.</p>
<p>For MongoDB, there is a MongoTemplate available. For configuration purposes the <strong>mongo</strong> namespace is available.  Furthermore annotations are available to do Java &lt;-&gt; NoSQL mapping for MongoDB: @Document, @Id, @Indexed, etc. MongoDB can also leverage the power of the <a title="QueryDSL" href="http://blog.springsource.org/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/" target="_blank">QueryDSL</a> project. This project provides type-safe composeable queries.</p>
<h3>Spring Integration</h3>
<p>The last small part of the talk is about Spring Integration, and more specifically about the <a title="AMQP" href="http://www.amqp.org/" target="_blank">Advanced Message Queueing Protocol</a> (AMQP) and SpringSource&#8217;s implementation <a title="RabbitMQ" href="http://www.rabbitmq.com/" target="_blank">RabbitMQ</a>.</p>
<p>AMQP is a protocol for message-oriented middleware. Messaging can be used to decouple systems. AMQP is based on open standards, has clustering support, supports transactions, flow control and error handling, to name but a few of it&#8217;s features.</p>
<p>RabbitMQ is an implementation of AMQP and is available as an application service in Cloud Foundry. Configuration of RabbitMQ in Cloud Foundry can be done via the following Spring Bean:</p>
<ul>
<li>cloud:rabbit-connection-factory</li>
</ul>
<p>Spring also has two template classes available for use:</p>
<ul>
<li>AmqpTemplate</li>
<li>RabbitTemplate</li>
</ul>
<h3>Conclusion</h3>
<p>This talk clearly proved that Cloud Foundry integrates smoothly with Spring applications. So when you&#8217;re already building your enterprise applications with Spring, you should definitely consider Cloud Foundry as your PAAS of choice. Cloud Foundry lacks a JEE Server, so for real JEE applications it&#8217;s less suitable. For most web applications though, a TomCat server will be sufficient. The choices of programming languages and frameworks in Cloud Foundry should suit a lot of web developers. It&#8217;s also great that they added support for an RDBMS database as well as some popular NoSQL databases. And last but not least, the Micro Cloud feature should be a great way to do some experimenting and gain a good insight on what the product has to offer. I for one can&#8217;t wait to play a little with it.</p>
<p>The NoSQL integration in Spring is also neatly done. I like the way Spring abstracts all external resources by way of Templates. It&#8217;s uniformly done, reliefs the developer of a lot of boilerplate coding and provides a unified way of dealing with exceptions. A lot of NoSQL databases are supported this way. Also the Java &lt;-&gt; NoSQL mapping available for MongoDB should appeal to a lot of programmers familiar with JPA providers like Hibernate.</p>
<h3>References</h3>
<ul>
<li><a title="Spring in the cloud" href="http://www.slideshare.net/ewolff/spring-in-the-cloud" target="_blank">Spring in the Cloud Slides (not from the Devoxx talk)</a></li>
<li><a title="vmc getting started guide" href="http://support.cloudfoundry.com/entries/20012337-getting-started-guide-command-line-vmc-users" target="_blank">vmc getting started guide</a></li>
<li><a title="SpringSource blogs" href="http://blog.springsource.com/" target="_blank">SpringSource blog</a>s</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2011/11/24/devoxx-2011-spring-into-the-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx 2011 &#8211; Building Next-generation Enterprise Applications in Java a.k.a. Duke’s Duct Tape Adventures</title>
		<link>http://blog.whitehorses.nl/2011/11/20/devoxx-2011-jee6/</link>
		<comments>http://blog.whitehorses.nl/2011/11/20/devoxx-2011-jee6/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 19:18:25 +0000</pubDate>
		<dc:creator>Roger Goossens</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[devox2011]]></category>
		<category><![CDATA[jee6]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2433</guid>
		<description><![CDATA[Devoxx 2011 kicks off with a very impressive demo-based talk on jee6. In a time span of approx. 4 hrs Paul Bakker and Bert Ertman hack together a small enterprise CRUD application showing a lot of the new features present in jee6. And foremost demonstrating how easy it is to quickly set up such an [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Devoxx 2011 kicks off with a very impressive demo-based talk on <strong>jee6</strong>. In a time span of approx. 4 hrs Paul Bakker and Bert Ertman hack together a small enterprise CRUD application showing a lot of the new features present in jee6. And foremost demonstrating how easy it is to quickly set up such an app in jee6. Granted, they use a couple of additional tools to accomplish this feat, but nonetheless, the end result is a plain jee6 web app, easily portable across different application servers and adhering to the jee6 specs.</p>
<h3>The application</h3>
<p>The application being built, is a Duct Tape Store. It&#8217;s a simple online web store. A user can log in, browse through the store inventory, put items in a shopping basket and eventually purchase the items. The application is build in an agile manner. Bert tells Paul which features he wants, Paul builds them on the spot, then Bert adds additional feature requirements, which Paul again adds to the application, and so forth.<br />
One of the key aspects of the application is that it&#8217;s build according to a layered design. A higher layer can only call code that&#8217;s in the layer directly below, and a layer can never call code in a higher layer. Delegation to a lower layer is achieved via Dependency Injection. There are basically 5 layers in the demo application:</p>
<ul>
<li>Presentation &#8211; implemented by JSF &amp; facelets</li>
<li>Navigation &#8211; implemented by Named Beans</li>
<li>Business Logic &#8211; implemented by Enterprise Java Beans</li>
<li>Data Access &#8211; implemented by JPA (this could also be a JAX-WS layer or a hybrid)</li>
<li>Data &#8211; MySQL (again as an alternative for a relation database, this could be a NoSQL database or even MQ)</li>
</ul>
<p>For fun, they throw in some AJAX, JMS and REST as well.</p>
<h3>Build tools</h3>
<p>Their build kit consists of the following tools:</p>
<ul>
<li>IntelliJ &#8211; IDE</li>
<li><a title="JBoss Forge" href="https://docs.jboss.org/author/display/FORGE/Home" target="_blank">JBoss Forge</a> &#8211; framework for rapid application jee6 development</li>
<li>Maven &#8211; build tool</li>
<li>Glassfish 3.1 &#8211; jee6 application server</li>
<li>MySQL &#8211; database</li>
<li><a title="Arquillian" href="http://www.jboss.org/arquillian" target="_blank">Arquillian</a> &#8211; framework for integration testing</li>
</ul>
<h3>The demo</h3>
<p>Let&#8217;s walk through some of the highlights of the demo. The complete source code is available on GitHub. A link to the code is available in the References section.</p>
<h4>Creating the basics</h4>
<p>Paul uses <strong>Jboss Forge</strong> to setup the skeleton of a new jee project:</p>
<pre class="brush: bash">new-project --named ducttape --topLevelPackage ducttape</pre>
<p>This creates a basic Maven project with a minimalistic pom file.</p>
<p>After this Paul again uses Forge to add the necessary JSF and CDI dependencies and files (<em>web.xml, faces-config.xml, beans.xml</em>).</p>
<p>He then adds a prebuilt <em>template.xhtml</em> file which will be the template file from which all other facelets will inherit and adds some resources (css, images) for styling.</p>
<p>Again with Forge persistence is setup using Hibernate as the JPA Provider.</p>
<pre class="brush: bash">persistence setup --provider HIBERNATE --container CUSTOM_JTA</pre>
<h4>Filling in the layers</h4>
<p>Using Forge an Entity <em>Product</em> is created in the data access layer, and using Hibernate this Entity is used to automatically create a database table <em>PRODUCT</em> in the mysql database:</p>
<pre class="brush: java">@Entity
public class Product</pre>
<p>In the Business Logic Layer an EJB named <em>ProductManager</em> is created for interacting with the data layer and doing CRUD operations on the PRODUCT table. For this an <em>EntityManager</em> is injected into the EJB to which the data access operations are delegated.</p>
<pre class="brush: java">@Stateless
public class ProductManager {
    @PersistenceContext
    EntityManager em;</pre>
<p>In the Navigation layer the <em>ProductsBean</em>, from where the UI will get his Product information, is created. It gets the following annotations:</p>
<pre class="brush: java">@RequestScoped
@Named
public class ProductsBean
    @Inject ProductManager productManager;</pre>
<p>The <strong>Named</strong> annotation enables the bean to be used via EL expression in the facelet pages. The <em>ProductManager</em> bean gets injected into the <em>ProductsBean</em> so the <em>ProductBean</em> can delegate Data Access tasks to the Business Logic layer:</p>
<p>Finally in the UI layer the ProductsBean is being injected using EL expressions:</p>
<pre class="brush: xml">&lt;h:dataTable value="#{productsBean.products}" var="product" id="products"&gt;
    &lt;h:column&gt;
        &lt;f:facet name="header"&gt;Name&lt;/f:facet&gt;
        #{product.name}
    &lt;/h:column&gt;
&lt;/h:dataTable&gt;</pre>
<p>In the above example the <em>getProducts</em> method is called on the <em>ProductsBean</em>, which spills out a List of Products.</p>
<h4>Extending the basics</h4>
<p>After the basics some more advanced features are added to the application:</p>
<ul>
<li>The Criteria API is used for building some type-safe queries in the beans in the Business Logic Layer;</li>
<li>A TestDataInserter class is created (using @Singleton and @Startup annotations) with a @PostConstruct method that inserts the testdata;</li>
<li>A JUnit test class is created with a @RunWith(Arquillian.class) annotation to make use of Arquillian for doing some integration testing;</li>
<li>Sorting on displayed colums is implemented using a request parameter, which also makes the JSF sorted page bookmarkable;</li>
<li>Ajax is added on a search text field to do some filtering on the product list (&lt;f:ajax event=&#8221;keyup&#8221; render=&#8221;products&#8221;/&gt;);</li>
<li>A @ConversationScoped <em>ShoppingBasket</em> class is added. The <em>ShoppingBasket</em> bean will be alive as long as the Conversation it belongs to, is alive. The lifecycle of this Conversation is handled programmatically via an @Injected Conversation class;</li>
<li>Bean Validation is added to the <em>Customer</em> entity. Hibernate Validator is used for this, which adds some extra validation Annotations, like @NotEmpy and @Email;</li>
<li>The use of Events is demonstrated. In the Producer class an Event class of a specific type (Generic) is injected, which can then be fired in one of the methods. The Consumer classes use the @Observes annotation on the method that can handle the typed Event .</li>
<li>The Injected event as well as the Method that consumes it can be annotated with a qualifier annotation, so events of the same type can be handled selectively.</li>
<li>A method can handle an event asynchronously by annotating it with @Asynchronous;</li>
<li>Using JAX-RS annotation a class is turned into a Rest Service, which can return a List of Product in XML and/or JSON.</li>
</ul>
<p>For more information regarding the implementations, check out the source code in the References section.</p>
<h3>Conclusion</h3>
<p>All in all this was a very impressive demo showing a lot of the powerful features of jee6. With the help of the new CDI annotations it&#8217;s very easy to setup a layered application. Also worthy of note are Arquillian and Forge. Theey are definitely productivity and quality boosters and i highly recommend in every jee6 project.</p>
<h3>References</h3>
<ul>
<li><a title="Building Next-Generation Enterprise Applications in Java" href="http://www.slideshare.net/ertmanb/devoxx-building-nextgeneration-enterprise-applications-in-java" target="_blank">The slides</a></li>
<li><a title="Demo source code" href="https://github.com/paulbakker/ducttape" target="_blank">Demo source code on github</a></li>
<li><a title="Jee 6 Refcard" href="http://refcardz.dzone.com/refcardz/java-enterprise-edition-6-most" target="_blank">Jee 6 Refcard</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2011/11/20/devoxx-2011-jee6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with popups in ADF</title>
		<link>http://blog.whitehorses.nl/2011/06/14/working-with-popups-in-adf/</link>
		<comments>http://blog.whitehorses.nl/2011/06/14/working-with-popups-in-adf/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 10:19:50 +0000</pubDate>
		<dc:creator>Marcel Maas</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Oracle platform]]></category>
		<category><![CDATA[adf]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Popup]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2165</guid>
		<description><![CDATA[Popups, ADF and browsers is the name of the game in this post. I&#8217;ve been developing ADF 11g web applications for some time now and I&#8217;ve been running into some issues while working with popups. While the popup mechanism in ADF is easy enough to understand and quite powerful, it has some quirks. This mainly [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Popups, <strong>ADF</strong> and browsers is the name of the game in this post. I&#8217;ve been developing ADF 11g web applications for some time now and I&#8217;ve been running into some issues while working with popups. While the popup mechanism in ADF is easy enough to understand and quite powerful, it has some quirks. This mainly has to do with showing and hiding them.  In this post I will show the various way&#8217;s to show and hide popups and what the advantages and disadvantages would be.</p>
<p>Firstly the way we create a popup. This is always the same. We create a &#8220;popup&#8221; element somewhere in the parent containers page.  Inside this element we can define the contents of the popup. This could be anything. If we would like to perform an action after we are done with the dialog we can use the &#8220;dialog&#8221; element to specify the actions and display the button&#8217;s to initiate these actions.</p>
<p>The hierarchical tree would look like this then:</p>
<pre class="brush: xml">&lt;!--- pseudoXML --&gt;
&lt;af:popup&gt;
   &lt;af:dialog&gt;
      [contents]
   &lt;/af:dialog&gt;
&lt;/af:popup&gt;</pre>
<p>It might be handy to understand how exactly this popup is being rendered runtime. Essentially the popup is created and exists as soon as you create the page. It is simply hidden so it won&#8217;t bother you. So if you have a syntax error in your popup display code this error wil manifest itself when the parent page is being loaded, not when you show the popup. Because you usually want to display the popup without getting a full page refresh the popup will be shown and hidden by using javascript.</p>
<p>So how to interact with the popup?</p>
<p><strong>1. From the JSF page</strong></p>
<p>Showing the popup can be done by using the &#8220;showPopupBehavior&#8221; element. You create this element as the child of a component that can perform an action, like a button</p>
<pre class="brush: xml">&lt;!--- pseudoXML --&gt;
&lt;af:commandToolbarButton&gt;
   &lt;af:showPopupBehavior /&gt;
&lt;/af:commandToolbarButton&gt;</pre>
<p>You can use this element to specify which popup needs to be shown and you can set some additional properties to specify where. For example if you set the &#8220;alignId&#8221; to the id of the button the popup will be shown over this button. If you want even more control you can set &#8220;align&#8221; property to control if the popup is show before, after, etc.. the button. Don&#8217;t forget to set the triggertype property. (in our case to &#8220;click&#8221;) Or else the popup will not be shown.</p>
<p>Closing the popup is done automatically when you use the &#8220;dialog&#8221; element and one of it&#8217;s buttons is clicked. Now there is another thing you can do using this element. You can perform actions based on which button was clicked. An example:</p>
<p>You have a dialog of the type &#8220;okCancel&#8221; . This means the popup will get two addtional buttons. One for &#8220;Ok&#8221; and one for &#8220;Cancel&#8221;. If we want to do something when one of the buttons is clicked we set the &#8220;dialogListener&#8221;. This must be a function in a backing bean with a parameter of the type &#8220;DialogEvent&#8221;. Here is how this function could look like:</p>
<pre class="brush: java">public void onDialogClose(DialogEvent dialogEvent) {
    if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.ok)) {
       // do Ok things
    }
}</pre>
<p><strong>2. From Backing Bean code</strong></p>
<p>Now there are situations where you do not want to react on a button but a different kind of event. In those cases it might be handy to be able to show a popup from backing bean code. This might pose for some difficulities since backing beans usually run server-side and not client-side (and that&#8217;s where the javascript is). Before 11g you had to jump through some hoops to get the job done.  You had to find the current JSF context, then initiate a render kit to provide a pathway to the javascript and eventually inject javascript for the popup to show.</p>
<p>Like so:</p>
<pre class="brush: java">FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
service.addScript(context, "var popup = AdfPage.PAGE.findComponent('"+DIALOG_CLIENT_ID+"'); popup."+action+"();");
AdfFacesContext.getCurrentInstance().addPartialTarget(dialog);</pre>
<p>In the example above the &#8220;DIALOG_CLIENT_ID&#8221; is the id of the popup and the &#8220;action&#8221; is &#8220;show&#8221; or &#8220;hide&#8221;. The bad news is that the above works in older versions of Internet Explorer, but it fails to close the popup in other browsers such as Firefox. The effect is that when using this code and Firefox it will freeze your screen when trying to close (hide) the popup. You can do nothing but to refresh the page and lose all context.</p>
<p>Now on for the good news:</p>
<p>In 11g there is a function that does the work for you and does so equally well in all browsers I have tested. (Firefox, Chrome and IE)</p>
<p>The code for showing and hiding is as follows:</p>
<pre class="brush: java">if (action.equals("show")){
  RichPopup.PopupHints ph = new RichPopup.PopupHints();
  popup.show(ph);
} else {
  popup.hide();
}</pre>
<p>In the above case &#8220;popup&#8221; is in instance of RichPopup which can be bound from the JSF page or looked up using its context. The &#8220;PopupHints&#8221; essentially do the same as the &#8220;showPopupBehaviour&#8221;. You specify which popup you want to show and provide an alignment if neccesary. Hiding the popup is now as simple as calling &#8220;hide()&#8221; on the object.</p>
<p><strong>So to recap and conclude</strong>:</p>
<p>When working with popups in adf 11g, try to use the &#8220;popup&#8221;, &#8220;dialog&#8221; and &#8220;showPopupBehaviour&#8221; elements. When it is impossible to do so, use the &#8220;popup&#8221;, &#8220;dialog&#8221; and the &#8220;popupHints&#8221; to controll a popup from your backing beans. In all cases try to avoid the use of the renderkit to inject javascript since this code is dependant on the javascript engine of the browser.</p>
<p>Thats all for now! Happy coding!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2011/06/14/working-with-popups-in-adf/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Connecting to a NTLM Web Service using a Java Servlet</title>
		<link>http://blog.whitehorses.nl/2011/01/23/using-a-servlet-to-connect-to-ntlm-web-service/</link>
		<comments>http://blog.whitehorses.nl/2011/01/23/using-a-servlet-to-connect-to-ntlm-web-service/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 12:23:34 +0000</pubDate>
		<dc:creator>Jos Nieuwenhuis</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Integration, SOA & BPM]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[httpclient]]></category>
		<category><![CDATA[httpcomponents]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[ntlm]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2040</guid>
		<description><![CDATA[This blog post explains about using a servlet which converts HTTP calls into HTTPS calls with NTLM. The servlet takes care of the NTLM handshake. I use it for connecting to an externally hosted webservice which uses NTLM authentication. This servlet functions as if it is a normal web service (without NTLM and HTTPS).]]></description>
			<content:encoded><![CDATA[<p></p><p>Connecting to a <strong>NTLM</strong> web service can be troublesome. This blog post shows the source code of a servlet which converts HTTP calls into HTTPS calls with NTLM. The servlet takes care of the NTLM handshake. </p>
<p>For a customer I needed to create a BPEL process which needed information from a web service that uses NTLM. There are many ways to solve this problem. My colleague used an Authenticator: <a href="http://biemond.blogspot.com/2009/04/jax-ws-web-service-proxy-client-and.html" target="_blank">JAX-WS web service proxy client and HTTP authentication</a>. I followed a different approach. I used the Apache HttpComponents libraries. The idea is to call a servlet as if it is the actual web service. It can be used from any application: e.g. BPEL process or soapUI. The application can be deployed on any servlet container, e.g. Apache Tomcat or OC4J.</p>
<p><img style="border: 0; margin: 0px;" src="http://blog.whitehorses.nl/wp-content/uploads/2011/01/ntlm-1.png" alt="NTLM Serlvlet" width="537" height="77" /></p>
<p>So, what is NTLM? NTLM is a Microsoft authentication protocol. Sometimes this protocol is used by applications delevoped using the Microsoft .Net Framework. The protocol involves a handshake in several steps. NTLM is a proprietary protocol, but it is fairly well documented. How to implement NTLM in a Java client? The answer is Apache HttpComponents. The latest version of Apache HttpComponents (version 4.1 GA) has full support for NTLMv1, NTLMv2, and NTLM2 Session authentication. </p>
<p>Since SOAP usually means sending XML over HTTP Post a Servlet can be used to handle these requests. There is no need to modify the contents of the HTTP Post Message. When handling a SOAP request, just remember to copy the HTTP Headers.</p>
<p>The servlet is part of a web application which contains only one class: <strong>NTLMProxyServlet</strong>. The libraries of Apache HttpComponents (version 4.1 GA) should be included in the war file. Do not forget to map an URL to the servlet in the deployment descriptor (web.xml).</p>
<p>The code of the doPost method of the class NTLMProxyServlet (implements HttpServlet) is shown below. Please replace the  hardcoded values for host, domain, user, url, password:</p>
<pre class="brush: java;">
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setCharacterEncoding("utf-8");
    PrintWriter out = response.getWriter();

    if(httpclient == null){
        httpclient = new DefaultHttpClient();
        httpclient.getAuthSchemes().register(
                "NTLM", new NTLMSchemeFactory());
        httpclient.getCredentialsProvider().setCredentials(
                new AuthScope("host", 443, "domain"),
                new NTCredentials("user", "password", "host", "domain"));
        httpclient.getParams().setParameter(
                CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);
        httpclient.getParams().setParameter(
                CoreProtocolPNames.PROTOCOL_VERSION,
                HttpVersion.HTTP_1_1);
        httpclient.getParams().setParameter(
                CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
    }

    HttpPost httppost = new HttpPost(
            "https://host/webservices/getdata.asmx");
    InputStream in = null;

    try {
        in = request.getInputStream();
        Writer writer = new StringWriter();
        char[] buffer = new char[1024];
        Reader reader = new BufferedReader(
                new InputStreamReader(in, "UTF-8"));
        int n;
        while ((n = reader.read(buffer)) != -1) {
            writer.write(buffer, 0, n);
        }
        httppost.setEntity(new StringEntity(writer.toString()));

        Enumeration headernames = request.getHeaderNames();
        while (headernames.hasMoreElements()) {
            String headerName = (String) headernames.nextElement();
            String headerValue = request.getHeader(headerName);
            httppost.setHeader(headerName, headerValue);
        }
        Header h1 = httppost.getFirstHeader(HTTP.CONTENT_LEN);
        if (h1 != null) {
            httppost.removeHeader(h1);
        }
        Header h2 = httppost.getFirstHeader(HTTP.TARGET_HOST);
        if (h2 != null) {
            httppost.removeHeader(h2);
        }
        httppost.setHeader(HTTP.TARGET_HOST, "host");

        HttpResponse httpresponse = httpclient.execute(
                new HttpHost("host", 443, "https"),
                httppost,
                new BasicHttpContext());
        HttpEntity output = httpresponse.getEntity();

        Header[] headers = httpresponse.getAllHeaders();

        for (Header header : headers) {
            if (!header.getName().equals(HTTP.CONTENT_LEN)) {
                response.setHeader(header.getName(),
                        header.getValue());
            }
        }

        if (output != null) {
            out.write(EntityUtils.toString(output));
        }
    } catch (Exception e) {
        e.printStackTrace(out);
    } finally {
        in.close();
        out.flush();
        out.close();
    }
}
private DefaultHttpClient httpclient = null;</pre>
<p>If the target server uses self-signed SSL certificates you might want to apply the code in <a href="http://theskeleton.wordpress.com/2010/07/24/avoiding-the-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated-with-httpclient/"  target="_blank">Avoiding the “javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated” with HttpClient</a>. </p>
<p>In order to use use the servlet make a local copy of the WSDL of the target web service and change the port address into the URL of the servlet, e.g.:</p>
<pre  class="brush: xml;">
&lt;wsdl:definitions&gt;
  [...]
  &lt;wsdl:service name="TargetWS"&gt;
    &lt;wsdl:port name="TargetWSSoap12" binding="tns:TargetWSSoap12"&gt;
      &lt;soap12:address location="http://localhost:8080/NTLMProxyApp/NTLMProxyServlet" /&gt;
    &lt;/wsdl:port&gt;
  &lt;/wsdl:service&gt;
&lt;/wsdl:definitions&gt;
</pre>
<p>Use this modified copy of the WSDL in your BPEL process of SoapUI project.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2011/01/23/using-a-servlet-to-connect-to-ntlm-web-service/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Oracle released Fusion MiddleWare 11g R1 Patch Set 3</title>
		<link>http://blog.whitehorses.nl/2011/01/16/oracle-released-fusion-middleware-11g-r1-patch-set-3/</link>
		<comments>http://blog.whitehorses.nl/2011/01/16/oracle-released-fusion-middleware-11g-r1-patch-set-3/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 20:12:06 +0000</pubDate>
		<dc:creator>Edwin Biemond</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Integration, SOA & BPM]]></category>
		<category><![CDATA[Oracle tools]]></category>
		<category><![CDATA[11g]]></category>
		<category><![CDATA[adf]]></category>
		<category><![CDATA[BPEL]]></category>
		<category><![CDATA[FMW]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Fusion Middleware]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[SOA Suite]]></category>
		<category><![CDATA[weblogic]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2054</guid>
		<description><![CDATA[Oracle starts 2011 very strong with a major release of FMW 11g Patch Set 3 (PS3). Officially this is a patch but Oracle always adds new functionality to a PS release. First, FMW PS3 is a full release and not a patch on PS1 and PS2. All the products can be directly installed on WebLogic 10.3.4. Big [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Oracle starts 2011 very strong with a major release of FMW 11g Patch Set 3 (PS3). Officially this is a patch but Oracle always adds new functionality to a PS release. First, FMW PS3 is a full release and not a patch on PS1 and PS2. All the products can be directly installed on WebLogic 10.3.4. Big High Five from the administrators and developers. In this post I will tell you the important new features and provide you the PS3 links so you can download or read more about this release.</p>
<p>I start with WebLogic, ADF , SOA Suite and OSB. At this time Oracle did not publish the new features and bugfixes of WebCenter (will be released later) &amp; BPM.</p>
<p><strong>WebLogic</strong>, Version = 10.3.4 and in this release Oracle provides a WebLogic Apache Maven Plug-in. This plugin allows you to perform deployment operations similar to those supported by the command-line utility. And in 10.3.4 WebLogic has support for JPA 2.0 Providers.</p>
<p><strong>ADF</strong>, with version 11.1.1.4.0 Oracle supports ADF on IBM WebSphere , Significant update to ADF Desktop Integration (Microsoft Excel Client) and Design-time support for <a href="http://biemond.blogspot.com/2011/01/adf-jmx-datacontrol-in-fmw-11g-ps3.html" target="_blank">creating JMX data controls</a>.</p>
<p><strong>SOA Suite</strong> version = 11.1.1.4.0 . The SOA Design plugin in JDeveloper now support BPEL 2.0, The BPEL editor in JDeveloper can generate BPEL 2.0 code and introduces several new activities. SOA Suite can now be run on IBM WebSphere Application Server. And the last is the single server do it all feature, previous called single domain (OSB in PS2 already supported this). This is so called developer release installs BPM, SOA , ADF and EM on one single WebLogic Server (The adminserver), this will reduce the required memory on 1 machine.</p>
<p><strong>OSB </strong> also version 11.1.1.4.0. Oracle Service Bus provides support for the Oracle JCA Adapter for Files/FTP , this feature is nice when you have to work with big files and works better then the native file transport with big files. HTTP transport has been enhanced to provide access to individual query parameters in the query string.</p>
<p><strong>Links</strong></p>
<ul>
<li><a href="http://download.oracle.com/docs/cd/E17904_01/web.1111/e13852/toc.htm" target="_blank">WebLogic 10.3.4 Release notes</a></li>
<li><a href="http://www.oracle.com/technetwork/developer-tools/jdev/index-088099.html" target="_blank">ADF Release notes</a></li>
<li><a href="http://www.oracle.com/technetwork/middleware/soasuite/documentation/soa-11gr1-ps3-new-features-258135.html" target="_blank">SOA Suite &amp; OSB Release notes</a></li>
<li><a href="http://download.oracle.com/docs/cd/E17904_01/index.htm" target="_blank">PS3 Documentation</a></li>
</ul>
<p>&nbsp;<br />
The download page is different then that of PS1 &amp; PS2. For PS3 Oracle made a new page with all the FMW products, here is the link <a href="http://www.oracle.com/technetwork/indexes/downloads/index.html" target="_blank">http://www.oracle.com/technetwork/indexes/downloads/index.html</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2011/01/16/oracle-released-fusion-middleware-11g-r1-patch-set-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx talk about Apache Camel &#8211; Claus Ibsen</title>
		<link>http://blog.whitehorses.nl/2010/11/19/devoxx-talk-about-apache-camel-claus-ibsen/</link>
		<comments>http://blog.whitehorses.nl/2010/11/19/devoxx-talk-about-apache-camel-claus-ibsen/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 17:03:39 +0000</pubDate>
		<dc:creator>Jos Nieuwenhuis</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Camel]]></category>
		<category><![CDATA[Devoxx]]></category>
		<category><![CDATA[devoxx 2010]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2011</guid>
		<description><![CDATA[Apache Camel is an open source integration framework that implemented the patterns which are mentioned in the  book Enterprise Integration Patterns. Some many people say this book is the bible in the integration space. According to Claus Ibsen the Camel framework let's you focus on the business problem. Source code can be written in such a way that everybody can read and understand it.]]></description>
			<content:encoded><![CDATA[<p></p><p>Apache Camel is an open source integration framework that implemented the patterns which are mentioned in the  book Enterprise Integration Patterns. Some many people say this book is the bible in the integration space. According to Claus Ibsen the Camel framework lets you focus on the business problem. Source code can be written in such a way that everybody (&#8216;even your boss&#8217;) can read and understand it. Example code:</p>
<pre class="brush: java;">from("queue:a").filter(header("foo").isEqualTo("bar")).to("queue:b");
from("queue:c").choice()
    .when(header("foo").isEqualTo("bar")).to("queue:d")
    .when(header("foo").isEqualTo("cheese")).to("queue:e")
    .otherwise().to("queue:f");
</pre>
<p>Apache Camel has no container dependency and is payload agnostic. Camel is just a library. You do not need to use Spring in order to use Camel. It provides a Developer Web Console in which you can edit Routes. Soon a visual tool called FuseSource Rider will be available. Other features include a fully asynchronous non-blocking routing engine, which facilitates high scalability.</p>
<p>Camel offers a few ways of error handling: ErrorHandlers like the DeadLetterChannelErrorHandler or using the doTry and doCatch methods:</p>
<pre class="brush: java;">from("direct:start")
     .doTry()
        .process(new ProcessorFail())
        .to("mock:result")
    .doCatch(IOException.class)
        .handled(false)
        .to("mock:io")
    .doCatch(Exception.class)
        .to("mock:error")
    .end();
</pre>
<p>A great article on Camel: <a href="http://architects.dzone.com/articles/apache-camel-integration" target="_blank">architects.dzone.com/articles/apache-camel-integration</a></p>
<p>Quick Reference card of Camel: <a href="http://cheat-sheets.biz/saved-copy/rc047-010d-enterprise_integration_patterns_1.pdf" target="_blank">cheat-sheets.biz/saved-copy/rc047-010d-enterprise_integration_patterns_1.pdf</a></p>
<p>Claus Ibsen&#8217;s blog: <a href="http://davsclaus.blogspot.com/ target="_blank"">davsclaus.blogspot.com.</a></p>
<p>In December 2010 Manning will release the book Camel in Action, written by Claus Ibsen.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2010/11/19/devoxx-talk-about-apache-camel-claus-ibsen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx talk about HTML5 &#8211; Nathaniel Schutta</title>
		<link>http://blog.whitehorses.nl/2010/11/19/devoxx-talk-about-html5-nathaniel-schutta/</link>
		<comments>http://blog.whitehorses.nl/2010/11/19/devoxx-talk-about-html5-nathaniel-schutta/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 05:54:32 +0000</pubDate>
		<dc:creator>Jos Nieuwenhuis</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Devoxx]]></category>
		<category><![CDATA[devoxx 2010]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=2002</guid>
		<description><![CDATA[HTML was never really designed to do what it is doing: Applications. HTML5 is going to change that. HTML5 is a collection of features  which will enable us to build applications.]]></description>
			<content:encoded><![CDATA[<p></p><p><strong> </strong>HTML was never really designed to do what it is doing: Applications. HTML5 is going to change that. HTML5 is a collection of features  which will enable us to build applications.</p>
<p>It seems that Adobe Flash will disappear. Applications like YouTube are moving away from flash video.</p>
<p>With HTML5, instead of trying to figure out which browser is being used, feature detection should be used. <a href="http://www.modernizr.com/" target="_blank">Modernizr</a> can be used to do this. If you would like to check the HTML5 features of your current browser you can use the website <a href="http://www.findmebyip.com" target="_blank">www.findmebyip.com</a>.</p>
<p>In HTML5 there will be many input new types: for phone numbers, search, date pickers, etcetera. These input provides functionality like form validation of the input. If the browser does not support the input type the input type will be defaulted to &#8220;text&#8221;.</p>
<p>We have been abusing cookies for a long time. HTML5 offers offline support. The web application is able to cache the data. This is a huge step forward. Other great features of HTML5: multithreaded Javascript support in the background using Web Workers; gradient support, video. Video is not a plugin, but part of the page, so it is possible to style, spin, and drop shadows.</p>
<p>HTML5 resources:</p>
<ul>
<li><a href="http://html5demos.com/" target="_blank">html5demos.com</a></li>
<li><a href="http://diveintohtml5.org/" target="_blank">diveintohtml5.org</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2010/11/19/devoxx-talk-about-html5-nathaniel-schutta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx talk about HK2 &#8211; Jerome Dochez</title>
		<link>http://blog.whitehorses.nl/2010/11/18/devoxx-talk-about-hk2-jerome-dochez/</link>
		<comments>http://blog.whitehorses.nl/2010/11/18/devoxx-talk-about-hk2-jerome-dochez/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 06:41:16 +0000</pubDate>
		<dc:creator>Jos Nieuwenhuis</dc:creator>
				<category><![CDATA[Enterprise Java]]></category>
		<category><![CDATA[Devoxx]]></category>
		<category><![CDATA[devoxx 2010]]></category>
		<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[hk2]]></category>
		<category><![CDATA[weblogic]]></category>

		<guid isPermaLink="false">http://blog.whitehorses.nl/?p=1996</guid>
		<description><![CDATA[HK2 is the library used in Glassfish for doing the lookup and instantiation of modules (and all the depending modules). It wraps the OSGi implementation, which can be Felix or Equinox. The OSGi is wrapped because OSGi itself is too complex. The HK2 has a service based architecture. In the modules annotations @Service, @Contract, and @Inject are used. Services are components with a scope.]]></description>
			<content:encoded><![CDATA[<p></p><p>HK2 is the library used in Glassfish for doing the lookup and instantiation of modules (and all the depending modules). It wraps the OSGi implementation, which can be Felix or Equinox. The OSGi is wrapped because OSGi itself is too complex. The HK2 has a service based architecture. In the modules annotations @Service, @Contract, and @Inject are used. Services are components with a scope. No class-loader is actually created until a service is actually requested. HK2 is open source: <a href="http://hk2.dev.java.net/" target="_blank">hk2.dev.java.net</a></p>
<p>HK2 is the base of Glassfish and will also be part of WebLogic Server. Glassfish and WebLogic AS have different purposes. According to the speaker the two will co-exist. Glassfish is an application server with a very fast startup-time and loads modules lazily. It is very useful  for developers, because it facilitates changes in source code. You can keep Glassfish running while changing the source code. WebLogic Server is different, because it wants to load many modules at startup. It is more suitable for deploying components in a controlled manner. The lifecycle (runtime states) in WebLogic Server is more sophisticated than the one used by Glassfish.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whitehorses.nl/2010/11/18/devoxx-talk-about-hk2-jerome-dochez/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

