Class ResourceMethod
- java.lang.Object
-
- org.glassfish.jersey.server.model.ResourceMethod
-
- All Implemented Interfaces:
NameBound,Consuming,Producing,ResourceModelComponent,Suspendable
public final class ResourceMethod extends java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResourceMethod.BuilderResource method model builder.(package private) static classResourceMethod.DataImmutable resource method data.static classResourceMethod.JaxrsTypeResource method classification based on the recognized JAX-RS resource method types.
-
Field Summary
Fields Modifier and Type Field Description private ResourceMethod.Datadataprivate Resourceparent
-
Constructor Summary
Constructors Constructor Description ResourceMethod(Resource parent, ResourceMethod.Data data)Create new resource method model instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ResourceModelVisitor visitor)A component should call the visitor back with an appropriate visitor interface method to give it a chance to process.java.util.List<? extends ResourceModelComponent>getComponents()Should return all existing resource model sub-components.java.util.List<javax.ws.rs.core.MediaType>getConsumedTypes()Get the consumed media types supported by the component.(package private) ResourceMethod.DatagetData()Get model data represented by this resource method.java.lang.StringgetHttpMethod()Get the associated HTTP method.InvocablegetInvocable()Get the invocable method model.java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>>getNameBindings()Get the collection of name bindings attached to this component.ResourcegetParent()Get the parent resource for this resource method model.java.util.List<javax.ws.rs.core.MediaType>getProducedTypes()Get the produced media types supported by the component.longgetSuspendTimeout()Get the suspend timeout value in the giventime unit.java.util.concurrent.TimeUnitgetSuspendTimeoutUnit()Get the suspendtimeout valuetime unit.ResourceMethod.JaxrsTypegetType()Get the JAX-RS method type.booleanisExtended()Get the flag indicating whether the resource method is extended or is a core of exposed RESTful API.booleanisManagedAsyncDeclared()Check if the component is marked to be executed asynchronously by using an internal Jerseyexecutor service.booleanisNameBound()Check if the component is bound or not.booleanisSse()Check whether the resource method will be producing Server-sent event stream.booleanisSuspendDeclared()Check if the component is marked for suspending.java.lang.StringtoString()(package private) static java.util.List<ResourceMethod>transform(Resource parent, java.util.List<ResourceMethod.Data> list)Transform a collection of resource method data into resource method models.
-
-
-
Field Detail
-
data
private final ResourceMethod.Data data
-
parent
private final Resource parent
-
-
Constructor Detail
-
ResourceMethod
ResourceMethod(Resource parent, ResourceMethod.Data data)
Create new resource method model instance.- Parameters:
parent- parent resource model.data- resource method model data.
-
-
Method Detail
-
transform
static java.util.List<ResourceMethod> transform(Resource parent, java.util.List<ResourceMethod.Data> list)
Transform a collection of resource method data into resource method models.- Parameters:
parent- parent resource model.list- resource method data collection.- Returns:
- transformed resource method models.
-
getData
ResourceMethod.Data getData()
Get model data represented by this resource method.- Returns:
- model data represented by this resource method.
-
getParent
public Resource getParent()
Get the parent resource for this resource method model.May return
nullin 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
nullif there is no parent resource associated with the method. - Since:
- 2.1
-
getType
public ResourceMethod.JaxrsType getType()
Get the JAX-RS method type.- Returns:
- the JAX-RS method type.
-
getHttpMethod
public java.lang.String getHttpMethod()
Get the associated HTTP method.May return
nullin case the method represents a sub-resource locator.- Returns:
- the associated HTTP method, or
nullin case this method represents a sub-resource locator.
-
getInvocable
public Invocable 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
OPTIONSresource methods added bymodel processorsorapplication.wadlresource 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:
trueif the method is extended.- Since:
- 2.5.1
- See Also:
ExtendedResource
-
getConsumedTypes
public java.util.List<javax.ws.rs.core.MediaType> getConsumedTypes()
Description copied from interface:ConsumingGet the consumed media types supported by the component.- Specified by:
getConsumedTypesin interfaceConsuming- Returns:
- immutable collection of supported consumed media types.
-
getProducedTypes
public java.util.List<javax.ws.rs.core.MediaType> getProducedTypes()
Description copied from interface:ProducingGet the produced media types supported by the component.- Specified by:
getProducedTypesin interfaceProducing- Returns:
- immutable collection of supported produced media types.
-
getSuspendTimeout
public long getSuspendTimeout()
Description copied from interface:SuspendableGet the suspend timeout value in the giventime unit.- Specified by:
getSuspendTimeoutin interfaceSuspendable- Returns:
- suspend timeout value.
-
getSuspendTimeoutUnit
public java.util.concurrent.TimeUnit getSuspendTimeoutUnit()
Description copied from interface:SuspendableGet the suspendtimeout valuetime unit.- Specified by:
getSuspendTimeoutUnitin interfaceSuspendable- Returns:
- time unit of the suspend timeout value.
-
isSuspendDeclared
public boolean isSuspendDeclared()
Description copied from interface:SuspendableCheck if the component is marked for suspending.- Specified by:
isSuspendDeclaredin interfaceSuspendable- Returns:
trueif the component is marked for suspending,falseotherwise.
-
isSse
public boolean isSse()
Check whether the resource method will be producing Server-sent event stream.- Returns:
trueif the resource method produces Server-sent event stream,falseotherwise.
-
isManagedAsyncDeclared
public boolean isManagedAsyncDeclared()
Description copied from interface:SuspendableCheck if the component is marked to be executed asynchronously by using an internal Jerseyexecutor service.- Specified by:
isManagedAsyncDeclaredin interfaceSuspendable- Returns:
trueif the component is marked for managed asynchronous execution,falseotherwise.
-
getComponents
public java.util.List<? extends ResourceModelComponent> getComponents()
Description copied from interface:ResourceModelComponentShould return all existing resource model sub-components.- Specified by:
getComponentsin interfaceResourceModelComponent- Returns:
- list of all sub-components
-
accept
public void accept(ResourceModelVisitor visitor)
Description copied from interface:ResourceModelComponentA component should call the visitor back with an appropriate visitor interface method to give it a chance to process.- Specified by:
acceptin interfaceResourceModelComponent- Parameters:
visitor- resource model visitor.
-
isNameBound
public boolean isNameBound()
Description copied from interface:NameBoundCheck if the component is bound or not.- Specified by:
isNameBoundin interfaceNameBound- Returns:
trueif the component is bound,falseotherwise.
-
getNameBindings
public java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> getNameBindings()
Description copied from interface:NameBoundGet the collection of name bindings attached to this component.- Specified by:
getNameBindingsin interfaceNameBound- Returns:
- collection of name binding annotation types.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-