Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. package com.ericsson.rest;
  2.  
  3. import javax.ws.rs.Consumes;
  4. import javax.ws.rs.GET;
  5. import javax.ws.rs.PUT;
  6. import javax.ws.rs.Path;
  7. import javax.ws.rs.Produces;
  8.  
  9.  
  10. @Path("/TestResource")
  11. public class TestResource {
  12. /**
  13. * Default constructor.
  14. */
  15. public TestResource() {
  16. // TODO Auto-generated constructor stub
  17. }
  18.  
  19.  
  20. /**
  21. * Retrieves representation of an instance of TestResource
  22. * @return an instance of String
  23. */
  24. @GET
  25. @Produces("text/html")
  26. public String resourceMethodGET() {
  27. // TODO Auto-generated method stub
  28. return "<html>Hello Roy</html>";
  29. }
  30.  
  31. /**
  32. * PUT method for updating or creating an instance of TestResource
  33. * @content content representation for the resource
  34. * @return an HTTP response with content of the updated or created resource.
  35. */
  36. @PUT
  37. @Consumes("text/html")
  38. public void resourceMethodPUT(String content) {
  39. // TODO Auto-generated method stub
  40. //throw new UnsupportedOperationException();
  41. }
  42. }
  43.  
  44. package rest.application.config;
  45.  
  46. import java.util.Set;
  47. import javax.ws.rs.core.Application;
  48. import javax.ws.rs.ApplicationPath;
  49.  
  50. @ApplicationPath("test")
  51. public class ApplicationConfig extends Application {
  52.  
  53. public Set<Class<?>> getClasses() {
  54. return getRestClasses();
  55. }
  56.  
  57. //Auto-generated from RESTful web service wizard
  58. private Set<Class<?>> getRestClasses() {
  59. Set<Class<?>> resources = new java.util.HashSet<Class<?>>();
  60.  
  61. resources.add(com.ericsson.rest.TestResource.class);
  62. return resources;
  63. }
  64. }
  65.  
  66. <?xml version="1.0" encoding="UTF-8"?>
  67. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  68. <display-name>JAX_RS</display-name>
  69. <servlet>
  70. <servlet-name>RestServlet</servlet-name>
  71. <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
  72. <init-param>
  73. <param-name>javax.ws.rs.Application</param-name>
  74. <param-value>rest.application.config.ApplicationConfig</param-value>
  75. </init-param>
  76. </servlet>
  77. <servlet-mapping>
  78. <servlet-name>RestServlet</servlet-name>
  79. <url-pattern>/*</url-pattern>
  80. </servlet-mapping>
  81. <welcome-file-list>
  82. <welcome-file>index.html</welcome-file>
  83. <welcome-file>index.htm</welcome-file>
  84. <welcome-file>index.jsp</welcome-file>
  85. <welcome-file>default.html</welcome-file>
  86. <welcome-file>default.htm</welcome-file>
  87. <welcome-file>default.jsp</welcome-file>
  88. </welcome-file-list>
  89. </web-app>
  90.  
  91. http://localhost:7001/JAX_RS/test/TestResource
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement