Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ericsson.rest;
- import javax.ws.rs.Consumes;
- import javax.ws.rs.GET;
- import javax.ws.rs.PUT;
- import javax.ws.rs.Path;
- import javax.ws.rs.Produces;
- @Path("/TestResource")
- public class TestResource {
- /**
- * Default constructor.
- */
- public TestResource() {
- // TODO Auto-generated constructor stub
- }
- /**
- * Retrieves representation of an instance of TestResource
- * @return an instance of String
- */
- @GET
- @Produces("text/html")
- public String resourceMethodGET() {
- // TODO Auto-generated method stub
- return "<html>Hello Roy</html>";
- }
- /**
- * PUT method for updating or creating an instance of TestResource
- * @content content representation for the resource
- * @return an HTTP response with content of the updated or created resource.
- */
- @PUT
- @Consumes("text/html")
- public void resourceMethodPUT(String content) {
- // TODO Auto-generated method stub
- //throw new UnsupportedOperationException();
- }
- }
- package rest.application.config;
- import java.util.Set;
- import javax.ws.rs.core.Application;
- import javax.ws.rs.ApplicationPath;
- @ApplicationPath("test")
- public class ApplicationConfig extends Application {
- public Set<Class<?>> getClasses() {
- return getRestClasses();
- }
- //Auto-generated from RESTful web service wizard
- private Set<Class<?>> getRestClasses() {
- Set<Class<?>> resources = new java.util.HashSet<Class<?>>();
- resources.add(com.ericsson.rest.TestResource.class);
- return resources;
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <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">
- <display-name>JAX_RS</display-name>
- <servlet>
- <servlet-name>RestServlet</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>rest.application.config.ApplicationConfig</param-value>
- </init-param>
- </servlet>
- <servlet-mapping>
- <servlet-name>RestServlet</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- <welcome-file>index.htm</welcome-file>
- <welcome-file>index.jsp</welcome-file>
- <welcome-file>default.html</welcome-file>
- <welcome-file>default.htm</welcome-file>
- <welcome-file>default.jsp</welcome-file>
- </welcome-file-list>
- </web-app>
- http://localhost:7001/JAX_RS/test/TestResource
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement