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 requests
of 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 Annotation
The following example demonstrates the use of @Workspace annotation on the resources in order to
have the auto-generated APP service document contain the information about it.
Given the following collection Resources definitions, ResourceA the result is displayed in
the "Auto Generated APP Service Document" table that follows.
@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";}
}
Auto Generated APP Service Document
<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 Annotation Specification
The following example illustrates how to define a resource with a singleton lifecycle
@Scope(ScopeType.SINGLETON)
@Path("service1")
public class ResourceA {
...
}
some kinds of lifescopes is below ,you can choose one which you need during your
coding
PROTOTYPE, SINGLETON
@Parent Annotation
The @Parent annotation provides the ability to define a base template URI for the URI specified in a
resources @Path annotation.If a resource is annotated with the @Parent annotation, the Apache Wink runtime calculates the final
resource template by first retrieving the value of the @Parent annotation, which holds the parent resource class, and then concatenates the resource path template definition to the path template definition of the parent resource.example is following:
@Path("services")
public class ParentResource {
...
}
@Parent(ParentResource .class)
@Path("service1")
public class ResourceA {
...
}
In the example, the user defined two resources: A ParentResource and ResourceA. ParentResource
defines the @Path annotation to associate it with "services" URI. ResourceA defines the @Path
annotation to associate it with "service1" URI and defines ParentResource to be its parent by specifying
it in the @Parent annotation.
In this case, the final URI path for ResourceA is "services/service1".
分享到:
相关推荐
NULL 博文链接:https://626333422-qq-com201110121851.iteye.com/blog/2368512
RESTful Web 服务和 Apache Wink
RESTful Web 服务和 Apache Wink
spring与wink集成开发rest服务,包括说明文档、源码、可执行文件
标签:apache-wink-1.3.0-src.tar.gz,apache,wink,1.3.0,src.tar.gz包下载,依赖包
标签:apache-wink-1.2.0-incubating-src.tar.gz,apache,wink,1.2.0,incubating,src.tar.gz包下载,依赖包
标签:apache-wink-1.1.2-incubating-src.tar.gz,apache,wink,1.1.2,incubating,src.tar.gz包下载,依赖包
标签:apache-wink-1.2.1-incubating.tar.gz,apache,wink,1.2.1,incubating.tar.gz包下载,依赖包
用maven创建基于wink的rest服务(二)-携带参数的get请求
Web service engine for cloud computing.
标签:apache-wink-1.4.tar.gz,apache,wink,1.4.tar.gz包下载,依赖包
标签:apache-wink-1.1.1-incubating.tar.gz,apache,wink,1.1.1,incubating.tar.gz包下载,依赖包
标签:apache-wink-1.4-src.tar.gz,apache,wink,1.4,src.tar.gz包下载,依赖包
标签:apache-wink-1.2.0-incubating.tar.gz,apache,wink,1.2.0,incubating.tar.gz包下载,依赖包
标签:apache-wink-0.1-incubating.tar.gz,apache,wink,0.1,incubating.tar.gz包下载,依赖包
标签:apache-wink-1.0-incubating.tar.gz,apache,wink,1.0,incubating.tar.gz包下载,依赖包
标签:apache-wink-1.1.1-incubating-src.tar.gz,apache,wink,1.1.1,incubating,src.tar.gz包下载,依赖包
标签:apache-wink-1.0-incubating-src.tar.gz,apache,wink,1.0,incubating,src.tar.gz包下载,依赖包
标签:apache-wink-1.1-incubating-src.tar.gz,apache,wink,1.1,incubating,src.tar.gz包下载,依赖包
标签:apache-wink-1.1.2-incubating.tar.gz,apache,wink,1.1.2,incubating.tar.gz包下载,依赖包