Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleReference

Refer to chapter ‎10 TBD for more information on 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 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 {
    ...
}

...