Class ResourceMethod
java.lang.Object
org.glassfish.jersey.server.model.ResourceMethod
- All Implemented Interfaces:
NameBound
,Consuming
,Producing
,ResourceModelComponent
,Suspendable
public final class ResourceMethod
extends Object
implements ResourceModelComponent, Producing, Consuming, Suspendable, NameBound
Model of a method available on a resource. Covers resource method, sub-resource
method and sub-resource locator.
- Author:
- Marek Potociar
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Resource method model builder.static enum
Resource method classification based on the recognized JAX-RS resource method types. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ResourceModelVisitor visitor) A component should call the visitor back with an appropriate visitor interface method to give it a chance to process.List<? extends ResourceModelComponent>
Should return all existing resource model sub-components.Get the consumed media types supported by the component.Get the associated HTTP method.Get the invocable method model.Collection<Class<? extends Annotation>>
Get the collection of name bindings attached to this component.Get the parent resource for this resource method model.Get the produced media types supported by the component.long
Get the suspend timeout value in the giventime unit
.Get the suspendtimeout value
time unit.getType()
Get the JAX-RS method type.boolean
Get the flag indicating whether the resource method is extended or is a core of exposed RESTful API.boolean
Check if the component is marked to be executed asynchronously by using an internal Jerseyexecutor service
.boolean
Check if the component is bound or not.boolean
isSse()
Check whether the resource method will be producing Server-sent event stream.boolean
Check if the component is marked for suspending.toString()
-
Method Details
-
getParent
Get the parent resource for this resource method model.May return
null
in case the resource method is not bound to an existing resource. This is typical for resource method models returned directly from theResourceMethod.Builder.build()
method.- Returns:
- parent resource, or
null
if there is no parent resource associated with the method. - Since:
- 2.1
-
getType
Get the JAX-RS method type.- Returns:
- the JAX-RS method type.
-
getHttpMethod
Get the associated HTTP method.May return
null
in case the method represents a sub-resource locator.- Returns:
- the associated HTTP method, or
null
in case this method represents a sub-resource locator.
-
getInvocable
Get the invocable method model.- Returns:
- invocable method model.
-
isExtended
public boolean isExtended()Get the flag indicating whether the resource method is extended or is a core of exposed RESTful API.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.If not set the resource will not be defined as extended by default.
- Returns:
true
if the method is extended.- Since:
- 2.5.1
- See Also:
-
getConsumedTypes
Description copied from interface:Consuming
Get the consumed media types supported by the component.- Specified by:
getConsumedTypes
in interfaceConsuming
- Returns:
- immutable collection of supported consumed media types.
-
getProducedTypes
Description copied from interface:Producing
Get the produced media types supported by the component.- Specified by:
getProducedTypes
in interfaceProducing
- Returns:
- immutable collection of supported produced media types.
-
getSuspendTimeout
public long getSuspendTimeout()Description copied from interface:Suspendable
Get the suspend timeout value in the giventime unit
.- Specified by:
getSuspendTimeout
in interfaceSuspendable
- Returns:
- suspend timeout value.
-
getSuspendTimeoutUnit
Description copied from interface:Suspendable
Get the suspendtimeout value
time unit.- Specified by:
getSuspendTimeoutUnit
in interfaceSuspendable
- Returns:
- time unit of the suspend timeout value.
-
isSuspendDeclared
public boolean isSuspendDeclared()Description copied from interface:Suspendable
Check if the component is marked for suspending.- Specified by:
isSuspendDeclared
in interfaceSuspendable
- Returns:
true
if the component is marked for suspending,false
otherwise.
-
isSse
public boolean isSse()Check whether the resource method will be producing Server-sent event stream.- Returns:
true
if the resource method produces Server-sent event stream,false
otherwise.
-
isManagedAsyncDeclared
public boolean isManagedAsyncDeclared()Description copied from interface:Suspendable
Check if the component is marked to be executed asynchronously by using an internal Jerseyexecutor service
.- Specified by:
isManagedAsyncDeclared
in interfaceSuspendable
- Returns:
true
if the component is marked for managed asynchronous execution,false
otherwise.
-
getComponents
Description copied from interface:ResourceModelComponent
Should return all existing resource model sub-components.- Specified by:
getComponents
in interfaceResourceModelComponent
- Returns:
- list of all sub-components
-
accept
Description copied from interface:ResourceModelComponent
A component should call the visitor back with an appropriate visitor interface method to give it a chance to process.- Specified by:
accept
in interfaceResourceModelComponent
- Parameters:
visitor
- resource model visitor.
-
isNameBound
public boolean isNameBound()Description copied from interface:NameBound
Check if the component is bound or not.- Specified by:
isNameBound
in interfaceNameBound
- Returns:
true
if the component is bound,false
otherwise.
-
getNameBindings
Description copied from interface:NameBound
Get the collection of name bindings attached to this component.- Specified by:
getNameBindings
in interfaceNameBound
- Returns:
- collection of name binding annotation types.
-
toString
-