<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8704981976211886804</id><updated>2011-07-31T03:13:51.339-07:00</updated><title type='text'>Roberto Rojas's Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://rjrojas.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8704981976211886804/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://rjrojas.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Roberto J Rojas</name><uri>http://www.blogger.com/profile/04757505835955377609</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://3.bp.blogspot.com/_82UpA2pbDhA/SMsNvbRURQI/AAAAAAAAAAo/hlb7WLVEkBE/S220/RobertoJRojas.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8704981976211886804.post-1487024857155528801</id><published>2009-07-16T06:57:00.000-07:00</published><updated>2009-07-16T07:24:49.879-07:00</updated><title type='text'>Open Source Integration Happy Hour</title><content type='html'>Last week I had the pleasure to enjoy a few beers with my co-workers (&lt;a href="http://soatechlab.blogspot.com/"&gt;Rod Biresch&lt;/a&gt;, &lt;a href="http://soa4real.blogspot.com/index.html"&gt;Steve Smith&lt;/a&gt;, &lt;a href="http://tompurcellstechblog.blogspot.com/"&gt;Tom Purcell&lt;/a&gt;, and &lt;a href="http://www.rimple.com/"&gt;Ken Rimple&lt;/a&gt;) and have a nice conversation about SOA, Integration, related technologies, use of ESBs, and the current state of things.  We spoke about our experiences on integration projects, best practices, and the various technologies we have used in the past. For those interested in listening in on our conversation the PostCast(Episode 35), as well other interesting Postcasts, can be found &lt;a href="http://chariotsolutions.com/downloads/podcasts"&gt;&lt;span style="text-decoration: underline;"&gt;here&lt;/span&gt;&lt;/a&gt;.  I hope you find it useful and enjoy it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8704981976211886804-1487024857155528801?l=rjrojas.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rjrojas.blogspot.com/feeds/1487024857155528801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8704981976211886804&amp;postID=1487024857155528801' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8704981976211886804/posts/default/1487024857155528801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8704981976211886804/posts/default/1487024857155528801'/><link rel='alternate' type='text/html' href='http://rjrojas.blogspot.com/2009/07/open-source-integration-happy-hour.html' title='Open Source Integration Happy Hour'/><author><name>Roberto J Rojas</name><uri>http://www.blogger.com/profile/04757505835955377609</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://3.bp.blogspot.com/_82UpA2pbDhA/SMsNvbRURQI/AAAAAAAAAAo/hlb7WLVEkBE/S220/RobertoJRojas.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8704981976211886804.post-3603219878860574230</id><published>2009-01-16T20:58:00.000-08:00</published><updated>2009-03-06T12:54:07.174-08:00</updated><title type='text'>Camel Component For Amazon SQS</title><content type='html'>&lt;span style="font-weight: bold;font-size:130%;" &gt;What Is Amazon SQS?&lt;/span&gt;&lt;br /&gt;As its name implies Amazon Simple Queue Service (Amazon SQS) is a simplified version of a Messaging system. The great thing about it is its reliability and high scalability features.&lt;br /&gt;Amazon SQS makes it easy to build an automated workflow, working in close conjunction with the Amazon Elastic Compute Cloud (Amazon EC2) and the other AWS infrastructure web services.&lt;br /&gt;You can learn more about Amazon SQS &lt;a href="http://aws.amazon.com/sqs/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The Problem&lt;/span&gt;&lt;br /&gt;My colleagues (Tom Purcell and Rod Biresch) and myself have been working on a demo application for &lt;a href="http://chariotsolutions.com/"&gt;Chariot Solutions&lt;/a&gt;' &lt;a href="http://www.phillyemergingtech.com/"&gt; Emerging Technologies for the Enterprise&lt;/a&gt; &lt;a href="http://www.phillyemergingtech.com/"&gt;&lt;/a&gt; conference and the need for a transport component to simplify the access of Amazon SQS arose.&lt;br /&gt;We have decided to use FUSE ESB(ServiceMix) 4 as the services integration platform for the demo application, and knowing that Apache Camel collaborates very well with ServiceMix, we decided to use it for the routing and transformation needs.&lt;br /&gt;&lt;br /&gt;Currently, neither ServiceMix, nor Camel provide a component to access Amazon SQS. Besides this limitation the remaining capabilities provided by these products still made it a great choice for the demo application.&lt;br /&gt;&lt;br /&gt;To learn more about the demo application, please visit &lt;a href="http://tompurcellstechblog.blogspot.com/index.html"&gt;Tom Purcell's blog&lt;/a&gt;.&lt;br /&gt;I also recommend attending to the Tom Purcell's presentation titled &lt;a href="http://www.phillyemergingtech.com/abstracts.php?catID=3"&gt;"Bus In the Cloulds"&lt;/a&gt; where he'll be speaking about Could Computing use cases and how Open Source Integration technologies can help resolve issues encountered while integrating with business partners.&lt;br /&gt;&lt;br /&gt;Another important part in production applications is management and monitoring. To learn more about how to monitor this application, please visit &lt;a href="http://soatechlab.blogspot.com/"&gt;Rod Biresch's blog&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;A Solution&lt;/span&gt;&lt;br /&gt;Apache Camel makes it relatively easy to compose your own components, so the next logical step was to try to create one. Having seen Dave Kavanagh's &lt;a href="http://code.google.com/p/typica/"&gt;Typica API&lt;/a&gt; in action and how easy it makes the communication with SQS, we decided to try and come up with such Camel component using this API as the back-bone.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The Camel Amazon SQS Component&lt;/span&gt;&lt;br /&gt;The basic idea is to create a component that could be used in the following fashion:&lt;route&gt;&lt;from uri="file:data"&gt;&lt;/from&gt;&lt;/route&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;&amp;lt;camel:route&amp;gt;&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(51, 204, 0);"&gt;&amp;lt;camel:from&lt;/span&gt; &lt;span style="color: rgb(204, 0, 0);"&gt;uri=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;"file:data-in"&lt;/span&gt; &lt;span style="color: rgb(51, 204, 0);"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(51, 204, 0);"&gt;&amp;lt;camel:convertBodyTo&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;"java.lang.String" &lt;/span&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(51, 204, 0);"&gt;&amp;lt;camel:to&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;uri=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;"sqs:sqsProducer?accessId=...&amp;amp;secretKey=...&amp;amp;queueName=dataQueue"&lt;/span&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(51, 204, 0);"&gt;&amp;lt;/camel:route&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: rgb(51, 204, 0);"&gt; &amp;lt;camel:route&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;                 &amp;lt;camel:from&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(153, 0, 0);"&gt;uri=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;"sqs:sqsConsumer?accessId=...&amp;amp;secretKey=...&amp;amp;queueName=dataQueue"&lt;/span&gt; &lt;span style="color: rgb(51, 204, 0);"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 204, 0);"&gt;&amp;lt;camel:to&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; uri=&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;"file:data-out"&lt;/span&gt; &lt;span style="color: rgb(51, 204, 0);"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(51, 204, 0);"&gt;&amp;lt;/camel:route&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;route&gt;&lt;from uri="file:data"&gt;&lt;convertbodyto type="java.lang.String"&gt;The above example shows a Camel route that sends data found in files placed in the data directory to a SQS queue named "dataQueue".&lt;br /&gt;In the to URI "sqs:sqsProducer?accessId=....", the protocol "sqs" will tell Camel what component to configure and attributes will be mapped the properties of either the Endpoint, or the Producer class.&lt;br /&gt;&lt;br /&gt;The documentation on writing Camel Components can be found &lt;a href="http://activemq.apache.org/camel/writing-components.html"&gt;here.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Let's dive into the design of the Camel SQS component.&lt;br /&gt;&lt;br /&gt;The main steps for writing a Camel Component are:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Write a POJO which implements the Component interface. The simplest approach is just to derive from DefaultComponent. In our case, the class SQSComponent was created. This class extends DefaultComponent&lt;sqsexchange&gt;.&lt;br /&gt;&lt;/sqsexchange&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt; To support auto-discovery of your component add a file to META-INF/services/org/apache/camel/component/sqs&lt;/li&gt;&lt;/ul&gt;            where 'sqs' is the URI scheme for your component and any related endpoints created on the fly. The sqs file will contain the class attribute with the name of Class that implements the Component:&lt;br /&gt;class=com.chariotsolutions.soalab.camel.component.sqs.SQSComponent&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Camel SQS Component is composed of the following artifacts:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The SQSComponent Class&lt;/span&gt;&lt;br /&gt;This class serves as factory of Endpoints. When the component is being configured by Camel, the method of the createEndpoint is called. This method creates and configures the Endpoint (SQSEndpoint).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The SQSEndpoint Class&lt;/span&gt;&lt;br /&gt;This class serves as a factory for Producers, Consumers, and Exchanges.&lt;br /&gt;After the SQSComponent.createEndpoint is execute, an instance of the class SQSEndoint is created.&lt;br /&gt;This class contains the properties used by the SQSConsumer class. These properties are:&lt;br /&gt;private String accessId;&lt;br /&gt;private String secretKey;&lt;br /&gt;private String queueName;&lt;br /&gt;&lt;br /&gt;This class extends ScheduledPollEndpoint&lt;sqsexchange&gt; and is used to create instances of the SQSProducer and SQSConsumer. The use of the ScheduledPollEndpoint is with the intention to use polling facilities it provides to query the SQS Queue at a specified time intervals.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The SQSConsumer Class&lt;/span&gt;&lt;br /&gt;This class extends the ScheduledPollConsumer&lt;sqsexchange&gt; class to indicate that it will be excueted in poll intervals.&lt;br /&gt;The poll intervals are configured in the Component URI using the consumer.initialDelay and consumer.delay attributes like so:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt; &amp;lt;from&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;uri=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"sqs:sqsConsumer?...&amp;amp;consumer.initialDelay=1000&amp;amp;consumer.delay=25000"&lt;/span&gt; &lt;span style="color: rgb(51, 204, 0);"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The poll() will be executed based on the configuration specified above.&lt;br /&gt;This method uses the Typica API to interact with the Amazon SQS Web services. If a message was found in the SQS Queue, it will&lt;br /&gt;be forward to the handleMessage. This method will set the message in a wrapper class called SQSObject, place it in the SQSExchange&lt;br /&gt;and send it flow of the route using the synchronous Processor by default. The attribute asyncProcess=true would cause it to use&lt;br /&gt;the AsyncProcess.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The SQSProducer Class&lt;/span&gt;&lt;br /&gt;This class extends the DefaultProducer&lt;sqsexchange&gt; class.&lt;br /&gt;It processes the message coming from the Camel flow and sends it to the SQS queue, then it sets the assigned message id to&lt;br /&gt;the SQSObject, which is later added to the SQSExchange in case other components need it down the road.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The SQSExchange Class&lt;/span&gt;&lt;br /&gt;This The base message exchange interface providing access to the request, response and fault instances.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The SQSObject Class&lt;/span&gt;&lt;br /&gt;This is convenient POJO that wraps the payload and properties coming from the SQS Queue.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Taking the Camel SQS Component For A Ride&lt;/span&gt;&lt;br /&gt;To see the Camel SQS Component in action, I created a small sample application.&lt;br /&gt;The sample application can be found in &lt;a href="http://robertojrojas-free-code.googlecode.com/files/camel-sqs-route-sample-v1.tar.gz"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here are the steps to build and run the application:&lt;br /&gt;&lt;/sqsexchange&gt;&lt;/sqsexchange&gt;&lt;/sqsexchange&gt;&lt;/convertbodyto&gt;&lt;/from&gt;&lt;/route&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;If you haven't already done so, create an Amazon SQS account using the "Sign Up" button in this &lt;a href="http://aws.amazon.com/sqs/"&gt;page&lt;/a&gt;.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Extract the sample code to a directory of your choice. For example, /tmp/sqs-sample. You should see 2 directories in there, camel-sqs (camel sqs component) and camel-sqs-route (sample camel route).&lt;/li&gt;&lt;li&gt;Navigate to the camel-sqs directory and build the code using: mvn clean install&lt;/li&gt;&lt;li&gt;Navigate to the camel-sqs-route directory.&lt;/li&gt;&lt;li&gt;Edit the file src/main/resources/aws.properties. Specify aws.accessId and aws.secretKey for your Amazon SQS account.&lt;/li&gt;&lt;li&gt;Edit the file src/main/resources/META-INF/spring/camel-context.xml. Find the file endpoints and modify them to point to the directories of your choice. The File-In endpoint is where you would supply the data files to be sent to the SQS queue. The File-Out endpoint is the directory where the files containing the contents of the SQS queue will be placed on.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Build the code using: mvn clean install&lt;/li&gt;&lt;li&gt;Run the code using: mvn camel:run  &lt;/li&gt;&lt;li&gt;You should be able to place your sample text files directory pointed by the File-In endpoint. After a few seconds the output files will be placed in directory pointed by File-Out.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Conclusion&lt;/span&gt;  &lt;route&gt;&lt;from uri="file:data"&gt;&lt;convertbodyto type="java.lang.String"&gt;&lt;sqsexchange&gt;&lt;sqsexchange&gt;&lt;sqsexchange&gt;&lt;br /&gt;Amazon SQS combined with ServiceMix and Camel are a great platform for building your &lt;/sqsexchange&gt;&lt;/sqsexchange&gt;&lt;/sqsexchange&gt;&lt;/convertbodyto&gt;&lt;/from&gt;&lt;/route&gt; IaaS (Infrastructure as a Service) projects.&lt;br /&gt;&lt;route&gt;&lt;from uri="file:data"&gt;&lt;convertbodyto type="java.lang.String"&gt;&lt;sqsexchange&gt;&lt;sqsexchange&gt;&lt;sqsexchange&gt;Hopefully future versions of Apache Camel will include such component. The Camel &lt;/sqsexchange&gt;&lt;/sqsexchange&gt;&lt;/sqsexchange&gt;&lt;/convertbodyto&gt;&lt;/from&gt;&lt;/route&gt;&lt;a href="https://issues.apache.org/activemq/browse/CAMEL-1432"&gt;CAMEL-1432&lt;/a&gt; &lt;route&gt;&lt;from uri="file:data"&gt;&lt;convertbodyto type="java.lang.String"&gt;&lt;sqsexchange&gt;&lt;sqsexchange&gt;&lt;sqsexchange&gt;JIRA issue has been created for this reason.&lt;br /&gt;&lt;br /&gt;Happy Cloud Computing!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Recommended Sites&lt;/span&gt;&lt;br /&gt;Tom Purcell's &lt;a href="http://tompurcellstechblog.blogspot.com/index.html"&gt;Blog&lt;/a&gt;&lt;br /&gt;Rod Biresch's &lt;a href="http://soatechlab.blogspot.com/"&gt;Blog&lt;/a&gt;&lt;br /&gt;Amazon &lt;a href="http://aws.amazon.com/sqs/"&gt;SQS&lt;/a&gt;&lt;br /&gt;&lt;a href="http://fusesource.com/products/enterprise-servicemix/"&gt;FUSE ESB&lt;/a&gt; (ServiceMix) 4&lt;br /&gt;&lt;a href="http://camel.apache.org/"&gt;Apache Camel&lt;/a&gt;&lt;br /&gt;&lt;a href="http://chariotsolutions.com/"&gt;Chariot Solutions&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/sqsexchange&gt;&lt;/sqsexchange&gt;&lt;/sqsexchange&gt;&lt;/convertbodyto&gt;&lt;/from&gt;&lt;/route&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8704981976211886804-3603219878860574230?l=rjrojas.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rjrojas.blogspot.com/feeds/3603219878860574230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8704981976211886804&amp;postID=3603219878860574230' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8704981976211886804/posts/default/3603219878860574230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8704981976211886804/posts/default/3603219878860574230'/><link rel='alternate' type='text/html' href='http://rjrojas.blogspot.com/2009/01/camel-component-for-amazon-sqs.html' title='Camel Component For Amazon SQS'/><author><name>Roberto J Rojas</name><uri>http://www.blogger.com/profile/04757505835955377609</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://3.bp.blogspot.com/_82UpA2pbDhA/SMsNvbRURQI/AAAAAAAAAAo/hlb7WLVEkBE/S220/RobertoJRojas.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8704981976211886804.post-3196474626356715355</id><published>2008-09-12T06:44:00.000-07:00</published><updated>2008-09-15T10:03:11.161-07:00</updated><title type='text'>RESTful Web Services using IONA FUSE ESB 4.0 Preview and Spring Dynamic Modules</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;I recently started doing a substantial amount of research on ServiceMix 4 and OSGi (particularly Spring Dynamic Modules) and it's interesting to see the capabilities you can gain when you combine the two.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;I have been playing around with the samples applications and looking at the code behind both ServiceMix 4 and Spring DM, and I felt like I should share some of &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;my findings.&lt;br /&gt;In this installment we'l&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;l&lt;/span&gt;&lt;span style="font-family:verdana;"&gt; look at a sample application that combines RESTful style of Web Services  and Spring Dyn&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;amic Modules (Spring DM).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;One way of providing RESTful services from within ServiceMix is by using the CXF Compo&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;nents that come with the product. As explained &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://cwiki.apache.org/CXF20DOC/restful-services.html"&gt;here&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, CXF provides different ways of exposing RESTful services.&lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;For the sample application I'll use the JAX-RS (JSR-311) API to expose&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt; the sample Weather application that comes with Spring Dynamic Modules from within FUSE ESB 4.0 Preview (ServiceMix 4).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The Ingredie&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;nts&lt;/span&gt;&lt;ul&gt;&lt;li  style="font-family:verdana;"&gt; &lt;span style="font-size:85%;"&gt;&lt;a href="http://open.iona.com/products/enterprise-servicemix-4-0-preview/"&gt;IONA FUSE ESB 4.0 Preview &lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:verdana;"&gt; &lt;a href="http://downloads.sourceforge.net/springframework/spring-osgi-1.2.0-m1-with-dependencies.zip?modtime=1220619341&amp;amp;big_mirror=0"&gt;&lt;span style="font-size:85%;"&gt;Spring Dynamic Modules 1.2.0 M1&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li  style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt; &lt;a href="http://java.sun.com/javase/downloads/index.jsp"&gt;Java 1.5+&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:verdana;"&gt; &lt;span style="font-size:85%;"&gt;&lt;a href="http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-2.0.9-bin.zip"&gt;Maven 2.0.9&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt; CXF-SpringDM-Weather Sample application  &lt;a href="http://robertojrojas-free-code.googlecode.com/svn/trunk/RESTful-Services-SpringDM/cxf-springdm-weather"&gt;SVN Repository&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;Subversion Client&lt;/span&gt; (&lt;a href="http://subversion.tigris.org/getting.html#windows"&gt;SVN command line&lt;/a&gt;, &lt;a href="http://tortoisesvn.tigris.org/"&gt;Tortoisevn&lt;/a&gt;)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;IONA FUSE ESB&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt; 4.0 Prev&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;iew&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt; &lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Configuration&lt;/span&gt;&lt;br /&gt;&lt;ol  style="font-family:verdana;"&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;Download IONA FUSE ESB 4.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;0 Preview from the link above and install it. The installation of product is really straight forward and choosing the default configuration should be just fine.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;Go to the examples directory of the FUSE ESB product and build the cxf-osgi project.         This step prepares your local maven repository with the artifacts required to build the sample application. If you run the followin&lt;/span&gt;&lt;span style="font-size:85%;"&gt;g, you should be just fine: &lt;span style="font-weight: bold; font-style: italic;"&gt;  mvn install&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Spring Dyna&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;mic Modu&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;les Instal&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;lation&lt;/span&gt;&lt;br /&gt;&lt;ol  style="font-family:verdana;"&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;Download Spring Dynamic Modules from the link above and install it. For the sample I'll assume the installation directory is C:\dev\spring-osgi-1.2.0-m1&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;Go to the samples directory (C:\dev\spring-osgi-1.2.0-m1\src\samples) of the Spring DM distribution and execute:  &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;mvn  -Dmaven.test.skip=true clean install -P fe&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;lix  &lt;/span&gt;&lt;span style="font-size:85%;"&gt;This step will help with the deployment of the weather service from within the ServiceMix console.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:85%;" &gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Sample Application Installa&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;tion and Build&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li  style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;Using a Subversion client, checkout the sample application from here:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;a href="http://robertojrojas-free-code.googlecode.com/svn/trunk/RESTful-Services-SpringDM/cxf-springdm-weather"&gt;SVN Repository&lt;/a&gt;&lt;br /&gt;I had to provide a URL link instead of the URL itself to avoid the word wrapping caused by such long URL. You can open your browser to the URL above,  copy and paste the address to your svn client.  I'll assume the code will be checked out to the directory &lt;span style="font-weight: bold;"&gt;C:\dev\cxf-springdm-weather&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li face="verdana"&gt;&lt;span style="font-size:85%;"&gt;&lt;span&gt;Install the required bundles for the sample application.&lt;br /&gt;From the directory&lt;br /&gt;C:\dev\cxf-springdm-weather\lib execute the following command:&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-weight: bold;"&gt; &lt;span style="font-style: italic;"&gt;mvn install:install-file -DgroupId=javax.ws.rs -DartifactId=jsr311-osgi-api -Dversion=0.8 -Dpackaging=jar -Dfile=jsr311-osgi-api-0.8.jar&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;Change to the  &lt;span style="font-weight: bold;"&gt;C:\dev\cxf-springdm-weather&lt;/span&gt; directory and build the application with:&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;mvn clean install&lt;/span&gt;&lt;br /&gt;If everything goes well,&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt; maven will create a target directory with a jar file with the name&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-style: italic; font-weight: bold;font-family:verdana;font-size:85%;"  &gt;cxf-springdm-weather-4&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;font-family:verdana;font-size:85%;"  &gt;.0.0.0-fuse.jar&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Deployment&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;&lt;br /&gt;The CXF implementation of JAX-RS&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt; depends on two OSGI bundle jars (jettison-1.0.1.jar and jsr311-osgi-api-0.8.jar). I had to convert these jars to OSGi bundles and I'm providing them within lib directory of the sample application so that you don't have to convert them yourself.&lt;br /&gt;&lt;br /&gt;Here is how you would deploy the sample application from within ServiceMix console. These steps use the "osgi" command to install and start the required bundles:&lt;br /&gt;&lt;/span&gt;&lt;ol  style="font-family:verdana;"&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;Launch the ServiceMix Ke&lt;/span&gt;&lt;span style="font-size:85%;"&gt;r&lt;/span&gt;&lt;span style="font-size:85%;"&gt;nel by running&lt;br /&gt;bin/servicemix&lt;br /&gt;in the root dir of FUSE ESB distribution.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;osgi install file:/C:/dev/cxf-springdm-weather/lib/jettison-1.0.1.jar&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;osgi install -s file:/C:/dev/cxf-springdm-weather/lib/jsr311-osgi-api-0.8.jar&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;bundleid of="" the="" api=""&gt;&lt;/bundleid&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;Use the command "osgi list" to find the bundle id for the bundle with the name "Apache CXF Bundle Jar (2.1.1.fuse)" and execute the command "osgi refresh &lt;bundle_id&gt;". In my system the bundle id is 56, so the command I used&lt;/bundle_id&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;bundle_id&gt; was: o&lt;/bundle_id&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;bundle_id&gt;sgi refresh 56.&lt;/bundle_id&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;osgi install -s mvn:org.springframework.osgi.samples/weather-dao/1.2.0-m1&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;osgi install -s mvn:org.springframework.osgi.samples/weather-service/1.2.0-m1&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;osgi install&lt;span style="font-size:78%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;-s file:/C:/dev/cxf-s&lt;/span&gt;&lt;span style="font-size:85%;"&gt;pringdm-weather/target/cxf-springdm-weather-4.0.0.0-fuse.jar&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;At this point you should see an output similar to this one within the ServiceMix console:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0); font-style: italic;font-size:85%;" &gt;&lt;span style="color: rgb(204, 0, 0);"&gt;servicemix&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; Instant&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153); font-style: italic;font-size:85%;" &gt;iating org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd&lt;br /&gt;class org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd setting weatherService: org.springframework.osgi.samples.weather&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153); font-style: italic;font-size:85%;" &gt;.service.WeatherServiceImpl@5c0dbc55&lt;br /&gt;Sep 12, 2008 10:41:40 AM org.apache.cxf.endpoint.ServerImpl initDestination&lt;br /&gt;INFO: Setting the server's publi&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153); font-style: italic;font-size:85%;" &gt;sh address to be &lt;span style="font-family:verdana;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;weather&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Testing T&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;he &lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Application&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;Now, just open your browser an&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;d go to the following url:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;http://localhost:8080/cxf/weather/service/historical-high/11-11-2002&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The date must be in the format &lt;span style="font-weight: bold;"&gt;mm-dd-yyyy&lt;/span&gt;. If you provide an invalid date an exception will be displayed in the ServiceMix console and today's date will be used for processing.&lt;br /&gt;&lt;br /&gt;Your browser should display this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_82UpA2pbDhA/SMr1BMWiJWI/AAAAAAAAAAM/_QJjCkw8g5I/s1600-h/xml-output.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_82UpA2pbDhA/SMr1BMWiJWI/AAAAAAAAAAM/_QJjCkw8g5I/s320/xml-output.png" alt="" id="BLOGGER_PHOTO_ID_5245274116870776162" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;Sample A&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;pplicatio&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;n Code Walk-through&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;The following diagram depicts the request/response flow of the Sample application.&lt;/span&gt;&lt;/span&gt; &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;Notice how the CXF component is serving as a proxy between the HTTP/WS component and the WeatherServiceFrontEnd Bean. Similarly, Spring DM serves as a proxy to the registered OSGi services, in this case, Weather-Service service and the Weather-dao service.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_82UpA2pbDhA/SMs0fHQ3-cI/AAAAAAAAABg/_9rNcTWdMSE/s1600-h/Request-Flow.png"&gt;&lt;img style="cursor: pointer;" src="http://1.bp.blogspot.com/_82UpA2pbDhA/SMs0fHQ3-cI/AAAAAAAAABg/_9rNcTWdMSE/s320/Request-Flow.png" alt="" id="BLOGGER_PHOTO_ID_5245343900133489090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Spring DM's We&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;ather A&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;pplication&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;&lt;br /&gt;First let me start explaining little bit about the Spring DM's weather sample application.&lt;br /&gt;The Spring DM weather applicati&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;on comes with some other OSGi bundles, but we only needed the weather-service and weather-dao bundles for the sample applciation.&lt;br /&gt;If you look at the context file&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;weather/src/main/resources/META-INF/spring/weather-service-context.xml&lt;/span&gt;, you'll find the &lt;span style="color: rgb(0, 153, 0);"&gt;&amp;lt;osgi:service &lt;span style="color: rgb(153, 0, 0);"&gt;ref=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"weatherService"&lt;/span&gt;&amp;gt; .... &amp;lt;/osgi:service&amp;gt;&lt;/span&gt; &lt;osgi:service ref="weatherService"&gt;tag. This tag registers&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService"&gt; the weatherService bean (defined in the same context file) inside the OSGi registry. Later, we'll look at how we get a reference to this service and inject it to our RESTful web service bean.&lt;br /&gt;&lt;br /&gt;The cxf-springdm-weather bundle (the front end of the sample application) depends on the service exposed by the weather-service bundle and the weather-service bundle depends on the service exposed by t&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService"&gt;he weather-dao bundle. This is a typical design of applications that take advantage of the modularity provided by OSGi. Of course, Spring DM makes&lt;/osgi:service&gt;&lt;/span&gt;&lt;osgi:service ref="weatherService"&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt; it really easy to accomplish such design by applying IoC principals.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;The &lt;/span&gt;&lt;/span&gt;&lt;/osgi:service&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;WeatherServiceFrontEnd Bean&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;osgi:service ref="weatherService"  style="font-family:verdana;"&gt;On the CXF/JAX-RS side, we start looking at the &lt;span style="color: rgb(204, 0, 0);"&gt;org.apache.servicem&lt;/span&gt;&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService"  style="font-family:verdana;"&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;ix.examples.restful.springdm.WeatherServiceFrontEnd&lt;/span&gt; class.&lt;br /&gt;This class is nothing m&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService"  style="font-family:verdana;"&gt;ore than a POJO with JAX-RS annotations and with&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService"  style="font-family:verdana;"&gt; a dependency on an object implementing the &lt;span style="color: rgb(204, 0, 0);"&gt;org.springframework.osgi.samples.weather.service.WeatherService&lt;/span&gt;&lt;br /&gt;interface. An instance of this interface will be injected using Spring DM.&lt;br /&gt;&lt;br /&gt;In a nutshell, the JAX-RS is a combination of annotations that help mapping the URI and HTTP request parameters to a POJO.&lt;/osgi:service&gt; &lt;osgi:service ref="weatherService" face="verdana"&gt;&lt;br /&gt;The &lt;span style="color: rgb(204, 0, 0);"&gt;@Path(&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"/service/"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; maps the URL immediately after the /cxf, which is the root of this application as we specified it in the xbeans.xml context file. We'll be talking about the configuration in the context&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService" face="verdana"&gt; file in just a minute.&lt;br /&gt;The &lt;span style="color: rgb(204, 0, 0);"&gt;@ProduceMime(&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"application/xml"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; says that this application will be returning xml data.&lt;br /&gt;&lt;br /&gt;If you look at the method &lt;span style="color: rgb(204, 0, 0);"&gt;getHistoricalHighForDate(...)&lt;/span&gt;, you'll notice that here we used some other JAX-RS annotations.&lt;br /&gt;The &lt;span style="color: rgb(204, 0, 0);"&gt;@Path(&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"/historica&lt;/span&gt;&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService" style="font-family: verdana;"&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;l-high/{date}"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; maps this to a URI underneath &lt;span style="color: rgb(0, 0, 153);"&gt;/cxf/weather/service&lt;/span&gt;.&lt;br /&gt;The &lt;span style="color: rgb(153, 0, 0);"&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;@PathParam(&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"date"&lt;/span&gt;)&lt;/span&gt;&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService" style="font-family: verdana;"&gt; maps the {date} specified by the above &lt;span style="color: rgb(204, 0, 0);"&gt;@Path&lt;/span&gt; to an argument of the getHistoricalHighForDate method.&lt;br /&gt;I purposely didn&lt;/osgi:service&gt;&lt;osgi:service style="font-family: verdana;" ref="weatherService"&gt;'t use any XML API to make the code of the sample application easier to read and follow. A&lt;/osgi:service&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;osgi:service style="font-family: verdana;" ref="weatherService"&gt;s you can see the code is really straight forward and all it does is delegate the call to implementation of the WeatherService and wrap in a XML string the results.&lt;br /&gt;More details on JAX-RS and how is used with CXF can be found &lt;a href="http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Note&lt;/span&gt;: JAX-RS nee&lt;/osgi:service&gt;&lt;osgi:service style="font-family: verdana;" ref="weatherService"&gt;ds to know what JAX-RS implementation would be used. This is done by creating a file calle&lt;/osgi:service&gt;&lt;/span&gt;&lt;osgi:service ref="weatherService"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;d "&lt;span style="color: rgb(204, 0, 0);"&gt;javax.ws.rs.ext.RuntimeDelegate&lt;/span&gt;" in the META-INF/services directory.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;      The contents of the file specify the name of the class performing this implementation.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The Sample Application Context File&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;   &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;The context file, located in META-INF/spring/xbean.xml, is used to configure the RESTful service, CXF and inject the weather service.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;At the start of the &lt;/span&gt;&lt;/span&gt;&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;context file, you'll find the usual namepace definitions, including those for JAX-RS and Spring DM.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;Then, there are a set of context imports:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt;&amp;lt;import &lt;span style="color: rgb(204, 0, 0);"&gt;resource&lt;/span&gt;=&lt;span style="color: rgb(51, 102, 255);"&gt;"classpath:META-INF/cxf/cxf.xml"&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;lt;import &lt;span style="color: rgb(204, 0, 0);"&gt;resource&lt;/span&gt;=&lt;span style="color: rgb(51, 102, 255);"&gt;"classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;lt;import &lt;span style="color: rgb(204, 0, 0);"&gt;resource&lt;/span&gt;=&lt;span style="color: rgb(51, 102, 255);"&gt;"classpath:META-INF/cxf/cxf-extension-http.xml"&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;lt;import &lt;span style="color: rgb(204, 0, 0);"&gt;resource&lt;/span&gt;=&lt;span style="color: rgb(51, 102, 255);"&gt;"classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" &lt;/span&gt;/&amp;gt;&lt;/span&gt;       &lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;These imports configure CXF's HTTP transport, hooks JAX-RS with CXF, and configure CXF within ServiceMix and the OSGi container.&lt;br /&gt;Then, there is the definition of the WeatherServiceFrontEnd bean.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt;&amp;lt;bean &lt;span style="color: rgb(204, 0, 0);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"weatherServiceFrontEnd"&lt;/span&gt; &lt;span style="color: rgb(204, 0, 0);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&lt;/span&gt; &amp;gt;&lt;br /&gt;&amp;lt;property &lt;span style="color: rgb(204, 0, 0);"&gt;name=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"weatherService"&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;springdm-osgi:reference &lt;span style="color: rgb(204, 0, 0);"&gt;interface=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"org.springframework.osgi.samples.weather.service.WeatherService"&lt;/span&gt; &lt;span style="color: rgb(204, 0, 0);"&gt;timeout=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"5000"&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;property name="weatherService"&gt;&lt;springdm-osgi:reference interface="org.springframework.osgi.samples.weather.service.WeatherService" timeout="5000"&gt;&lt;/springdm-osgi:reference&gt;&lt;/property&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;This is where the magic of Spring DM and Spring IoC is used to inject the weather-service to the weather RESTful service bean.&lt;br /&gt;The &lt;/span&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt;&amp;lt;springdm-osgi:reference ...&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt; &lt;/span&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt; tag finds a service in the OSGi registry with the interface &lt;span style="color: rgb(204, 0, 0);"&gt;org.springframework.osgi.samples.weather.service.WeatherService&lt;/span&gt;&lt;br /&gt;and injects it to the weatherService property of the  &lt;span style="color: rgb(204, 0, 0);"&gt;org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd&lt;/span&gt; bean.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;Lastly, the configuration of the RESTful web service by mapping it to the "/cxf/weather" URI using the address attribute of the JAX-RS component tag:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;jaxrs:server id="weatherService" address="/"&gt;&lt;br /&gt;&lt;jaxrs:servicebeans&gt;&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt;&amp;lt;jaxrs:server &lt;span style="color: rgb(204, 0, 0);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"weatherService"&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt; address=&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;"/weather"&lt;/span&gt; &amp;gt;&lt;br /&gt;&amp;lt;jaxrs:serviceBeans&amp;gt;&lt;br /&gt;&amp;lt;ref &lt;span style="color: rgb(204, 0, 0);"&gt;bean=&lt;span style="color: rgb(51, 102, 255);"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;weatherServiceFrontEnd"&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;lt;/jaxrs:serviceBeans&amp;gt;&lt;br /&gt;&amp;lt;/jaxrs:server&amp;gt;&lt;/span&gt;&lt;ref bean="weatherServiceFrontEnd"&gt;&lt;/ref&gt;&lt;/jaxrs:servicebeans&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;As you can see in the snippet of code above, the reference of the WeatherServiceFrontEnd bean is injected into the JAX-RS component.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;OSGi Bundles&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;The last thing to explain is how to help the OSGi container find the required classes for the various bundles of an application. This is usually done by specifying package imports/exports in the META-INF/MANIFEST.MF file. If you look closely at the provided pom.xml file, you'll notice that I'm using a ServiceMix 4 specific artifact as the parent for this project. This is due to the fact that I've used one of the sample's pom.xml file as starting point for this project. I'm guessing that down the road FUSE ESB 4.0 will come with maven archetypes, as its predecessor did, to facilitate the start of new projects. Back with the maven project, the maven-bundle-plugin plug-in is used to take care of generating the MANIFEST.MF file for us. This is done at the moment when the application is being built by the maven build process. All we have to do is specify the packages to import/export in the plug-in's configuration section. In there you'll find the packages of JAX-RS, CXF, the weather-service, among others.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;For a more in-depth look OSGi bundles, visit &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://blog.springsource.com/main/2008/02/18/creating-osgi-bundles/"&gt;Costin Leau's Blog&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;span style="font-family:verdana;"&gt;Final Words&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;The combination of an ESB like ServiceMix on top of an OSGi Container, all that with the flexibility and easy of use of Spring Dynamic Modules makes this an interesting&lt;/span&gt;&lt;/span&gt;&lt;/jaxrs:server&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;jaxrs:server id="weatherService" address="/"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt; product to use for your Enterprise Application Integration needs.&lt;br /&gt;I look forward to the GA release of the FUSE ESB 4.0 product. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Recommended Reading&lt;br /&gt;&lt;/span&gt;&lt;/jaxrs:server&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;ul  style="font-family:verdana;"&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;jaxrs:server id="weatherService" address="/"&gt;&lt;a href="http://open.iona.com/products/enterprise-servicemix-4-0-preview#documentation"&gt;IONA FUSE ESB 4 Preview Documentation&lt;/a&gt;&lt;/jaxrs:server&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;jaxrs:server id="weatherService" address="/"&gt;&lt;a href="http://static.springframework.org/osgi/docs/1.2.0-m1/reference/html/"&gt;Spring Dynamic Modules Reference&lt;/a&gt;&lt;/jaxrs:server&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;jaxrs:server id="weatherService" address="/"&gt;&lt;a href="http://soatechlab.blogspot.com/index.html"&gt;Rod Biresch's Blog&lt;/a&gt;&lt;/jaxrs:server&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;a href="http://soa4real.blogspot.com/index.html"&gt;Steve Smith's Blog&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;jaxrs:server id="weatherService" address="/"&gt;&lt;a href="http://macstrac.blogspot.com/"&gt;James Strachan's Blog&lt;/a&gt;&lt;/jaxrs:server&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;jaxrs:server id="weatherService" address="/"&gt;&lt;a href="http://gnodet.blogspot.com/"&gt;Guillaume Nodet's Blog&lt;/a&gt;&lt;/jaxrs:server&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;a href="http://blog.springsource.com/main/2008/02/18/creating-osgi-bundles/"&gt;Costin Leau's Blog&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;osgi:service ref="weatherService"&gt;&lt;import resource="classpath:META-INF/cxf/cxf.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"&gt;&lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml"&gt;&lt;import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"&gt;&lt;bean id="weatherServiceFrontEnd" class="org.apache.servicemix.examples.restful.springdm.WeatherServiceFrontEnd"&gt;&lt;jaxrs:server id="weatherService" address="/"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/jaxrs:server&gt;&lt;/bean&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/import&gt;&lt;/osgi:service&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8704981976211886804-3196474626356715355?l=rjrojas.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rjrojas.blogspot.com/feeds/3196474626356715355/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8704981976211886804&amp;postID=3196474626356715355' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8704981976211886804/posts/default/3196474626356715355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8704981976211886804/posts/default/3196474626356715355'/><link rel='alternate' type='text/html' href='http://rjrojas.blogspot.com/2008/09/restful-web-services-using-iona-fuse.html' title='RESTful Web Services using IONA FUSE ESB 4.0 Preview and Spring Dynamic Modules'/><author><name>Roberto J Rojas</name><uri>http://www.blogger.com/profile/04757505835955377609</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://3.bp.blogspot.com/_82UpA2pbDhA/SMsNvbRURQI/AAAAAAAAAAo/hlb7WLVEkBE/S220/RobertoJRojas.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_82UpA2pbDhA/SMr1BMWiJWI/AAAAAAAAAAM/_QJjCkw8g5I/s72-c/xml-output.png' height='72' width='72'/><thr:total>3</thr:total></entry></feed>
