net.sf.javaprinciples.resource
Interface ResourceFactory<T>

Type Parameters:
T - - content type of resource

public interface ResourceFactory<T>

Author:
wslade

Method Summary
 Resource<T> getResource(ResourceIdentifier identifier)
           
 ResourceIdentifier putResource(Resource<T> resource)
          Put a Resource representation to the server in response to a POST request.
 ResourceIdentifier putResource(ResourceIdentifier identifier, Resource<T> resource)
          Put a Resource representation to the server in response to a PUT request.
 

Method Detail

getResource

Resource<T> getResource(ResourceIdentifier identifier)
                        throws ResourceException
Parameters:
identifier - A non-null URN
Returns:
A resource matching the identifier, may be null if not available.
Throws:
ResourceException - On any error encountered.

putResource

ResourceIdentifier putResource(ResourceIdentifier identifier,
                               Resource<T> resource)
                               throws ResourceException
Put a Resource representation to the server in response to a PUT request. PUT requests typically update an existing representation, or in cases of Resource creation, this method is used where the client is able to construct a valid URI.

Parameters:
identifier - The identifier of the Resource to be updated / created.
resource - The representation to be put onto the server.
Returns:
ResourceIdentifier, may be null.
Throws:
ResourceException - On any error encountered.

putResource

ResourceIdentifier putResource(Resource<T> resource)
                               throws ResourceException
Put a Resource representation to the server in response to a POST request. POST requests are generally used to create a new Resource on the server, when the server is responsible for creating the Resource URI. A file upload service is a good example of using this method.

Parameters:
resource - The Resource representation to be put onto the server.
Returns:
The URI created by the server for the new Resource.
Throws:
ResourceException - On any error encountered.


Copyright © 2013. All Rights Reserved.