Build an Apache Wink REST service(一)
Apache Wink service configuration
Apache Wink applications are typically deployed in a servlet container like Apache Tomcat and packaged as a WAR file. Like any other Web application, Apache Wink services also need a web.xml file
web.xml Web configuration file as following:
<web-app><display-name>Wink demo</display-name><description>Demonstration of SDK features</description><!-- Wink SDK servlet configuration. This servlet handles HTTP requestsof SDK web service on application server.--><servlet><servlet-name>restSdkService</servlet-name><servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class><init-param><param-name>applicationConfigLocation</param-name><param-value>/WEB-INF/application</param-value></init-param></servlet><servlet-mapping><servlet-name>restSdkService</servlet-name><url-pattern>/rest/*</url-pattern></servlet-mapping></web-app>
@Workspace(workspaceTitle = "Services", collectionTitle = "Service1")@Path("services/service1")public class ResourceA { @POST @Produces("text/plain") @Consumes({"application/atom+xml", "application/xml"}) public String getText() {return "hey there1";}}
<service xmlns:atom=http://www.w3.org/2005/Atom xmlns="http://www.w3.org/2007/app"> <workspace> <atom:title>Services</atom:title> <collection href="services/service1"> <atom:title>Service1</atom:title> <accept>application/xml</accept> <accept>application/atom+xml</accept> </collection> </workspace></service>
@Scope(ScopeType.SINGLETON)@Path("service1")public class ResourceA { ...}
@Path("services")public class ParentResource { ...}@Parent(ParentResource .class)@Path("service1")public class ResourceA { ...}