<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>Mathew's Thoughts</title><updated>2010-03-18T06:31:45Z</updated><id>http://blogs.averconsulting.com/atom.aspx</id><link href="http://blogs.averconsulting.com/atom.aspx" rel="self" type="application/rss+xml" /><link href="http://blogs.averconsulting.com" rel="alternate" type="application/rss+xml" /><generator uri="http://app.onlinequickblog.com/" version="2.0">Quick Blogcast</generator><entry><title>Virtual Appliances</title><link rel="alternate" href="http://blogs.averconsulting.com/2010/01/26/virtual-appliances.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2010-01-26:54b9523a-38b4-4735-a3c6-12cae8b0bd1c</id><author><name>Mathew Thomas</name></author><category term="Virtual Appliances" /><updated>2010-01-27T02:17:00Z</updated><published>2010-01-27T02:17:00Z</published><content type="html">Recently I had to review a product which was being offered as a Virtual Appliance. This was the first time I had come across something like this. Pretty soon I was "googling" around to understand this better. &lt;br&gt;&lt;br&gt;A virtual appliance is a pre-built, pre-configured virtual machine that has an OS, the application and other supporting software all packaged together and ready to go. All you do is to use a product such as VMWare Fusion/Player or Sun VirtualBox to play the appliance and viola you have a running product. I downloaded a Wordpress Virtual Appliance from &lt;a href="http://www.turnkeylinux.org/wordpress"&gt;http://www.turnkeylinux.org/wordpress&lt;/a&gt;. Turnkey has many other appliances at &lt;a href="http://www.turnkeylinux.org/"&gt;http://www.turnkeylinux.org/&lt;/a&gt;&lt;div&gt; &lt;/div&gt;&lt;br&gt;I have both VMWare Fusion and Sun VirtualBox on my Mac. Next I either open the appliance in VMWare or Import the appliance in VirtualBox. In a few minutes I had the VM ready and the Wordpress application working like a champ. In my excitement to play with this toy i installed appliances for bugzilla and drupal. The simplicity of this is what amazed me.&lt;br&gt;&lt;br&gt;I find this approach of delivering software very innovative. It drastically simplifies the administrative tasks required to setup an application. I do not know how efficient this modal is in real work use, but frankly I don't care &lt;img src="http://blogs.averconsulting.com/emoticons/smile.png" border="0"&gt; its just too elegant. &lt;br&gt;&lt;br&gt;Too learn more about Virtual Appliances check &lt;a href="http://www.vmware.com/appliances/getting-started/learn/overview.html"&gt;http://www.vmware.com/appliances/getting-started/learn/overview.html &lt;br&gt;&lt;/a&gt;&lt;div&gt; &lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div&gt; &lt;/div&gt;</content><summary>Recently I had to review a product which was being offered as a Virtual Appliance. This was the first time I had come across something like this. Pretty soon I was "googling" around to understand
this better. </summary></entry><entry><title>JEE  - The Road Ahead with JEE 6</title><link rel="alternate" href="http://blogs.averconsulting.com/2010/01/03/the-road-ahead-jee-6.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2010-01-03:98f5dcb8-c801-4b59-b313-d9200d4ecfd0</id><author><name>Mathew Thomas</name></author><category term="JEE J2EE" /><updated>2010-01-03T15:38:00Z</updated><published>2010-01-03T15:38:00Z</published><content type="html">Prior to JEE 5 , the JEE/J2EE platform did not go down that well across the developer community. As software evolves and new ideas flow in, it was only natural that JEE 6 would refine and become a better platform. &lt;br&gt;&lt;br&gt;Spring Framework came into being partly due to the complexity ofJ2EE. But today SF itself is getting large. SF gave you an abstraction on existing frameworks and made it easier to wire different technologies together. But as the complexities in JEE are addressed you have to start thinking if SF is an overkill. OK I did not exactly mean to say that but you need to think about it.&lt;br&gt;&lt;br&gt;Below are a few notable items from JEE 6 (I do not go into the merits of each nor do I list every new feature):&lt;br&gt;&lt;ul&gt;&lt;li&gt;Context &amp;amp; Dependency Injection (CDI). This allows for any POJO to be injected into dependent classes. Right now you have the ability to inject container managed resources (such as connection pools, EJB's). You cannot inject regular POJO objects. JEE6 adds that ability. &lt;/li&gt;&lt;li&gt;CDI - Introduces annotations such as &lt;br&gt;&lt;ul&gt;&lt;li&gt;@ManagedBean - Identifies a bean as a container managed bean.&lt;/li&gt;&lt;li&gt;@Model identifies a model object in a MVC architecture.&lt;/li&gt;&lt;li&gt;@*Scope annotations such as @SessionScoped which tie an instance of a bean to a scope such as request, session or application.&lt;/li&gt;&lt;li&gt;@Inject is used to inject managed beans into other dependent classes.&lt;/li&gt;&lt;li&gt;...and so on...&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;CDI allows session beans to be used in place of JSF beans (influenced from Seam obviously). This means you can use session beans in your JSF EL expressions.&lt;/li&gt;&lt;li&gt;Bean Validations: Set of annotations to apply on java objects so that the validations can be shared between UI and backend tier.&lt;/li&gt;&lt;li&gt;Eliminate web.xml with new annotations such as @WebServlet, @WebFilter , etc.&lt;/li&gt;&lt;li&gt;Ability of servlets to respond to asynchronous requests (AJAX). This could greatly simplify the existing mechanisms on the server to handle such requests. Having the servlets take over this allows for more efficient use of server threads vs existing implementations.&lt;/li&gt;&lt;li&gt;Introducing the concept of web fragments. Basically separate web.xml files so that appropriate frameworks can be configured in their own files.&lt;/li&gt;&lt;li&gt;JSF 2.0 (includes annotations that let you eliminate the faces-config.xml file, AJAX support, facelets).&lt;/li&gt;&lt;li&gt;Simplication of EJB in 3.1 (no requirement for business interfaces, singleton beans, asyhnchronous session beans)&lt;/li&gt;&lt;li&gt;Concept of Profiles to differentiate between different configurations or stacks of JEE...similar to J2ME .See my article on J2ME at&amp;nbsp;&lt;div&gt;&lt;a target="_blank" href="http://my.advisor.com/doc/12697"&gt;http://my.advisor.com/doc/12697&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;Ability to package EJBs as part of the WAR file.&lt;/li&gt;&lt;li&gt;Inclusion of JAX-RS into the JEE spec (&lt;a href="http://blogs.averconsulting.com/2009/05/02/rest-with-jaxrs.aspx"&gt;REST with JAX-RS&lt;/a&gt;).&lt;/li&gt;&lt;li&gt;Support for JPA 2.0 (notably to me is the inclusion of a Criteria API...such as the one in Hibernate).&lt;/li&gt;&lt;/ul&gt;While a lot of things have been added into JEE 6, I do not see any NEW path-breaking changes (except for the asynch servlet invocation). Seems to me JEE is playing catch-up with innovations in other OS frameworks (such a Spring,hibernate,etc). &lt;br&gt;&lt;br&gt;In conclusion - I wonder where the next set of innovations will come from and what form they will take. I like that Spring has introduced "Spring Integration". This should allow applications to efficiently handle common integration patterns. &lt;br&gt;</content><summary>Prior to JEE 5 , the JEE/J2EE platform did not go down that well across the developer community. As software evolves and new ideas flow in, it was only natural that JEE 6 would refine and become a better platform.</summary></entry><entry><title>Is Axis2 way too complicated for web apps?</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/12/10/is-axis2-way-too-complicated-for-web-apps.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-12-10:4c926d9f-e57b-4e6f-9b55-2b0a9277f3d1</id><author><name>Mathew Thomas</name></author><updated>2009-12-11T03:24:00Z</updated><published>2009-12-11T03:24:00Z</published><content type="html">I recently had the pleasure of using Axis2 on a Web Application. For reasons I cannot go into here, we were unable to use my original choice SpringWS. We were using Spring so it would have been a piece of cake to expose a document style web service using SpringWS. &lt;br&gt;&lt;br&gt;When I finally got my application modified to use Axis2 to expose the web service, the final result was not pretty. In Axis2 you have to create the following in your WEB-INF&lt;br&gt;&lt;br&gt;WEB-INF&lt;br&gt;&amp;nbsp;&amp;nbsp; - services\&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; services.list (list of aar file names ... one on each line)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; service1.aar&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; service2.aar&lt;br&gt;&amp;nbsp; - modules\&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modules.list  (list of aar file names ... one on each line)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; module1.aar&lt;br&gt;&amp;nbsp; - conf\&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; axis2. xml&lt;br&gt;&lt;br&gt;Each aar file contains in my case&lt;br&gt;&amp;nbsp; service1.aar&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - META-INF\&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; service.xml (this actually contains the service configuration for service1)&lt;br&gt;&lt;br&gt;service.aar is a jar that contains your service configuration and any libraries that you may choose to include. In my case all libraries were in web--inf/lib. If you need to implement custom handlers (as was my case) you have to create modules and the corresponding module.aar file. If you want your handler to take effect you need to then pull out the axis2.xml file from the axis jar file, modify it to include your handler then put it into web-inf/conf&lt;br&gt;&lt;br&gt;All this to even expose a simple secure hello world. I always wondered why Spring documentation did not cover integrating Spring with Axis2. Now I know. This is way too complicated !&amp;nbsp; Those who read this and say deploy as .jws , that wont work for me. Maybe it does for you.&lt;br&gt;</content><summary>Is Axis2 way too complicated for web apps? </summary></entry><entry><title>Apache CXF - Simple WebService With Spring</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/10/07/apache-cxf--simple-webservice-with-spring.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-10-07:0922f690-5e79-4673-a681-f495144817ed</id><author><name>Mathew Thomas</name></author><category term="Apache CXF Spring Web Services" /><updated>2009-10-08T03:02:00Z</updated><published>2009-10-08T03:02:00Z</published><content type="html">A reader posted a comment to one of my &lt;a href="http://blogs.averconsulting.com/2007/05/07/xfire-webservice-with-spring.aspx"&gt;old blogs on XFire.&lt;/a&gt; That rekindled my interest so I checked the XFire web site only to be informed that XFire is now Apache CXF (version 2.2.3 at this moment in time).&lt;br&gt;&lt;br&gt;So how hard would it be to convert my old example to CXF. Turned out to be a piece of cake. Had to change the following:&lt;br&gt;&lt;ol&gt;&lt;li&gt;Updated the maven dependencies to reflect CXF libraries.&lt;/li&gt;&lt;li&gt;web.xml - to point to the CXF Servlet&lt;/li&gt;&lt;li&gt;Spring context (app-context.xml) - It was now a lot simpler and cleaner.&lt;/li&gt;&lt;li&gt;Finally I used CXF wsdl2java utils to generate a client &lt;/li&gt;&lt;/ol&gt;Maven pom.xml&lt;br&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;code&gt;&amp;lt;project&amp;gt;&lt;br&gt;    &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;&lt;br&gt;    &amp;lt;groupId&amp;gt;com.aver&amp;lt;/groupId&amp;gt;&lt;br&gt;    &amp;lt;artifactId&amp;gt;echo&amp;lt;/artifactId&amp;gt;&lt;br&gt;    &amp;lt;packaging&amp;gt;war&amp;lt;/packaging&amp;gt;&lt;br&gt;    &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;&lt;br&gt;    &amp;lt;name&amp;gt;CXF Echo Service&amp;lt;/name&amp;gt;&lt;br&gt;    &amp;lt;dependencies&amp;gt;&lt;br&gt;        &amp;lt;dependency&amp;gt;&lt;br&gt;            &amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;&lt;br&gt;            &amp;lt;artifactId&amp;gt;spring&amp;lt;/artifactId&amp;gt;&lt;br&gt;            &amp;lt;version&amp;gt;2.5.6&amp;lt;/version&amp;gt;&lt;br&gt;        &amp;lt;/dependency&amp;gt;&lt;br&gt;&lt;br&gt;        &amp;lt;dependency&amp;gt;&lt;br&gt;            &amp;lt;groupId&amp;gt;org.apache.cxf&amp;lt;/groupId&amp;gt;&lt;br&gt;            &amp;lt;artifactId&amp;gt;cxf-rt-frontend-jaxws&amp;lt;/artifactId&amp;gt;&lt;br&gt;            &amp;lt;version&amp;gt;2.2.3&amp;lt;/version&amp;gt;&lt;br&gt;        &amp;lt;/dependency&amp;gt;&lt;br&gt;        &amp;lt;dependency&amp;gt;&lt;br&gt;            &amp;lt;groupId&amp;gt;org.apache.cxf&amp;lt;/groupId&amp;gt;&lt;br&gt;            &amp;lt;artifactId&amp;gt;cxf-rt-transports-http&amp;lt;/artifactId&amp;gt;&lt;br&gt;            &amp;lt;version&amp;gt;2.2.3&amp;lt;/version&amp;gt;&lt;br&gt;        &amp;lt;/dependency&amp;gt;&lt;br&gt;&lt;br&gt;        &amp;lt;dependency&amp;gt;&lt;br&gt;            &amp;lt;groupId&amp;gt;junit&amp;lt;/groupId&amp;gt;&lt;br&gt;            &amp;lt;artifactId&amp;gt;junit&amp;lt;/artifactId&amp;gt;&lt;br&gt;            &amp;lt;version&amp;gt;4.7&amp;lt;/version&amp;gt;&lt;br&gt;            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;br&gt;        &amp;lt;/dependency&amp;gt;&lt;br&gt;&lt;br&gt;        &amp;lt;dependency&amp;gt;&lt;br&gt;            &amp;lt;groupId&amp;gt;log4j&amp;lt;/groupId&amp;gt;&lt;br&gt;            &amp;lt;artifactId&amp;gt;log4j&amp;lt;/artifactId&amp;gt;&lt;br&gt;            &amp;lt;version&amp;gt;1.2.14&amp;lt;/version&amp;gt;&lt;br&gt;        &amp;lt;/dependency&amp;gt;&lt;br&gt;    &amp;lt;/dependencies&amp;gt;&lt;br&gt;&lt;br&gt;    &amp;lt;build&amp;gt;&lt;br&gt;        &amp;lt;plugins&amp;gt;&lt;br&gt;            &amp;lt;plugin&amp;gt;&lt;br&gt;                &amp;lt;groupId&amp;gt;org.mortbay.jetty&amp;lt;/groupId&amp;gt;&lt;br&gt;                &amp;lt;artifactId&amp;gt;maven-jetty-plugin&amp;lt;/artifactId&amp;gt;&lt;br&gt;                &amp;lt;configuration&amp;gt;&lt;br&gt;                    &amp;lt;contextPath&amp;gt;/echoservice&amp;lt;/contextPath&amp;gt;&lt;br&gt;                    &amp;lt;connectors&amp;gt;&lt;br&gt;                        &amp;lt;connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"&amp;gt;&lt;br&gt;                            &amp;lt;port&amp;gt;9090&amp;lt;/port&amp;gt;&lt;br&gt;                            &amp;lt;maxIdleTime&amp;gt;60000&amp;lt;/maxIdleTime&amp;gt;&lt;br&gt;                        &amp;lt;/connector&amp;gt;&lt;br&gt;                    &amp;lt;/connectors&amp;gt;&lt;br&gt;                &amp;lt;/configuration&amp;gt;&lt;br&gt;            &amp;lt;/plugin&amp;gt;&lt;br&gt;            &amp;lt;plugin&amp;gt;&lt;br&gt;                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;&lt;br&gt;                &amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;&lt;br&gt;                &amp;lt;configuration&amp;gt;&lt;br&gt;                    &amp;lt;source&amp;gt;1.5&amp;lt;/source&amp;gt;&lt;br&gt;                    &amp;lt;target&amp;gt;1.5&amp;lt;/target&amp;gt;&lt;br&gt;                &amp;lt;/configuration&amp;gt;&lt;br&gt;            &amp;lt;/plugin&amp;gt;&lt;br&gt;        &amp;lt;/plugins&amp;gt;&lt;br&gt;    &amp;lt;/build&amp;gt;&lt;br&gt;&amp;lt;/project&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;The web.xml...&lt;br&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;code&gt;&amp;lt;web-app&amp;gt;&lt;br&gt;    &amp;lt;context-param&amp;gt;&lt;br&gt;        &amp;lt;param-name&amp;gt;contextConfigLocation&amp;lt;/param-name&amp;gt;&lt;br&gt;        &amp;lt;param-value&amp;gt;&lt;br&gt;            /WEB-INF/app-context.xml&lt;br&gt;        &amp;lt;/param-value&amp;gt;&lt;br&gt;    &amp;lt;/context-param&amp;gt;&lt;br&gt;&lt;br&gt;    &amp;lt;listener&amp;gt;&lt;br&gt;        &amp;lt;listener-class&amp;gt;&lt;br&gt;            org.springframework.web.context.ContextLoaderListener&lt;br&gt;        &amp;lt;/listener-class&amp;gt;&lt;br&gt;    &amp;lt;/listener&amp;gt;&lt;br&gt;&lt;br&gt;    &amp;lt;servlet&amp;gt;&lt;br&gt;        &amp;lt;servlet-name&amp;gt;CXFServlet&amp;lt;/servlet-name&amp;gt;&lt;br&gt;        &amp;lt;servlet-class&amp;gt;&lt;br&gt;            org.apache.cxf.transport.servlet.CXFServlet&lt;br&gt;        &amp;lt;/servlet-class&amp;gt;&lt;br&gt;    &amp;lt;/servlet&amp;gt;&lt;br&gt;    &amp;lt;servlet-mapping&amp;gt;&lt;br&gt;        &amp;lt;servlet-name&amp;gt;CXFServlet&amp;lt;/servlet-name&amp;gt;&lt;br&gt;        &amp;lt;url-pattern&amp;gt;/services/*&amp;lt;/url-pattern&amp;gt;&lt;br&gt;    &amp;lt;/servlet-mapping&amp;gt;&lt;br&gt;&amp;lt;/web-app&amp;gt;&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;The Spring context file - app-context.xml&lt;br&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br&gt;&amp;lt;beans xmlns="http://www.springframework.org/schema/beans"&lt;br&gt;    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"&lt;br&gt;    xsi:schemaLocation="http://www.springframework.org/schema/beans &lt;a href="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd%3Cbr%3E"&gt;www.springframework.org/schema/beans/spring-beans-2.0.xsd&lt;br&gt;&lt;/a&gt;    &lt;a href="http://cxf.apache.org/jaxws"&gt;cxf.apache.org/jaxws&lt;/a&gt; &lt;a href="http://cxf.apache.org/schemas/jaxws.xsd" &amp;gt;=""&gt;&lt;br&gt;&lt;br&gt;"&amp;gt;cxf.apache.org/schemas/jaxws.xsd"&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/a&gt;    &amp;lt;import resource="classpath:META-INF/cxf/cxf.xml" /&amp;gt;&lt;br&gt;    &amp;lt;import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /&amp;gt;&lt;br&gt;    &amp;lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml" /&amp;gt;&lt;br&gt;&lt;br&gt;    &amp;lt;jaxws:endpoint id="echoService" implementor="#echo"&lt;br&gt;        address="/EchoService" /&amp;gt;&lt;br&gt;&lt;br&gt;    &amp;lt;bean id="echo" class="com.aver.EchoServiceImpl" /&amp;gt;&lt;br&gt;&amp;lt;/beans&lt;/code&gt;&lt;/pre&gt;The wsdl2java command I executed was:&lt;br&gt;&lt;br&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;code&gt;./wsdl2java -p com.aver.client -client &lt;a href="http://localhost:9090/echoservice/services/EchoService?wsdl%3Cbr%3E%3C/code%3E%3C/pre%3E"&gt;localhost:9090/echoservice/services/EchoService?wsdl&lt;br&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;Run the project using maven: mvn clean package jetty:run&lt;br&gt;The WSDL is located at the address mentioned above in the wsld2java command.&lt;br&gt;&lt;br&gt;Finally I ran the test client that wsdl2java generated...class named EchoService_EchoServicePort_Client&lt;br&gt;&lt;br&gt;The output was:&lt;br&gt;&lt;blockquote&gt;&lt;em&gt;Invoking echo...&lt;/em&gt;&lt;br&gt;&lt;em&gt;echo.result=echo: 'uyy ' received on 10-07-2009 10:53:59 PM&lt;/em&gt;&lt;br&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;a href="http://blogs.averconsulting.com/files/26522-25187/cxf.zip"&gt;Click here&lt;/a&gt; to download the maven project for this blog. &lt;/div&gt;&lt;br&gt;</content><summary>A reader posted a comment to one of my old blogs on XFire. That rekindled my interest so I checked the XFire web site only to be informed that XFire is now Apache CXF (version 2.2.3 at this moment in time).</summary></entry><entry><title>Spring Batch 2.0</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/09/24/spring-batch-20--part-i.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-09-24:9903b52e-6969-4700-81c9-42083d65f4bd</id><author><name>Mathew Thomas</name></author><category term="Spring" /><updated>2009-09-25T01:12:51Z</updated><published>2009-09-25T01:12:51Z</published><content type="html">Previously I had written a 3 part series on Spring Batch 1.x. Since then Spring 2.x has been released and I promised myself (and one reader) that I would get to updating my previous articles to reflect the new release.&lt;br&gt;&lt;br&gt;Rather than create new articles I have updated the previous 3 articles with the changes made in 2.x.&lt;br&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;a href="http://blogs.averconsulting.com/2009/01/31/spring-batch--part-i-2.aspx"&gt;Spring Batch - Part I&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;a href="http://blogs.averconsulting.com/2009/02/03/spring-batch--part-ii.aspx"&gt;Spring Batch - Part II - Flat File To Database&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;a href="http://blogs.averconsulting.com/2009/02/03/spring-batch--part-iii--from-database-to-flat-file.aspx"&gt;Spring Batch - Part III - From Database to Flat File&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;Happy reading!&lt;br&gt;</content><summary>Previously I had written a 3 part series on Spring Batch 1.x. Since then Spring 2.x has been released and I promised myself (and one reader) that I would get to updating my previous articles to reflect the new release.</summary></entry><entry><title>Comet , HTML 5 Web Sockets and Server Sent Events (SSE)</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/08/21/html5-web-sockets.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-08-21:9eca520c-f71b-4da9-a6bc-1710fd2c6233</id><author><name>Mathew Thomas</name></author><category term="Web" /><updated>2009-08-22T01:00:00Z</updated><published>2009-08-22T01:00:00Z</published><content type="html">There has always been a need to support UI's that constantly update themselves as new data becomes available on the server. THe implementation for this falls into two general categories: either client side polling or server side push.&lt;br&gt;&lt;br&gt;Comet is the term that is often used to describe current Client side polling and server side push techniques. Lets delve briefly into what the techniques are and then move to HTML 5 Server Sent Events and WebSockets. &lt;em&gt;Check out &lt;a href="http://cometdproject.dojotoolkit.org/"&gt;Cometd&lt;/a&gt; for an implementation that you can try out. Cometd implements the &lt;a href="http://svn.cometd.com/trunk/bayeux/bayeux.html"&gt;Bayeux&lt;/a&gt; spec. Implementations are available in multiple languages.&lt;/em&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Comet Techniques&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;&lt;strong&gt;&lt;br&gt;Client Side Polling&lt;/strong&gt;&lt;br&gt;Client periodically polls the server for new data and updates the UI as the data becomes available. The benefit of this is in its sheer simplicity. Downside is that for medium to high volume sites we introduce too many useless round trips to the server.&amp;nbsp; From an architectural point of view if your volumes are relatively low this may be the right solution for you.&lt;br&gt;&lt;br&gt;&lt;strong&gt;Client Side Polling - Long Polling&lt;/strong&gt;&lt;br&gt;Slight variation from the previous ones. The client makes a call to the server for data. The server can hold onto the connection for some period of time. When data becomes available it is sent back and the connection is closed. If no data is available for a predefined time then the connection can be closed too. Once the connection is closed a new one is created and the process continues on. The obvious advantage of this is that we do not keep opening and closing too many connections from the client side.&lt;br&gt;&lt;br&gt;&lt;strong&gt;Server Side Push&lt;/strong&gt;&lt;br&gt;The idea here is for the server to push data updates to the client rather than the client polling the server for updates. In this data exchange pattern the client opens a connection to the server for which the server responds but the client does not close the connection. The client is in a continuous read mode on the connection. Whenever the server has data it sends it back within JavaScript &amp;lt;script&amp;gt; tags. Due to the way the browser renders incoming data, any JavaScript is executed which is how we can call our callback function in the client to render the updates.&lt;br&gt;&lt;br&gt;If you want full duplex communication between client and server then two connections are required. One for the client-to-server communications and the other for the server-to-client communications. With browsers often supporting up to two connections for a server this can be a big limitation. So you need to use this approach carefully. Otherwise you can run into some interesting problems. &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;HTML 5&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;&lt;strong&gt;&lt;br&gt;HTML 5 Server Sent Events (SSE)&lt;/strong&gt;&lt;br&gt;SSE standardizes the Comet styles of communication between client and server. It adds a new DOM element and the following new tag to support it.&lt;br&gt;&lt;br&gt;&lt;em&gt;&amp;lt;eventsource src="http://myserver/dosomething" onmessage="alert(event.data)"&amp;gt;&lt;/em&gt; &lt;br&gt;&lt;br&gt;There is also a programmatic way to create this.&lt;br&gt;&lt;em&gt;var es = document.createElement(”eventsource”); &lt;br&gt;es.addEventListener(”message”, callbackmethod, false); &lt;br&gt;es.addEventSource(”http://myserver/dosomething” ); &lt;br&gt;document.body.appendChild(es);&lt;/em&gt;&lt;br&gt;&lt;br&gt;Once the server has data it will stream it to the call back method registered above. As per the spec the events have a reconnection time. The browsers should check with the server for data updates once the reconnection time has elapsed.&lt;br&gt;&lt;br&gt;&lt;strong&gt;HTML 5 Web Sockets&lt;/strong&gt;&lt;br&gt;Web Sockets allow for full-duplex communication over a single connection and the API is exposed via JavaScript. The API is quite simple as can be seen from the example below:&lt;br&gt;&lt;br&gt;&lt;em&gt;var myconn = new WebSocket("ws://myserver/something");&lt;br&gt;myconn.onopen = function(event) {&amp;nbsp; }&lt;br&gt;myconn.postMessage("my message");&lt;br&gt;myconn.onread = function(event) { // u can read event.data) }&lt;br&gt;myconn.onclose = function(event) { }&lt;/em&gt;&lt;br&gt;&lt;br&gt;The above is quite self explanatory. ws:// stands for web socket connection and wss:// represents the secure connection.&lt;br&gt;&lt;br&gt;Web Socket implementations are not yet out there. That is especially the case with HTML 5 still not being official yet. Hopefully in the coming months we will have more widespread support for this. Remember for this to work there needs to be support on the browser as well as the web server.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;_uacct = "UA-1164071-1";urchinTracker();&lt;/script&gt;</content><summary>In the AJAX world of today and in the past there has always been a need to support UI's that constantly update themselves as new data becomes available on the server.</summary></entry><entry><title>Adobe Flex - Part  2</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/07/22/adobe-flex--part--2.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-07-22:6d956355-a450-4869-a51b-15e2a5b91585</id><author><name>Mathew Thomas</name></author><category term="Flex" /><updated>2009-07-22T20:18:00Z</updated><published>2009-07-22T20:18:00Z</published><content type="html">  &lt;link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"&gt;  &lt;link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;  &lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script type="text/javascript"&gt;SyntaxHighlighter.config.bloggerMode = true;SyntaxHighlighter.ClipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.287/scripts/clipboard.swf';SyntaxHighlighter.all();  &lt;/script&gt;I modified the previous Flex example app to implement the following:&lt;br&gt;&lt;ul&gt;  &lt;li&gt;Separated out related code into different physical files.&lt;/li&gt;  &lt;li&gt;Created the src/components folder to hold reusable UI components in their respective .mxml files.&amp;nbsp;&lt;/li&gt;  &lt;li&gt;Created a new Class called Movie (file name Movie.as) in a package named dto. This class will hold the values of our grid properties. We will load the XML into instances of this class and collect them in a ArrayCollection.&lt;/li&gt;  &lt;li&gt;Finally we use some validators in our form to validate that both movie name and rating are entered. Unless entered (as valid) the Add Movie button will NOT be enabled.&lt;/li&gt;&lt;/ul&gt;To create a reusable component&amp;nbsp; right click on the src folder in Flex Builder and create a new Flex Component. Put the code in there(minus the mx:Application) and voila you have a reusable component.When you read the code notice how parameters are defined in the component files and then passed in from the root SecondFlexApp.mxml file.&lt;br&gt;Here is the new version of the SecondFlexApp.mxml file...&lt;br&gt;

