org.glassfish.jersey.server.model
Class Resource.Builder

java.lang.Object
  extended by org.glassfish.jersey.server.model.Resource.Builder
Enclosing class:
Resource

public static final class Resource.Builder
extends java.lang.Object

Resource model component builder.


Method Summary
 ResourceMethod.Builder addMethod()
          Add a new arbitrary method model to the resource.
 ResourceMethod.Builder addMethod(java.lang.String httpMethod)
          Add a new method model to the resource for processing requests of the specified HTTP method.
 Resource build()
          Build a new resource model.
 Resource.Builder mergeWith(Resource.Builder resourceBuilder)
          Merge methods from a given resource model builder into this resource model builder.
 Resource.Builder mergeWith(Resource resource)
          Merge methods from a given resource model into this resource model builder.
 Resource.Builder name(java.lang.String name)
          Define a new name of the built resource.
 Resource.Builder path(java.lang.String path)
          Define a new path for the built resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

name

public Resource.Builder name(java.lang.String name)
Define a new name of the built resource. The resource model name is typically used for reporting purposes (e.g. validation etc.).

Parameters:
name - new name of the resource.
Returns:
updated builder object.
See Also:
Resource.getName()

path

public Resource.Builder path(java.lang.String path)
Define a new path for the built resource.

NOTE: Invoking this method marks a resource as a root resource.

Parameters:
path - new path for the resource.
Returns:
updated builder object.

addMethod

public ResourceMethod.Builder addMethod(java.lang.String httpMethod)
Add a new method model to the resource for processing requests of the specified HTTP method.

The returned builder is automatically bound to the the resource. It is not necessary to invoke the build() method on the method builder after setting all the data. This will be done automatically when the resource is built.

Parameters:
httpMethod - HTTP method that will be processed by the method.
Returns:
a new resource method builder.

addMethod

public ResourceMethod.Builder addMethod()
Add a new arbitrary method model to the resource.

The returned builder is automatically bound to the the resource. It is not necessary to invoke the build() method on the method builder after setting all the data. This will be done automatically when the resource is built.

Returns:
a new resource method builder.

mergeWith

public Resource.Builder mergeWith(Resource resource)
Merge methods from a given resource model into this resource model builder.

Parameters:
resource - to be merged into this resource model builder.
Returns:
updated builder object.

mergeWith

public Resource.Builder mergeWith(Resource.Builder resourceBuilder)
Merge methods from a given resource model builder into this resource model builder.

NOTE: Any "open" method builders in the supplied resourceBuilder that have not been explicitly converted to method models will be closed as part of this merge operation before merging the resource builder instances.

Parameters:
resourceBuilder - to be merged into this resource model builder.
Returns:
updated builder object.

build

public Resource build()
Build a new resource model.

Returns:
new (immutable) resource model.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.