@ Annotations
Apache Wink provides several annotations in addition to those defined by the JAX-RS specification. The following section describes these annotations in detail.
@Workspace Annotation
The purpose of the @Workspace annotation is to associate a "Collection Resource" with a workspace element and collection elements in an APP Service Document.
Info | ||
---|---|---|
| ||
Refer to chapter 10 TBD for more information on APP Service Document. |
The workspaceTitle annotation parameter specifies the title of the workspace and the collectionTitle annotation parameter specifies the title of the collection.
Annotation Specification
Value | Description | |
---|---|---|
Mandatory | No | |
Target | Resource class | |
Parameters | Name | Type |
| workspaceTitle | String |
| collectionTitle | String |
Example | @Workspace(workspaceTitle = "Title", |
@Workspace Annotation Example
The following example demonstrates the use of @Workspace annotation on two resources in order to have the auto-generated APP service document contain the information about them.
Given the following collection Resources definitions, ResourceA and ResourceB, the result is displayed in the "Auto Generated APP Service Document" table that follows.
ResourceA Definition
Code Block | ||||
---|---|---|---|---|
| ||||
@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";}
}
|
ResourceB Definition
Code Block | ||||
---|---|---|---|---|
| ||||
@Workspace(workspaceTitle = "Services", collectionTitle = "Service2")
@Path("services/service2")
public class ResourceB {
@POST
@Produces("text/plain")
@Consumes({"application/atom+xml", "application/xml"})
public String getText() {return "hey there2";}
}
|
The auto-generated APP Service Document is as follows:
Auto Generated APP Service Document
Code Block | ||||
---|---|---|---|---|
| ||||
<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>
<collection href="services/service2">
<atom:title>Service2</atom:title>
<accept>application/xml</accept>
<accept>application/atom+xml</accept>
</collection>
</workspace>
</service>
|
@Asset Annotation
The @Asset annotation is a marker annotation used by the Apache Wink runtime in order to identify an entity as an Asset.
Info | ||
---|---|---|
| ||
Refer to chapter 5 TBD for more information on Assets. |