&lt;pre class="brush: xml"&gt;
&amp;lt;?xml version="1.0"?&gt;
&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="components.*" initialize="initApp()"&gt;

   &amp;lt;mx:Script&gt;
		&amp;lt;![CDATA[
			import dto.Movie;
			import mx.controls.Alert;
			import mx.collections.ArrayCollection;
		

            [Bindable]
            public var movieList:ArrayCollection;

            public var moviexml:XML = 
		      &amp;lt;movies&gt;
			       &amp;lt;movie&gt;
				     &amp;lt;name&gt;Angels &amp;amp; Demons&amp;lt;/name&gt;
				     &amp;lt;rating&gt;1&amp;lt;/rating&gt;
				   &amp;lt;/movie&gt;
				   &amp;lt;movie&gt;
				     &amp;lt;name&gt;Ice Age 3&amp;lt;/name&gt;
				     &amp;lt;rating&gt;2&amp;lt;/rating&gt;
				   &amp;lt;/movie&gt;
				   &amp;lt;movie&gt;
				     &amp;lt;name&gt;Transformers: Revenge of the Fallen&amp;lt;/name&gt;
				     &amp;lt;rating&gt;3&amp;lt;/rating&gt;
				   &amp;lt;/movie&gt;
		      &amp;lt;/movies&gt;;	
      		
            public function initApp():void {
                movieList = new ArrayCollection(); 
                for each (var movie:XML in moviexml.movie) {
                    var mv:Movie = new Movie();
                    mv.name = movie.name;
                    mv.rating = movie.rating;
                    movieList.addItem(mv);
                }
                movieGrid.initApp();
            }
       ]]&gt;
	&amp;lt;/mx:Script&gt;	
	

	&amp;lt;mx:VBox width="50%"&gt;
	   &amp;lt;mx:Label color="blue" text="Movies I have seen..."/&gt;
	   &amp;lt;comp:MovieGrid id="movieGrid" movieList="{movieList}" width="100%"/&gt;
	   &amp;lt;comp:addmovieform movieList="{movieGrid.movieList}"/&gt;
	&amp;lt;/mx:VBox&gt;
		
