<?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-8053768756089400780</id><updated>2011-11-27T16:52:24.216-08:00</updated><title type='text'>Hydera'Bad'sha</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://maheshyamsani.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8053768756089400780/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://maheshyamsani.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>MaheshYamsani</name><uri>http://www.blogger.com/profile/01694759725132924564</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_-Qy-yPAvq74/SZ9xpGPISJI/AAAAAAAAAPI/SN53uxIARyc/S220/123.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8053768756089400780.post-8558480008522836819</id><published>2009-05-24T21:30:00.000-07:00</published><updated>2009-11-20T17:56:53.329-08:00</updated><title type='text'>Rest in Spring 3.0 Sample Application in the form of Web Module(OSGi bundle)</title><content type='html'>Sample Hello World Program to Expose a RESTfull service using Spring 3.0 and REST Support of Spring 3.0. or this I am Using SpringDm Server 2.0 m2 and STS2.x&lt;br /&gt;Things to do before starting this example: Spring Framewoek 2.5 annotations, OSGi bundle development.&lt;br /&gt;1)Go to File-&gt;New Project-&gt;Spring Sourcedm Server -&gt; Bundle Project&lt;br /&gt;2)Provide a Name as HelloWorld&lt;br /&gt;then create a class as HelloWorld&lt;br /&gt;&lt;br /&gt;package hello.world;&lt;br /&gt;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;&lt;br /&gt;import org.springframework.stereotype.Controller;import org.springframework.ui.ModelMap;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.servlet.ModelAndView;&lt;br /&gt;@Controller@RequestMapping("/test/**")&lt;br /&gt;public class HelloWorld {&lt;br /&gt; @RequestMapping("/test")&lt;br /&gt;public ModelAndView sayMessage()&lt;br /&gt;{&lt;br /&gt; ModelMap modelMap = new ModelMap(); &lt;br /&gt;String response = "HelloWorld";&lt;br /&gt; modelMap.addAttribute("message", response);&lt;br /&gt;  return new ModelAndView("hello", modelMap); }&lt;br /&gt; @RequestMapping(value = "test/{message}", method = RequestMethod.GET)&lt;br /&gt;  public ModelAndView sayMessage(@PathVariable("message") String message, ModelMap modelMap,HttpServletRequest request,HttpServletResponse response) throws Exception{&lt;br /&gt; System.out.println("Hai in HelloWorld");&lt;br /&gt; modelMap.addAttribute("message", message);&lt;br /&gt; HelloData helloData = new HelloData(); &lt;br /&gt;helloData.setMessage(message);&lt;br /&gt; XMLTreeBuilder xmlBuilder = new XMLTreeBuilder();&lt;br /&gt; xmlBuilder.createXMLTree(helloData, response);&lt;br /&gt;  return new ModelAndView();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The above calss is acts like a controller with the Request mapping as /test/** means if any request comes up with the URL /test/ that should come to this controller , we can also provide option for Method as Post,Get,Put and Delete.&lt;br /&gt;&lt;br /&gt;The corresponding Manifest file should looks like&lt;br /&gt;&lt;br /&gt;Manifest-Version: 1.0Bundle-Version: 1.0.0Bundle-Name: RestBundle BundleBundle-ManifestVersion: 2Bundle-SymbolicName: RestBundleModule-Type: WebImport-Library: org.springframework.spring;version="[3.0.0.CI-217,3.0.0.CI-217]"Web-ContextPath: helloWeb-DispatcherServletUrlPatterns: /Import-Package: javax.servlet;version="[2.5.0,2.5.0]", javax.xml;version="[1.0.1,1.0.1]"Import-Bundle: com.springsource.javax.servlet;version="[2.5.0,2.5.0]"&lt;br /&gt;&lt;br /&gt;and the Module-Context.xml looks like&lt;br /&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;beans xmlns="&lt;a href="&gt;http://www.springframework.org/schema/beans&lt;/a&gt;" xmlns:context="&lt;a href="http://www.springframework.org/schema/context"&gt;http://www.springframework.org/schema/context&lt;/a&gt;" xmlns:p="&lt;a href="http://www.springframework.org/schema/p"&gt;http://www.springframework.org/schema/p&lt;/a&gt;" xmlns:xsi="&lt;a href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;" xsi:schemaLocation="&lt;a href="http://www.springframework.org/schema/beans"&gt;http://www.springframework.org/schema/beans&lt;/a&gt; &lt;a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&lt;/a&gt;     &lt;a href="http://www.springframework.org/schema/context"&gt;http://www.springframework.org/schema/context&lt;/a&gt; &lt;a href="http://www.springframework.org/schema/context/spring-context-2.5.xsd"&gt;http://www.springframework.org/schema/context/spring-context-2.5.xsd&lt;/a&gt;"&gt;               &lt;!--  - The controllers are autodetected POJOs labeled with the @Controller annotation. --&gt; &lt;context:component-scan package="hello" filters="false"&gt;  &lt;context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"&gt; &lt;/context:component-scan&gt;  &lt;!--  - This bean resolves specific types of exceptions to corresponding logical   - view names for error views. The default behaviour of DispatcherServlet   - is to propagate all exceptions to the servlet container: this will happen   - here with all other types of exceptions. --&gt; &lt;bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"&gt;  &lt;property name="exceptionMappings"&gt;   &lt;props&gt;    &lt;prop key=".DataAccessException"&gt;dataAccessFailure&lt;/prop&gt;      &lt;prop key=".lang.Exception"&gt;uncaughtException&lt;/prop&gt;       &lt;/props&gt;  &lt;/property&gt; &lt;/bean&gt;&lt;br /&gt;  &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" prefix="/WEB-INF/jsp/" suffix=".jsp"&gt;   &lt;!-- required to enable Spring 3.0 REST support --&gt;         &lt;/beans&gt;&lt;br /&gt;&lt;br /&gt;and the OSGi-Context.xml should looks like&lt;br /&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;beans:beans xmlns="&lt;a href="&gt;http://www.springframework.org/schema/osgi&lt;/a&gt;" xmlns:xsi="&lt;a href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;" xmlns:beans="&lt;a href="http://www.springframework.org/schema/beans"&gt;http://www.springframework.org/schema/beans&lt;/a&gt;" xsi:schemaLocation="&lt;a href="http://www.springframework.org/schema/osgi"&gt;http://www.springframework.org/schema/osgi&lt;/a&gt;           &lt;a href="http://www.springframework.org/schema/osgi/spring-osgi.xsd"&gt;http://www.springframework.org/schema/osgi/spring-osgi.xsd&lt;/a&gt;           &lt;a href="http://www.springframework.org/schema/beans"&gt;http://www.springframework.org/schema/beans&lt;/a&gt;           &lt;a href="http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;http://www.springframework.org/schema/beans/spring-beans.xsd&lt;/a&gt;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/beans:beans&gt;&lt;br /&gt;Util class is&lt;br /&gt;package hello.world;&lt;br /&gt;import java.io.PrintWriter;import java.io.StringWriter;&lt;br /&gt;import javax.servlet.http.HttpServletResponse;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import javax.xml.transform.OutputKeys;import javax.xml.transform.Transformer;import javax.xml.transform.TransformerFactory;import javax.xml.transform.dom.DOMSource;import javax.xml.transform.stream.StreamResult;&lt;br /&gt;import org.w3c.dom.Document;import org.w3c.dom.Element;&lt;br /&gt;public class XMLTreeBuilder {&lt;br /&gt; public void createXMLTree(HelloData helloData,HttpServletResponse response)throws Exception{  PrintWriter pw = null;  response.setContentType("text/xml");  pw = response.getWriter();  try  {   DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();   DocumentBuilder docBuilder = builderFactory.newDocumentBuilder();   //creating a new instance of a DOM to build a DOM tree.   Document doc = docBuilder.newDocument();   createXmlTree(doc,helloData,pw);  }  catch(Exception e)  {   System.out.println(e);  }&lt;br /&gt; }&lt;br /&gt; public void createXmlTree(Document document,HelloData helloData,PrintWriter pw) throws Exception {  Element treeElement = document.createElement("tree");  &lt;br /&gt;  document.appendChild(treeElement);&lt;br /&gt;  Element itemID = null;&lt;br /&gt;  itemID = document.createElement("message");  itemID.setAttribute("text",helloData.getMessage());  treeElement.appendChild(itemID);&lt;br /&gt;  //TransformerFactory instance is used to create Transformer objects.   TransformerFactory factory = TransformerFactory.newInstance();  Transformer transformer = factory.newTransformer();&lt;br /&gt;  transformer.setOutputProperty(OutputKeys.INDENT, "yes");&lt;br /&gt;  // create string from xml tree  StringWriter sw = new StringWriter();  StreamResult result = new StreamResult(sw);  DOMSource source = new DOMSource(document);  transformer.transform(source, result);  String xmlString = sw.toString();  System.out.println("XMLString "+xmlString);  pw.write(xmlString);  pw.flush();  pw.close();&lt;br /&gt; }}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add this particular HelloWorld project to Spring Dm Server and start deploy it.&lt;br /&gt;Once it is successfully deploying application go to &lt;a href="http://localhost:8080/hello/test/%7Bmessage"&gt;http://localhost:8080/hello/test/{message&lt;/a&gt; you want get there}&lt;br /&gt;&lt;br /&gt;You will get the message that you want to display in the form of xml which is to used by the client to read using RESTTemplate.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- Facebook Fan Badge START --&gt;&lt;div style="width: 100%;"&gt;&lt;div style="background: #3B5998;padding: 5px;"&gt;&lt;img src="http://www.facebook.com/images/fb_logo_small.png" alt="Facebook"/&gt;&lt;img src="http://badge.facebook.com/badge/68425977417.1273718385.547808001.png" alt="" width="0" height="0"/&gt;&lt;/div&gt;&lt;div style="background: #EDEFF4;display: block;border-right: 1px solid #D8DFEA;border-bottom: 1px solid #D8DFEA;border-left: 1px solid #D8DFEA;margin: 0px;padding: 0px 0px 5px 0px;"&gt;&lt;div style="background: #EDEFF4;display: block;padding: 5px;"&gt;&lt;table cellspacing="0" cellpadding="0" border="0"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;img src="http://www.facebook.com/images/icons/fbpage.gif" alt=""/&gt;&lt;/td&gt;&lt;td valign="top"&gt;&lt;p style="color: #808080;font-family: verdana;font-size: 11px;margin: 0px 0px 0px 0px;padding: 0px 8px 0px 8px;"&gt;&lt;a href="http://www.facebook.com/mahesh.yamsani" title="Mahesh Yamsani" target="_TOP" style="color: #3B5998;font-family: verdana;font-size: 11px;font-weight: normal;margin: 0px;padding: 0px 0px 0px 0px;text-decoration: none;"&gt;Mahesh Yamsani&lt;/a&gt; is a fan of&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style="background: #FFFFFF;clear: both;display: block;margin: 0px;overflow: hidden;padding: 5px;"&gt;&lt;table cellspacing="0" cellpadding="0" border="0"&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;a href="http://www.facebook.com/pages/Hyderabad-India/Ocimum-Biosolutions/68425977417" title="Ocimum  Biosolutions" target="_TOP" style="border: 0px;color: #3B5998;font-family: verdana;font-size: 12px;font-weight: bold;margin: 0px;padding: 0px;text-decoration: none;"&gt;&lt;img src="http://www.facebook.com/profile/pic.php?oid=AAAAAQAQZIS2EOgARgfJyqYd1i70bAAAAAuugqgkavMQWgMmTlat4Ux3&amp;size=square" style="border: 0px;margin: 0px;padding: 0px;" alt="Ocimum  Biosolutions"/&gt;&lt;/a&gt;&lt;/td&gt;&lt;td valign="middle" style="padding: 0px 8px 0px 8px;"&gt;&lt;a href="http://www.facebook.com/pages/Hyderabad-India/Ocimum-Biosolutions/68425977417" title="Ocimum  Biosolutions" target="_TOP" style="border: 0px;color: #3B5998;font-family: verdana;font-size: 12px;font-weight: bold;margin: 0px;padding: 0px;text-decoration: none;"&gt;Ocimum  Biosolutions&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="display: block;float: right;margin: 0px;padding: 4px 0px 0px 0px;"&gt;&lt;a href="http://www.facebook.com/facebook-widgets/fanbadges.php" title="Create your Fan Badge" target="_TOP" style="color: #3B5998;font-family: verdana;font-size: 11px;font-weight: none;margin: 0px;padding: 0px;text-decoration: none;"&gt;Create your Fan Badge&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;!-- Facebook Fan Badge END --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8053768756089400780-8558480008522836819?l=maheshyamsani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://maheshyamsani.blogspot.com/feeds/8558480008522836819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8053768756089400780&amp;postID=8558480008522836819' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8053768756089400780/posts/default/8558480008522836819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8053768756089400780/posts/default/8558480008522836819'/><link rel='alternate' type='text/html' href='http://maheshyamsani.blogspot.com/2009/05/rest-in-spring-30-sample-application-in.html' title='Rest in Spring 3.0 Sample Application in the form of Web Module(OSGi bundle)'/><author><name>MaheshYamsani</name><uri>http://www.blogger.com/profile/01694759725132924564</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_-Qy-yPAvq74/SZ9xpGPISJI/AAAAAAAAAPI/SN53uxIARyc/S220/123.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8053768756089400780.post-3307895284415714424</id><published>2009-02-20T19:17:00.000-08:00</published><updated>2010-12-21T05:26:24.520-08:00</updated><title type='text'>Cloud Computing</title><content type='html'>&lt;div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8053768756089400780-3307895284415714424?l=maheshyamsani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://maheshyamsani.blogspot.com/feeds/3307895284415714424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8053768756089400780&amp;postID=3307895284415714424' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8053768756089400780/posts/default/3307895284415714424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8053768756089400780/posts/default/3307895284415714424'/><link rel='alternate' type='text/html' href='http://maheshyamsani.blogspot.com/2009/02/cloud-computing.html' title='Cloud Computing'/><author><name>MaheshYamsani</name><uri>http://www.blogger.com/profile/01694759725132924564</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_-Qy-yPAvq74/SZ9xpGPISJI/AAAAAAAAAPI/SN53uxIARyc/S220/123.JPG'/></author><thr:total>0</thr:total></entry></feed>
