Class ResourceMethod.Builder
- java.lang.Object
-
- org.glassfish.jersey.server.model.ResourceMethod.Builder
-
- Enclosing class:
- ResourceMethod
public static final class ResourceMethod.Builder extends java.lang.Object
Resource method model builder.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<javax.ws.rs.core.MediaType>
consumedTypes
private java.lang.reflect.Method
definitionMethod
private boolean
encodedParams
private boolean
extended
private java.lang.Class<?>
handlerClass
private java.lang.Object
handlerInstance
private java.util.Collection<Parameter>
handlerParameters
private java.lang.reflect.Method
handlingMethod
private java.lang.String
httpMethod
private boolean
managedAsync
private java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>>
nameBindings
private Resource.Builder
parent
private java.util.Set<javax.ws.rs.core.MediaType>
producedTypes
private java.lang.reflect.Type
routingResponseType
private boolean
sse
private boolean
suspended
private long
suspendTimeout
private java.util.concurrent.TimeUnit
suspendTimeoutUnit
-
Constructor Summary
Constructors Constructor Description Builder(Resource.Builder parent)
Create a resource method builder.Builder(Resource.Builder parent, ResourceMethod originalMethod)
Create a builder from an existing resource method model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceMethod
build()
Build the resource method model and register it with the parentResource.Builder
.ResourceMethod.Builder
consumes(java.lang.String... types)
Add consumed media types supported by the component.ResourceMethod.Builder
consumes(java.util.Collection<javax.ws.rs.core.MediaType> types)
Add consumed media types supported by the component.ResourceMethod.Builder
consumes(javax.ws.rs.core.MediaType... types)
Add consumed media types supported by the component.private Invocable
createInvocable()
ResourceMethod.Builder
encodedParameters(boolean value)
If set totrue
, the parameter values will not be automatically decoded.ResourceMethod.Builder
extended(boolean extended)
Get the flag indicating whether the resource method is extended or is a core of exposed RESTful API.ResourceMethod.Builder
handledBy(java.lang.Class<?> handlerClass, java.lang.reflect.Method method)
Define a resource method handler binding.ResourceMethod.Builder
handledBy(java.lang.Class<? extends Inflector> inflectorClass)
Define an inflector-based resource method handler binding.ResourceMethod.Builder
handledBy(java.lang.Object handlerInstance, java.lang.reflect.Method method)
Define a resource method handler binding.ResourceMethod.Builder
handledBy(Inflector<javax.ws.rs.container.ContainerRequestContext,?> inflector)
Define an inflector-based resource method handler binding.ResourceMethod.Builder
handlerParameters(java.util.Collection<Parameter> parameters)
Parameters defined on the handler (i.e.ResourceMethod.Builder
handlingMethod(java.lang.reflect.Method handlingMethod)
Define a specific method of the handling class that will be executed.ResourceMethod.Builder
httpMethod(java.lang.String name)
Set the associated HTTP method name.ResourceMethod.Builder
managedAsync()
Set the managed async required flag on the method model totrue
.ResourceMethod.Builder
nameBindings(java.lang.annotation.Annotation... nameBindings)
Adds name bindings.ResourceMethod.Builder
nameBindings(java.lang.Class<? extends java.lang.annotation.Annotation>... nameBindings)
Adds name bindings.ResourceMethod.Builder
nameBindings(java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> nameBindings)
Adds name bindings.ResourceMethod.Builder
produces(java.lang.String... types)
Add produced media types supported by the component.ResourceMethod.Builder
produces(java.util.Collection<javax.ws.rs.core.MediaType> types)
Add produced media types supported by the component.ResourceMethod.Builder
produces(javax.ws.rs.core.MediaType... types)
Add produced media types supported by the component.ResourceMethod.Builder
routingResponseType(java.lang.reflect.Type routingResponseType)
Define the response entity type used during the routing for selection of the resource methods.ResourceMethod.Builder
sse()
Set the SSE flag on the method model totrue
.ResourceMethod.Builder
suspended(long timeout, java.util.concurrent.TimeUnit unit)
Mark the component for suspending.
-
-
-
Field Detail
-
parent
private final Resource.Builder parent
-
httpMethod
private java.lang.String httpMethod
-
consumedTypes
private final java.util.Set<javax.ws.rs.core.MediaType> consumedTypes
-
producedTypes
private final java.util.Set<javax.ws.rs.core.MediaType> producedTypes
-
managedAsync
private boolean managedAsync
-
sse
private boolean sse
-
suspended
private boolean suspended
-
suspendTimeout
private long suspendTimeout
-
suspendTimeoutUnit
private java.util.concurrent.TimeUnit suspendTimeoutUnit
-
handlerClass
private java.lang.Class<?> handlerClass
-
handlerInstance
private java.lang.Object handlerInstance
-
handlerParameters
private final java.util.Collection<Parameter> handlerParameters
-
definitionMethod
private java.lang.reflect.Method definitionMethod
-
handlingMethod
private java.lang.reflect.Method handlingMethod
-
encodedParams
private boolean encodedParams
-
routingResponseType
private java.lang.reflect.Type routingResponseType
-
nameBindings
private final java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> nameBindings
-
extended
private boolean extended
-
-
Constructor Detail
-
Builder
Builder(Resource.Builder parent)
Create a resource method builder.The supplied parent resource model builder will be called to register the newly created resource method instance as part of the
build()
method invocation.Note that the
build()
method does not have to be invoked manually as the registration will happen automatically as part of theResource.Builder.build()
method invocation.- Parameters:
parent
- parent resource model builder.
-
Builder
Builder(Resource.Builder parent, ResourceMethod originalMethod)
Create a builder from an existing resource method model.- Parameters:
parent
- parent resource model builder.originalMethod
- existing resource method model to create the builder from.
-
-
Method Detail
-
httpMethod
public ResourceMethod.Builder httpMethod(java.lang.String name)
Set the associated HTTP method name.- Parameters:
name
- HTTP method name.- Returns:
- updated builder object.
-
produces
public ResourceMethod.Builder produces(java.lang.String... types)
Add produced media types supported by the component.- Parameters:
types
- produced media types.- Returns:
- updated builder object.
-
produces
public ResourceMethod.Builder produces(javax.ws.rs.core.MediaType... types)
Add produced media types supported by the component.- Parameters:
types
- produced media types.- Returns:
- updated builder object.
-
produces
public ResourceMethod.Builder produces(java.util.Collection<javax.ws.rs.core.MediaType> types)
Add produced media types supported by the component.- Parameters:
types
- produced media types.- Returns:
- updated builder object.
-
consumes
public ResourceMethod.Builder consumes(java.lang.String... types)
Add consumed media types supported by the component.- Parameters:
types
- consumed media types.- Returns:
- updated builder object.
-
consumes
public ResourceMethod.Builder consumes(javax.ws.rs.core.MediaType... types)
Add consumed media types supported by the component.- Parameters:
types
- consumed media types.- Returns:
- updated builder object.
-
consumes
public ResourceMethod.Builder consumes(java.util.Collection<javax.ws.rs.core.MediaType> types)
Add consumed media types supported by the component.- Parameters:
types
- consumed media types.- Returns:
- updated builder object.
-
nameBindings
public ResourceMethod.Builder nameBindings(java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> nameBindings)
Adds name bindings. The passed annotation types not annotated withNameBinding
meta-annotation will be ignored.- Parameters:
nameBindings
- collection of name binding annotation types.- Returns:
- updated builder object.
-
nameBindings
@SafeVarargs public final ResourceMethod.Builder nameBindings(java.lang.Class<? extends java.lang.annotation.Annotation>... nameBindings)
Adds name bindings. The passed annotation types not annotated withNameBinding
meta-annotation will be ignored.- Parameters:
nameBindings
- name binding annotation types.- Returns:
- updated builder object.
-
nameBindings
public ResourceMethod.Builder nameBindings(java.lang.annotation.Annotation... nameBindings)
Adds name bindings. The passed annotations not annotated withNameBinding
meta-annotation will be ignored.- Parameters:
nameBindings
- name binding annotations.- Returns:
- updated builder object.
-
suspended
public ResourceMethod.Builder suspended(long timeout, java.util.concurrent.TimeUnit unit)
Mark the component for suspending. An invocation of a component (resource or sub-resource method) marked for suspending will be automatically suspended by the Jersey runtime.- Parameters:
timeout
- suspend timeout value.unit
- suspend timeout time unit.- Returns:
- updated builder object.
-
sse
public ResourceMethod.Builder sse()
Set the SSE flag on the method model totrue
.- Returns:
- updated builder object.
-
managedAsync
public ResourceMethod.Builder managedAsync()
Set the managed async required flag on the method model totrue
.- Returns:
- updated builder object.
-
encodedParameters
public ResourceMethod.Builder encodedParameters(boolean value)
If set totrue
, the parameter values will not be automatically decoded. Defaults tofalse
.- Parameters:
value
-true
if the automatic parameter decoding should be disabled, false otherwise.- Returns:
- updated builder object.
- See Also:
Encoded
-
handledBy
public ResourceMethod.Builder handledBy(java.lang.Class<?> handlerClass, java.lang.reflect.Method method)
Define a resource method handler binding.- Parameters:
handlerClass
- concrete resource method handler class.method
- method that will be executed as a resource method. The parameters initializesinvocable definition method
.- Returns:
- updated builder object.
-
handledBy
public ResourceMethod.Builder handledBy(java.lang.Object handlerInstance, java.lang.reflect.Method method)
Define a resource method handler binding.- Parameters:
handlerInstance
- concrete resource method handler instance.method
- handling method.- Returns:
- updated builder object.
-
handledBy
public ResourceMethod.Builder handledBy(Inflector<javax.ws.rs.container.ContainerRequestContext,?> inflector)
Define an inflector-based resource method handler binding.- Parameters:
inflector
- inflector handling the resource method.- Returns:
- updated builder object.
-
handledBy
public ResourceMethod.Builder handledBy(java.lang.Class<? extends Inflector> inflectorClass)
Define an inflector-based resource method handler binding.- Parameters:
inflectorClass
- class of the inflector handling the resource method.- Returns:
- updated builder object.
-
handlerParameters
public ResourceMethod.Builder handlerParameters(java.util.Collection<Parameter> parameters)
Parameters defined on the handler (i.e. not in the handling method), e.g. via property setters or fields.- Parameters:
parameters
- handler parameters to be added to the set of handler parameters for the method.- Returns:
- updated builder object.
- Since:
- 2.20
-
handlingMethod
public ResourceMethod.Builder handlingMethod(java.lang.reflect.Method handlingMethod)
Define a specific method of the handling class that will be executed. If the method is not defined then the method will be equal to the method initialized by one of thehandledBy()
builder methods.- Parameters:
handlingMethod
- specific handling method.- Returns:
- updated builder object.
-
routingResponseType
public ResourceMethod.Builder routingResponseType(java.lang.reflect.Type routingResponseType)
Define the response entity type used during the routing for selection of the resource methods. If this method is not called then theInvocable.getRoutingResponseType()
will be equal toInvocable.getResponseType()
which is the default configuration state.- Parameters:
routingResponseType
- Routing response type.- Returns:
- updated builder object.
- See Also:
Invocable.getRoutingResponseType()
-
extended
public ResourceMethod.Builder extended(boolean extended)
Get the flag indicating whether the resource method is extended or is a core of exposed RESTful API. The method defines the flag available atResourceMethod.isExtended()
.Extended resource model components are helper components that are not considered as a core of a RESTful API. These can be for example
OPTIONS
resource methods
added bymodel processors
orapplication.wadl
resource producing the WADL. Both resource are rather supportive than the core of RESTful API.- Parameters:
extended
- Iftrue
then resource method is marked as extended.- Returns:
- updated builder object.
- Since:
- 2.5.1
- See Also:
ExtendedResource
-
build
public ResourceMethod build()
Build the resource method model and register it with the parentResource.Builder
.- Returns:
- new resource method model.
-
createInvocable
private Invocable createInvocable()
-
-