&amp;lt;/mx:Application&gt;        
&lt;/pre&gt;
&lt;br&gt;&lt;ul&gt;  &lt;li&gt;The new xmlns:comp namespace which refers to the components folder (components.* allows us to refer to all components in the src/components folder.&lt;/li&gt;  &lt;li&gt;We pass in references to values in the&amp;nbsp;&lt;span style="font-style: italic;"&gt;mx:VBox&lt;/span&gt; such as in &lt;span style="font-style: italic;"&gt;comp:MovieGrid&lt;/span&gt; we pass in the movieXML parameter into the component.&lt;/li&gt;  &lt;li&gt;The &lt;span style="font-style: italic;"&gt;mx:VBox&lt;/span&gt;is a layout container that places components vertically (there is an&amp;nbsp;&lt;span style="font-style: italic;"&gt;mx:HBox&lt;/span&gt; too if you want).&lt;/li&gt;  &lt;li&gt;In the initApp method I iterate through the XML , create Movie instances and add them to the movieList ArrayCollection.&lt;/li&gt;&lt;/ul&gt;The Movie class is:&lt;br&gt;
&lt;pre class="brush: java"&gt;
package dto {
	public class Movie {
		public var name:String;
		public var rating:Number;
		
		public function Movie() {
		}
	}
}
&lt;/pre&gt;

&lt;br&gt;&lt;strong&gt;&lt;br&gt;The complete Flex Archive can be downloaded here&lt;a href="http://blogs.averconsulting.com/files/26522-25187/secondflexapp.zip"&gt; secondflexapp.zip&lt;/a&gt;&lt;/strong&gt;&lt;div&gt; &lt;/div&gt;&lt;br&gt;&lt;br&gt;The running app with validation ON looks like this...&lt;br&gt;&lt;img src="http://images.quickblogcast.com/26522-25187/secondflexapp_1.jpg"&gt;&lt;div&gt; &lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;_uacct = "UA-1164071-1";urchinTracker();&lt;/script&gt;</content><summary>Organize Flex code into separate files, create custom components, create custom class and use validators to validate form elements.</summary></entry><entry><title>Adobe Flex - Part 1</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/07/22/adobe-flex.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-07-22:caf6f8ea-b801-43d2-b035-4dcf2e29589c</id><author><name>Mathew Thomas</name></author><category term="Flex" /><updated>2009-07-22T12:20:00Z</updated><published>2009-07-22T12:20:00Z</published><content type="html"> &lt;link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"&gt;  &lt;link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;  &lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script type="text/javascript"&gt;SyntaxHighlighter.config.bloggerMode = true;SyntaxHighlighter.ClipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.287/scripts/clipboard.swf';SyntaxHighlighter.all();  &lt;/script&gt;Adobe Flex is a framework/sdk provided by Adobe that allows us to build rich internet applications (RIA) using Flash as the underlying technology. &lt;br&gt;&lt;br&gt;Web designers have been using Flash to design apps for the web for a longtime. But the approach to designing with Flash directly is not that conducive to mainstream application development. Thus Flex was created. Flex provides a programming platform which is more easily understood by application developers as compared to Flash. Flex uses two programming languages to achieve this. &lt;br&gt;&lt;br&gt;&lt;strong&gt;MXML &lt;/strong&gt;- is an XML based programming model to define your UI layout.&lt;br&gt;&lt;strong&gt;ActionScript &lt;/strong&gt;- is an implementation of ECMAScript (javascript2.0)&lt;br&gt;&lt;br&gt;While MXML is used to define the UI elements, ActionScript is used to put in the behavior logic. This allows us to separate UI vs controller code. Let us run through an example to get a quick intro. This example is a little more involved than a standard hello but simple nevertheless.&lt;br&gt;&lt;br&gt;Applications coded in Flash or Flex are executed in the browser using the Flash Player. There is another runtime called the AIR which is used to execute the applications outside of the browser as standalone desktop applications. Which one you use will depend on your application needs. For this tutorial we will use the browser to run the applications.&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;What You Need to Install&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;Flex 3 downloads are available from &lt;a href="http://www.adobe.com/products/flex/flexdownloads/"&gt;http://www.adobe.com/products/flex/flexdownloads/.&lt;/a&gt;&lt;div&gt; &lt;/div&gt;&lt;br&gt;You can download the Flex SDK free of charge. But then you would have to use the command line or some other editor to code the application. Instead I would strongly recommend you download the trial version of Flex Builder 3 Eclipse Plugin. If you have an existing eclipse setup then installing the plugin is the preferred way. After 30 days you have to buy this product. I personally feel that Adobe has priced the product too high&amp;nbsp; for regular developers and I hope they provide a free version for development soon.&lt;br&gt;&lt;br&gt;I also suggest going through the tutorial at&amp;nbsp;&lt;a href="http://www.adobe.com/devnet/flex/videotraining/"&gt;http://www.adobe.com/devnet/flex/videotraining/&lt;/a&gt;. I found this very useful and strongly recommend it for folks new to Flex.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Whatis the App?&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;The application is your personal movie tracker. It shows a grid with a list of movies you have watched and what rating you gave them. You can delete movies from the Grid or add new movies to the grid using a simple form.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Creatinga Basic Project&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;Once the Flex Builder3 plugin has been installed open up the Flex Debugging perspective and you should see something like this:&lt;br&gt;&lt;img alt="aa" src="http://images.quickblogcast.com/26522-25187/firstflexapp_1.jpg"&gt;&lt;br&gt;&lt;br&gt;Now create&amp;nbsp; new Flex project and name it 'FirstFlexApp'. This will create a project with the following structure:&lt;br&gt;&lt;img style="width: 338px; height: 335px;" alt="aaa" src="http://images.quickblogcast.com/26522-25187/firstflexapp_2.jpg"&gt;&lt;br&gt;&lt;br&gt;&lt;ul&gt;  &lt;li&gt;.actionScriptProperties, .flexProperties contain various Flex related configuration.&lt;/li&gt;  &lt;li&gt;.project is the Flex eclipse project configuration.&lt;/li&gt;  &lt;li&gt;By default Flex Builder created a FirstFlexApp.mxml file. This is what you will run to execute your application.&lt;/li&gt;&lt;/ul&gt;Even though we have MXML to code the UI layout, you must be aware that MXML is converted to ActionScript during compile time. So it is entirely possible to build your application using ONLY ActionScript. But it would make it much harder to do so. Our application MXML code starts with...&lt;br&gt;&lt;pre class="brush: xml"&gt;&amp;lt;?xmlversion="1.0"?&amp;gt;&lt;br&gt;&amp;lt;mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"creationComplete="initApp()"&amp;gt;&lt;br&gt;...&lt;br&gt;&amp;lt;/mx:Application&amp;gt;&lt;/pre&gt;&lt;br&gt;The creationComplete hook is optional. We use it here to call afunction which will retrieve the current movie list (as XML) and thenpopulate the grid with the contents. creationComplete is invoked afterthe layout has been prepared and displayed. There is another hookcalled initialize which can be used instead. initialize calls afunction before the UI is displayed.&lt;br&gt;&lt;br&gt;Next we add the initial XML data here as:&lt;br&gt;&lt;pre class="brush: xml"&gt;&amp;lt;mx:XMLList id="moviexml"&amp;gt;&lt;br&gt;   &amp;lt;movie&amp;gt;&lt;br&gt;     &amp;lt;name&amp;gt;Angels&amp;amp;Demons&amp;lt;/name&amp;gt;&lt;br&gt;     &amp;lt;rating&amp;gt;1&amp;lt;/rating&amp;gt;&lt;br&gt;   &amp;lt;/movie&amp;gt;&lt;br&gt;&lt;br&gt;   &amp;lt;movie&amp;gt;&lt;br&gt;     &amp;lt;name&amp;gt;Ice Age3&amp;lt;/name&amp;gt;&lt;br&gt;     &amp;lt;rating&amp;gt;2&amp;lt;/rating&amp;gt;&lt;br&gt;   &amp;lt;/movie&amp;gt;&lt;br&gt;&lt;br&gt;   &amp;lt;movie&amp;gt;&lt;br&gt;     &amp;lt;name&amp;gt;Transformers:Revenge of theFallen&amp;lt;/name&amp;gt;&lt;br&gt;     &amp;lt;rating&amp;gt;3&amp;lt;/rating&amp;gt;&lt;br&gt;   &amp;lt;/movie&amp;gt;&lt;br&gt;&amp;lt;/mx:XMLList&amp;gt;&lt;/pre&gt;&lt;br&gt;&lt;strong&gt;mx &lt;/strong&gt;- is the namespace used to identify the MXML elements. XMLLIst is an alias for a ActionScript class. Following that are various properties/methods that you want to configure for this class. In this case id is used to give a unique name to this instance of XMLList. Here we setup 3 movies. There are no remote calls in this tutorial to make things easier.&lt;br&gt;&lt;br&gt;Next here is the rest of the UI layout:&lt;br&gt;

&lt;pre class="brush: xml"&gt;
    &amp;lt;mx: Panel title="Movie List" height="100%" width="100%" 
        paddingTop="10" paddingLeft="10" paddingRight="10"&gt;

        &amp;lt;mx:Label width="100%" color="blue"
            text="Movies I have seen..."/&gt;

        &amp;lt;mx: DataGrid id="movieGrid" width="50%" height="50%" rowCount="4" resizableColumns="true" editable="false" &gt;
            &amp;lt;mx:columns&gt;
                &amp;lt;mx: DataGridColumn dataField="name" headerText="Name"/&gt;
                &amp;lt;mx: DataGridColumn dataField="rating" headerText="Rating" /&gt;
				&amp;lt;mx: DataGridColumn width="40" sortable="false" fontWeight="bold"&gt;
				    &amp;lt;mx:itemRenderer &gt;
						&amp;lt;mx:Component&gt;
                                                // refer to full listing for code here
						&amp;lt;/mx:Component&gt;  
				    &amp;lt;/mx:itemRenderer&gt;
				&amp;lt;/mx: DataGridColumn&gt;            
            &amp;lt;/mx:columns&gt;
        &amp;lt;/mx: DataGrid&gt;
        
        &amp;lt;mx: Panel width="359" height="170" layout="absolute"&gt;
            &amp;lt;mx:Label x="10" y="10" text="Movie Name:"/&gt;
            &amp;lt;mx:Label x="42" y="36" text="Rating:"/&gt;
            &amp;lt;mx:TextInput x="96" y="8" id="fldMovieName"/&gt;
            &amp;lt;mx:TextInput x="96" y="34" width="25" id="fldMovieRating" maxChars="1"/&gt;
            &amp;lt;mx:Button x="69" y="76" label="Add Movie" click="addMovie()"/&gt;
        &amp;lt;/mx: Panel&gt;
        
    &amp;lt;/mx: Panel&gt; 
&lt;/pre&gt;
We define a label and then a data grid to display the XML data. The &lt;em&gt;mx&lt;img src="http://blogs.averconsulting.com/emoticons/laugh.png" border="0"&gt;ataGridColumn&lt;/em&gt; is used to define the columns in this table. Our 3rd column is a special non-data column which will display an X symbol to delete a row. The code for that can be seen in the full listing at the end. You can also see the text form to enter new movies. The &lt;em&gt;mx:Button&lt;/em&gt; uses its click property to connect the click event to the &lt;em&gt;addMovie &lt;/em&gt;function.&lt;br&gt;&lt;br&gt;Finally here is the ActionScript code to bind the grid to the XML data.&lt;br&gt;

&lt;pre class="brush: xml"&gt;
&amp;lt;mx:Script&gt;
&amp;lt;![CDATA[
   import mx.collections.XMLListCollection;
   import mx.controls.Alert;


   [Bindable]
   private var movieList:XMLListCollection; 
            
   public function initApp():void {
      movieList = new XMLListCollection(moviexml); 
      movieGrid.dataProvider = movieList;
   }

   private function addMovie():void {	        	
      if ( fldMovieName.text == "" || fldMovieRating.text == "") {
         Alert.show("Enter valid values for movie and rating.","Alert");
      }
      else {
         movieList.addItem(
           &lt;movie&gt;
              &lt;name&gt;{fldMovieName.text}&lt;/name&gt;
              &lt;rating&gt;{fldMovieRating.text}&lt;/rating&gt;
           &lt;/movie&gt; );
      }
   }
]]&gt;
&amp;lt;/mx:Script&gt;
&lt;/pre&gt;

The sample above is quite self-explanatory. The initApp creates a XMLListCollection and references that to the movieGrid.dataProvider.&lt;br&gt;&lt;br&gt;Run the eclipse application and here what you will see in the browser:&lt;br&gt;&lt;img style="width: 848px; height: 543px;" alt="aaa" src="http://images.quickblogcast.com/26522-25187/firstflexapp_3.jpg"&gt;&lt;br&gt;&lt;br&gt;Click on &lt;a href="http://blogs.averconsulting.com/files/26522-25187/firstflexapp.zip"&gt;firstflexapp.zip&lt;/a&gt; to download the complete Flex Project Archive. You can export a Flex Archive by right clicking on the browser and performing an Export to Flex Archive (a zip file).&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;_uacct = "UA-1164071-1";urchinTracker();&lt;/script&gt;</content><summary>Adobe Flex is a framework/sdk provided by Adobe that allows us to build rich internet applications (RIA) using Flash as the underlying technology.</summary></entry><entry><title>Facelets</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/06/16/facelets.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-06-16:86670aa6-8498-4111-b99c-a5c168ca7358</id><author><name>Mathew Thomas</name></author><category term="JSF" /><updated>2009-06-16T23:34:00Z</updated><published>2009-06-16T23:34:00Z</published><content type="html">Facelets is a JSF framework to implement UI templating (like tiles,sitemesh). You can use Tiles to implement the templating portion but Facelets is built for JSF. &lt;br&gt;&lt;br&gt;In addition to the templating feature you can also create reusable components using Facelets and if you like Tapestry then you can make use of a similar feature with Facelets wherein rather than using jsf tags in the JSP you can use jsfc to indicate the component you plan to use. Example:&lt;br&gt;&lt;br&gt;&amp;lt;input type="text" jsfc="h:outputText" value="Printed using Using jsfc .. like Tapestry" /&amp;gt;&lt;br&gt;&lt;br&gt;Note:I put this example together quite some time back but forgot to publish this earlier. Now straight to an example. I assume a certain knowledge of JSF as required. If not sure you can download the complete working zip file and get an idea for yourself regarding JSF and Facelets.&lt;br&gt;&lt;br&gt;First of all you create the template.xhtml which will define the layoutfor our application:&lt;br&gt;&lt;table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"&gt;  &lt;tbody&gt;    &lt;tr&gt;      &lt;td&gt;&lt;small&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:h="http://java.sun.com/jsf/html"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:f="http://java.sun.com/jsf/core"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:ui="http://java.sun.com/jsf/facelets"&amp;gt;&lt;br&gt;&amp;lt;head&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;title&amp;gt;Test Faceletswebapp&amp;lt;/title&amp;gt;&lt;br&gt;&amp;lt;/head&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;lt;body&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;h3&amp;gt;&amp;lt;ui:insert name="title"&amp;gt;DefaultTitle&amp;lt;/ui:insert&amp;gt;&amp;lt;/h3&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;hr /&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;p&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ui:insert name="body"&amp;gt;Default Body&amp;lt;/ui:insert&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/p&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;br /&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;br /&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;hr /&amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/html&amp;gt;&lt;/small&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;The above illustrates a very basic example. In the zip file I do no use the above template, instead the zip file has more elaborate layout.&lt;br&gt;&lt;ul&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;ui:insert name="title"&amp;gt; &lt;/span&gt;: Creates a placeholder to drop page titles.&lt;/li&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;ui:insert name="body"&amp;gt;&lt;/span&gt; : Creates a placeholder to drop page content.&lt;/li&gt;&lt;/ul&gt;Now here is my content page index..xhtml:&lt;br&gt;&lt;table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"&gt;  &lt;tbody&gt;    &lt;tr&gt;      &lt;td&gt;&lt;small&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:ui="http://java.sun.com/jsf/facelets"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:h="http://java.sun.com/jsf/html"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:f="http://java.sun.com/jsf/core"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:t="http://myfaces.apache.org/tomahawk"&amp;gt;&lt;br&gt;&amp;lt;head&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;title&amp;gt;Notes&amp;lt;/title&amp;gt;&lt;br&gt;&amp;lt;/head&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;lt;body&amp;gt; &lt;br&gt;&amp;nbsp; &amp;lt;ui:composition template="/template.xhtml"&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ui:define name="title"&amp;gt;Facelet works&amp;lt;/ui:define&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This text will also not be displayed.&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ui:define name="body"&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;h:form&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;h:commandLink value="Display All Notes" action="toNotes"/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/h:form&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/ui:define&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/ui:composition&amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/html&amp;gt;&lt;/small&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;ul&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;ui:composition template="/template.xhtml"&amp;gt;&lt;/span&gt; : The composition tagis used to identify the template to be used for this page.&lt;/li&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;ui:define name="title"&amp;gt;&lt;/span&gt; : The ui:define tag is used here toinsert the page title&lt;/li&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;&amp;lt;ui:define name="body"&amp;gt;&lt;/span&gt; : The ui:define tag is used here toinsert the page contents.&lt;/li&gt;&lt;/ul&gt;The web.xml is:&lt;br&gt;&lt;table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"&gt;  &lt;tbody&gt;    &lt;tr&gt;      &lt;td&gt;&lt;small&gt;&amp;lt;?xml version="1.0"encoding="UTF-8"?&amp;gt;&lt;br&gt;&amp;lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xsi:schemaLocation="http://java.sun.com/xml/ns/javaee&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" &amp;gt;=""&gt;&lt;br&gt;"&amp;gt;java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&amp;gt;&lt;br&gt;&lt;/a&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;context-param&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;param-name&amp;gt;javax.faces.DEFAULT_SUFFIX&amp;lt;/param-name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;param-value&amp;gt;.xhtml&amp;lt;/param-value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/context-param&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;context-param&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;param-name&amp;gt;facelets.DEVELOPMENT&amp;lt;/param-name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/context-param&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-name&amp;gt;Faces Servlet&amp;lt;/servlet-name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-class&amp;gt;javax.faces.webapp.FacesServlet&amp;lt;/servlet-class&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/servlet&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-mapping&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-name&amp;gt;Faces Servlet&amp;lt;/servlet-name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;url-pattern&amp;gt;*.faces&amp;lt;/url-pattern&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/servlet-mapping&amp;gt;&lt;br&gt;&amp;lt;/web-app&amp;gt;&lt;/small&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;Finally the faces-config.xml:&lt;br&gt;&lt;table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"&gt;  &lt;tbody&gt;    &lt;tr&gt;      &lt;td&gt;&lt;small&gt;&amp;lt;?xml version="1.0"encoding="UTF-8"?&amp;gt;&lt;br&gt;&amp;lt;faces-config version="1.2"xmlns="http://java.sun.com/xml/ns/javaee"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xsi:schemaLocation="http://java.sun.com/xml/ns/javaeejava.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd" style="color:teal;"&amp;gt;&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;application&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;view-handler&amp;gt;com.sun.facelets.FaceletViewHandler&amp;lt;/view-handler&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/application&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;navigation-rule&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;from-view-id&amp;gt;/index.xhtml&amp;lt;/from-view-id&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;navigation-case&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;from-outcome&amp;gt;toNotes&amp;lt;/from-outcome&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;to-view-id&amp;gt;/notes.xhtml&amp;lt;/to-view-id&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/navigation-case&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/navigation-rule&amp;gt;&lt;br&gt;&amp;lt;/faces-config&amp;gt;&lt;/small&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;ul&gt;  &lt;li&gt;com.sun.facelets.FaceletViewHandler is the what does the templating magic.&lt;/li&gt;&lt;/ul&gt;Here is the screenshot of the home page:&lt;br&gt;&lt;img style="width: 910px; height: 738px;" alt="aa" src="http://images.quickblogcast.com/26522-25187/facelets1.jpg"&gt;&lt;br&gt;&lt;br&gt;Clicking on Display All Notes will take you to the notes.xhtml page which is another static page with different content.&lt;br&gt;&lt;img style="width: 910px; height: 738px;" alt="aaa" src="http://images.quickblogcast.com/26522-25187/facelets2.jpg"&gt;&lt;br&gt;&lt;br&gt;You can download the complete example by clicking here - &lt;a href="http://blogs.averconsulting.com/files/26522-25187/faceletss.zip"&gt;faceletss.zip&lt;/a&gt;. Having done all of this I must say though that SiteMesh still remains my favourite templating engine. Not sure if it will work with JSF though.

&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;_uacct = "UA-1164071-1";urchinTracker();&lt;/script&gt;</content><summary>Facelets is a JSF framework to implement UI templating (like tiles, sitemesh). You can use Tiles to implement the templating portion but Facelets is built for JSF.</summary></entry><entry><title>REST with JAX-RS</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/05/02/rest-with-jaxrs.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-05-02:ab572033-c115-4425-84c0-e01263eb90c7</id><author><name>Mathew Thomas</name></author><category term="WebServices" /><updated>2009-05-02T09:52:00Z</updated><published>2009-05-02T09:52:00Z</published><content type="html">REST (REpresentational State Transfer) is an architecture style that describes how to use the Web (HTTP) to access services. &lt;a href="http://jcp.org/en/jsr/detail?id=311"&gt;JAX-RS (JSR 311) &lt;/a&gt;isa Java API to support implementation/access of REST web services using Java. This style was first documented by &lt;a href="http://www.ics.uci.edu/%7Efielding/pubs/dissertation/rest_arch_style.htm"&gt;Ron Fielding&lt;/a&gt;.&lt;br&gt;&lt;br&gt;There will be times we use REST principles without even knowing that we use REST (that is a mouthful). Ever since HTTP came around the largest REST implementation is the web itself. &lt;br&gt;&lt;ul&gt;  &lt;li&gt;REST prescribes that all services be treated as resources that can be accessed via a URL. Thus the web is REstful. &lt;/li&gt;  &lt;li&gt;REST also requires the services to be stateless.&lt;/li&gt;  &lt;li&gt;REST does NOT describe any common data exchange formats. The producer and consumer are free to choose whatever format they can agree on.&lt;/li&gt;  &lt;li&gt;REST services in many cases are cacheable (though I think in many business cases it is not and thats just fine).&lt;/li&gt;  &lt;li&gt;REST is commonly used over HTTP (though since it is an architectural style one can use the same principles on any transport).&lt;/li&gt;&lt;/ul&gt;&lt;br&gt;Used over HTTP the following HTTP methods can be used:&lt;br&gt;&lt;ul&gt;  &lt;li&gt;GET to retrieve data.&lt;/li&gt;  &lt;li&gt;DELETE to delete.&lt;/li&gt;  &lt;li&gt;INSERT to add new data&lt;/li&gt;  &lt;li&gt;PUT to update data.&lt;/li&gt;&lt;/ul&gt;Now compare all of this to SOAP based web services where you use a WSDL to publish your interface, we have the SOAP envelope that carries the payload and can optionally provide many services such as transaction,security, addressing, etc (basically the WS-* nightmare). But often we just need to access a simple service without the need for all of the SOAP complexity.. That is where the RESTful architecture style comes in.&lt;br&gt;&lt;br&gt;On the Java side JAX-RS was introduced to provide a common API to implement/access REST based services in Java. &lt;a href="http://https://jersey.dev.java.net/"&gt;Jersey &lt;/a&gt;is the open source reference implementation of REST. Lets get to an example and see how this works. I will implement my usual time service. Call a service to get time of the day in XML, plain text or JSON format.&lt;br&gt;&lt;br&gt;In Eclipse create a dynamic web project. Here is my layout.&lt;br&gt;&lt;img style="width: 283px; height: 395px;" alt="a" src="http://images.quickblogcast.com/26522-25187/jaxrs_projlayout.jpg"&gt;&lt;br&gt;&lt;br&gt;Here is the web.xml...&lt;br&gt;&lt;table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"&gt;  &lt;tbody&gt;    &lt;tr&gt;      &lt;td&gt;&lt;small&gt;&amp;lt;?xml version="1.0"encoding="UTF-8"?&amp;gt;&lt;br&gt;&amp;lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns="http://java.sun.com/xml/ns/javaee"xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xsi:schemaLocation="http://java.sun.com/xml/ns/javaee&lt;a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;&lt;br&gt;"&amp;gt;java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&lt;br&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="WebApp_ID" version="2.5"&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;display-name&amp;gt;jaxrs&amp;lt;/display-name&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;servlet&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;display-name&amp;gt;jaxrs tryout&amp;lt;/display-name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-name&amp;gt;jaxrsservlet&amp;lt;/servlet-name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-class&amp;gt;com.sun.jersey.spi.container.servlet.ServletContainer&amp;lt;/servlet-class&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/servlet&amp;gt;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;servlet-mapping&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-name&amp;gt;jaxrsservlet&amp;lt;/servlet-name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;url-pattern&amp;gt;/services/*&amp;lt;/url-pattern&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/servlet-mapping&amp;gt;&lt;br&gt;&amp;lt;/web-app&amp;gt;&lt;/small&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;Here is the implementation of the TimeOfTheDayService.&amp;nbsp; I usethe JAX-WS annotations to configure various JAX-RS attributes.&lt;br&gt;&lt;table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"&gt;  &lt;tbody&gt;    &lt;tr&gt;      &lt;td&gt;&lt;small&gt;package com.tryout;&lt;br&gt;      &lt;br&gt;import java.text.SimpleDateFormat;&lt;br&gt;import java.util.Calendar;&lt;br&gt;import javax.ws.rs.GET;&lt;br&gt;import javax.ws.rs.Path;&lt;br&gt;import javax.ws.rs.PathParam;&lt;br&gt;import javax.ws.rs.Produces;&lt;br&gt;      &lt;br&gt;@Path("/timeoftheday")&lt;br&gt;public class TimeOfTheDayService {&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static String PATTERN = "MM.dd.yyyy HH:mm:ss";&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @GET&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Produces("text/plain")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Path("/asplaintext/{name}")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public String getTimeOfTheDay(@PathParam("name") String name) {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SimpleDateFormat df = new SimpleDateFormat(PATTERN);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return name + "-" + df.format(Calendar.getInstance().getTime());&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @GET&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Produces("application/xml")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Path("/asxml/{name}/")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Time getTimeOfTheDayInXML(@PathParam("name") String name) {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SimpleDateFormat df = new SimpleDateFormat(PATTERN);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Time t = new Time();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.setName(name);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.setTime(df.format(Calendar.getInstance().getTime()));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return t;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @GET&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Produces("application/json")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Path("/asjson/{name}/")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Time getTimeOfTheDayInJSON(@PathParam("name") String name) {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SimpleDateFormat df = new SimpleDateFormat(PATTERN);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Time t = new Time();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.setName(name);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.setTime(df.format(Calendar.getInstance().getTime()));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return t;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;/small&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;ul&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;@Path("/timeoftheday")    &lt;/span&gt;- Specifies the URI part for all the services in thisclass.&lt;/li&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;@GET&lt;/span&gt;- Used to annotate the read method.&lt;/li&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;@Produces("text/plain")&lt;/span&gt;- Marks the method as a producer of plain/text content.&lt;/li&gt;  &lt;li&gt;&lt;span style="font-style: italic;"&gt;@Path("/asjson/{name}/")    &lt;/span&gt;- Describes the specific method. The optional {name} describes in our case the parameter passed into this service method.&lt;/li&gt;&lt;/ul&gt;The URL to access the services would be one of:&lt;br&gt;&lt;ul&gt;  &lt;li&gt;http://localhost:8080/jaxrs/services/timeoftheday/asplaintext/mathew&lt;/li&gt;  &lt;li&gt;http://localhost:8080/jaxrs/services/timeoftheday/asxml/mathew&lt;/li&gt;  &lt;li&gt;http://localhost:8080/jaxrs/services/timeoftheday/asjson/mathew&lt;/li&gt;&lt;/ul&gt;The resource is identified via the URL and so is the parameter name inthis example.&lt;br&gt;&lt;br&gt;The Time javabean class is:&lt;br&gt;&lt;table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"&gt;  &lt;tbody&gt;    &lt;tr&gt;      &lt;td&gt;&lt;small&gt;package com.tryout;&lt;br&gt;      &lt;br&gt;import javax.xml.bind.annotation.XmlElement;&lt;br&gt;import javax.xml.bind.annotation.XmlRootElement;&lt;br&gt;      &lt;br&gt;@XmlRootElement(name = "clock")&lt;br&gt;public class Time {&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XmlElement&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private String time;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XmlElement&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private String name;&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void setTime(String time) {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.time = time;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void setName(String name) {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.name = name;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;/small&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;Deploy the web application. I used the embedded Tomcat instance in Eclipse to run this example. Access one of the URLs mentioned earlier and you will get the response in the appropriate format.&lt;br&gt;&lt;br&gt;You can also use the jersey client API to access this service...&lt;br&gt;&lt;table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"&gt;  &lt;tbody&gt;    &lt;tr&gt;      &lt;td&gt;&lt;small&gt;package com.tryout;&lt;br&gt;      &lt;br&gt;import com.sun.jersey.api.client.Client;&lt;br&gt;import com.sun.jersey.api.client.WebResource;&lt;br&gt;      &lt;br&gt;public class JSONClient {&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) throws Exception {&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Client c = Client.create();&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WebResource r = c&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.resource("http://localhost:8080/jaxrs/services/timeoftheday/asplaintext/mathew");&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Plain Text=&amp;gt;&amp;gt; " +r.get(String.class));&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r = c&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.resource("http://localhost:8080/jaxrs/services/timeoftheday/asxml/mathew");&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("XML=&amp;gt;&amp;gt; " + r.get(String.class));&lt;br&gt;      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r = c&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.resource("http://localhost:8080/jaxrs/services/timeoftheday/asjson/mathew");&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r.accept("application/json");&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("JSON=&amp;gt;&amp;gt; " + r.get(String.class));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;/small&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;Once you execute this client you should get a response such as:&lt;br&gt;&lt;br&gt;&lt;em&gt;&lt;font size="2"&gt;Plain Text=&amp;gt;&amp;gt;mathew-05.02.2009 08:31:35&lt;br&gt;XML=&amp;gt;&amp;gt;&amp;lt;?xml version="1.0" encoding="UTF-8"standalone="yes"?&amp;gt;&amp;lt;clock&amp;gt;&amp;lt;time&amp;gt;05.02.200908:31:35&amp;lt;/time&amp;gt;&amp;lt;name&amp;gt;mathew&amp;lt;/name&amp;gt;&amp;lt;/clock&amp;gt;&lt;br&gt;JSON=&amp;gt;&amp;gt; {"time":"05.02.2009 08:31:35","name":"mathew"}&lt;/font&gt;&lt;/em&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Pretty simple ah! Enjoy.&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;_uacct = "UA-1164071-1";urchinTracker();&lt;/script&gt;</content><summary>REST (REpresentational State Transfer) is an architecture style that describes how to use the Web (HTTP) to access services. JAX-RS (JSR 311) is a Java API to support implementation/access of REST web services using Java. This style was first documented by Ron Fielding.</summary></entry><entry><title>Apache Camel</title><link rel="alternate" href="http://blogs.averconsulting.com/2009/03/24/apache-camel.aspx?ref=rss" /><id>tag:blogs.averconsulting.com,2009-03-24:7567ae14-acc6-4e37-a1ec-e8f350b8a292</id><author><name>Mathew Thomas</name></author><category term="Integration" /><updated>2009-03-25T03:03:00Z</updated><published>2009-03-25T03:03:00Z</published><content type="html">&lt;link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" type="text/css" rel="stylesheet" /&gt;&lt;link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" type="text/css" rel="stylesheet" /&gt;&lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.ClipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.287/scripts/clipboard.swf';
SyntaxHighlighter.all();  
&lt;/script&gt;

&lt;a href="http://camel.apache.org"&gt;Apache Camel &lt;/a&gt;is an integration framework that supports and implements various integration related patterns. This article goes over a basic example which will give the reader a decent beginning to Camel.&lt;br&gt;&lt;br&gt;Camel touts itself as "a powerful open source integration framework based on known &lt;a href="http://camel.apache.org/enterprise-integration-patterns.html" title="Enterprise Integration Patterns"&gt;Enterprise Integration Patterns&lt;/a&gt; with powerful &lt;a href="http://camel.apache.org/bean-integration.html" title="Bean Integration"&gt;Bean Integration&lt;/a&gt;." These &lt;span class="nobr"&gt;&lt;a href="http://www.enterpriseintegrationpatterns.com/toc.html" title="Visit page outside Confluence" rel="nofollow"&gt;Enterprise Integration Patterns&lt;sup&gt;&lt;img class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt; are documented in the book by &lt;span class="nobr"&gt;&lt;a href="http://www.amazon.com/exec/obidos/search-handle-url/105-9796798-8100401?_encoding=UTF8&amp;amp;search-type=ss&amp;amp;index=books&amp;amp;field-author=Gregor%20Hohpe" title="Visit page outside Confluence" rel="nofollow"&gt;Gregor Hohpe&lt;sup&gt;&lt;img class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt; and &lt;span class="nobr"&gt;&lt;a href="http://www.amazon.com/exec/obidos/search-handle-url/105-9796798-8100401?_encoding=UTF8&amp;amp;search-type=ss&amp;amp;index=books&amp;amp;field-author=Bobby%20Woolf" title="Visit page outside Confluence" rel="nofollow"&gt;Bobby Woolf&lt;sup&gt;&lt;img class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;. The specific patterns that Camel supports can be found at &lt;a target="_blank" href="http://camel.apache.org/enterprise-integration-patterns.html"&gt;Camel Patterns.&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;em&gt;Note: Camel is used as part of IONA's FUSE ESB product. FUSE also uses ServiceMix, CXF and ActiveMQ.&lt;/em&gt;&lt;br&gt;&lt;br&gt;One of the key features of an ESB is to allow heterogeneous applications to talk to each other in a location independent way. What this means is that App1 does not talk to App2 directly (point-2-point). Instead they communicate via a common medium, the message bus. App1 puts a message on the bus requesting a certain service. The bus looks at the message header and routes it to the appropriate endpoint. The endpoint in this case is App2. Neither App1 nor App2 are directly tied together anymore.&lt;em&gt;&lt;br&gt;&lt;/em&gt;&lt;br&gt;Apache Camel provides the routing and mediation capabilities. Using URI's we define where we want to send the messages to. Example from our sample below - jms:queue:customer. This indicates that we are dropping a message to a jms queue named customer. The bus then routes the message appropriately to the endpoint. In the case of Camel we can set up the routing in either Java DSL (Java api) or via Spring XML. In this blog I use Java DSL (Spring XML is just as easy). &lt;br&gt;&lt;br&gt;In the example below I implement the following:&lt;br&gt;&lt;ul&gt;&lt;li&gt;The client (consumer) needs to call a remote service (provider) to get customer information (including any available rebate information)&lt;/li&gt;&lt;li&gt;The client does not know who the provider is.&lt;/li&gt;&lt;li&gt;The client only knows that it can drop a message into the bus with the customer id and it will get back a Customer java object.&lt;/li&gt;&lt;li&gt;On the ESB itself there are two services in play. The first service returns basic customer information. Another independent service returns the rebates based on the customer type (preferred customer or regular customer).&lt;/li&gt;&lt;li&gt;On the ESB we need to wire these two services together to provide the complete customer.&lt;/li&gt;&lt;li&gt;Finally my example takes the liberty of hardcoding certain values such as customer id and account id to only focus on Camel.&lt;/li&gt;&lt;/ul&gt;For this blog I will not post every single code file but describe the key parts. I will attach a zip file containing the complete maven project.&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;First the simple AccountService implementation...&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;

&lt;pre class="brush: java"&gt;
package com.aver;
import org.springframework.stereotype.Service;
@Service(value = "acctsvc")
public class AccountServiceImpl implements AccountService {

    public Boolean isActive(String acctId) {
        System.out.println("Invoked isActive with " + acctId);
        return acctId.equals("12345") ? true : false;
    }
}
&lt;/pre&gt;

&lt;strong&gt;Next the CustomerService implementation...&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;
&lt;pre class="brush: java"&gt;
package com.aver;
import org.springframework.stereotype.Service;
@Service(value = "custsvc")
public class CustomerServiceImpl implements CustomerService {
    public Customer getCustomerInfo(String custid) {
        System.out.println("Invoked getCustomerInfo with " + custid);
        Customer c = new Customer();
        c.setCustId(custid);
        if (custid.equals("cust1")) {
            c.setAcctId("12345");
            c.setName("activecustomer");
            c.setType(Customer.Type.PREFERRED);
        } else {
            c.setAcctId("09876");
            c.setName("inactivecustomer");
            c.setType(Customer.Type.REGULAR);
        }
        return c;
    }
}
&lt;/pre&gt;
&lt;br&gt;As you can see the CustomerService has nothing to do with the rebate information. &lt;br&gt;&lt;br&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;Next is the Rebate implementation...&lt;/span&gt;&lt;/strong&gt;&lt;br&gt;

&lt;pre class="brush: java"&gt;
package com.aver;
import org.springframework.stereotype.Service;
@Service(value = "rebatesvc")
public class LoyaltyRebateServiceImpl implements LoyaltyRebateService {

    public Customer rebates(Customer c) {
        if (c.getType() == Customer.Type.PREFERRED) {
            Rebate r = new Rebate("50% off all java 1.2 books");
            c.getRebates().add(r);
        }
        return c;
    }
}
&lt;/pre&gt;
&lt;br&gt;&lt;br&gt;Next we need to tell Camel what our routes are. For this blog I use the Java DSL and implement a RouteBuilder.&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;ServerRoutes (RouteBuilder)...&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;
&lt;pre class="brush: java"&gt;
package com.aver;
import org.apache.camel.builder.RouteBuilder;
public class ServerRoutes extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("jms:queue:customer").to("custsvc").to("rebatesvc");
        from("jms:queue:account").to("acctsvc");
    }

}
&lt;/pre&gt;
&lt;br&gt;Here we route the messages coming to the customer queue to the customer service and then to the rebate service.&lt;br&gt;&lt;br&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;Next we create the camel-server.xml (in META-INF/spring folder)...&lt;/span&gt;&lt;/strong&gt;&lt;br&gt;The spring xml below sets up the Camel Context, the ActiveMQ JMS and configures Camel to use ActiveMQ.&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;pre class="brush: xml"&gt;
    &amp;lt;!-- use spring annotations --&gt;
    &amp;lt;context:component-scan base-package="com.aver" /&gt;

    &amp;lt;!-- camel context --&gt;
    &amp;lt;camel:camelContext id="camel"&gt;
        &amp;lt;camel:package&gt;com.aver&amp;lt;/camel:package&gt;
    &amp;lt;/camel:camelContext&gt;


    &amp;lt;!-- configure ActiveMQ --&gt;
    &amp;lt;broker:broker useJmx="false" persistent="false"
        brokerName="localhost"&gt;
        &amp;lt;broker:transportConnectors&gt;
            &amp;lt;broker:transportConnector name="tcp"
                uri="tcp://localhost:61616" /&gt;
        &amp;lt;/broker:transportConnectors&gt;
    &amp;lt;/broker:broker&gt;

    &amp;lt;!-- configure Camel to use the ActiveMQ broker --&gt;
    &amp;lt;bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent"&gt;
        &amp;lt;property name="brokerURL" value="tcp://localhost:61616" /&gt;
    &amp;lt;/bean&gt;  
