Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Annotations

Apache Wink provides several annotations in addition to those defined by the JAX-RS specification. The following section describes these annotations in detail.

...

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
titleReference

Refer to chapter ‎10 TBD for For more information on regarding the APP Service Document, refer to section 5.4 APP Service Document

The workspaceTitle annotation parameter specifies the title of the workspace and the collectionTitle annotation parameter specifies the title of the collection.

...

ResourceA Definition

Code Block
xml
xml

@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
xml
xml

@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";}
}

...

Auto Generated APP Service Document

Code Block
xml
xml

<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>

...

The @Asset annotation is a marker annotation used by the Apache Wink runtime in order to identify an entity as an Asset.

Info
titleReference

Refer to chapter ‎5 TBD for For more information on about Assets refer to section 5.9 Assets.

@Asset Annotation Specification

...

The following example illustrates how to define a resource with a singleton lifecycle.

Code Block
xml
xml

@Scope(ScopeType.SINGLETON)
@Path("service1")
public class ResourceA {
    ...
}

...

The following example illustrates how to define a provider with a prototype lifecycle.

Code Block
xml
xml

@Scope(ScopeType.PROTOTYPE)
@Provider
public class EntityProvider implements MessageBodyReader<String> {
    ...
}

...

Example 1

Code Block
xml
xml

@Path("services")
public class ParentResource {
    ...
}

Example 2

Code Block
xml
xml

@Parent(BaseResource.class)
@Path("service1")
public class ResourceA {
    ...
}
Explanation

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".