&lt;/pre&gt;
&lt;br&gt;&lt;br&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;The Client...&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;com.aver.client.Client contains following code that mimics a caller. There also exists a camel-client.xml (please see the zip file). &lt;br&gt;&lt;br&gt;
&lt;pre class="brush: java"&gt;
// simple
Boolean response = (Boolean) camelTemplate.sendBody(
         "jms:queue:account", ExchangePattern.InOut, "12345");
System.out.println("Account Active Flag: " + response);

// returns java object
Customer c = (Customer) camelTemplate.sendBody("jms:queue:customer",
         ExchangePattern.InOut, "cust1");
System.out.println("Customer : " + c);
&lt;/pre&gt;
&lt;br&gt;&lt;br&gt;The client code in this case has no idea about the service classes or actual endpoint. It only knows how to address the service in the bus using URI's such as 'jms:queue:account". Camel then routes this to the actual endpoint. &lt;br&gt;&lt;br&gt;Running this....&lt;br&gt;Run maven command&lt;br&gt;&lt;ul&gt;&lt;li&gt;&lt;em&gt;mvn clean compile exec:java&amp;nbsp; -Dexec.mainClass=org.apache.camel.spring.Main&lt;/em&gt; (this will bring up the Camel runtime so you can test).&lt;/li&gt;&lt;li&gt;From your eclipse project run Client.java as a regular java application (after you have started Camel server).&lt;/li&gt;&lt;/ul&gt;&lt;a href="http://blogs.averconsulting.com/files/26522-25187/camelapp.zip"&gt;Click here&lt;/a&gt; to download the zip file containing the code.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div&gt; &lt;/div&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;_uacct = "UA-1164071-1";urchinTracker();&lt;/script&gt;</content><summary>Apache Camel is an integration framework that supports and implements various integration related patterns. This article goes over a basic example which will give the reader a decent beginning to Camel.</summary></entry></feed>