Annotation Type SRA
An annotation for controlling the lifecycle of Short Running Actions (SRAs).
Newly created SRAs are uniquely identified and the id is referred to as the SRA context. The context
is passed around using a JAX-RS request/response header called SRAClient#SRA_HTTP_HEADER ("Short-Running-Action").
The implementation (of the SRA specification) is expected to manage this context and the application
developer is expected to declaratively control the creation, propagation and destruction of SRAs
using the @SRA annotation. When a JAX-RS bean method is invoked in the context of an SRA any JAX-RS
client requests that it performs will carry the same header so that the receiving resource knows that
it is inside an SRA context (typically achieved using JAX-RS client filters). Similarly if the
enableJTABridge()
attribute is enabled then a JTA transaction context will be associated for the
duration of the method call so that any resources used by the method will be enlisted with the
SRA and will be committed or rolled back when the SRA finishes.
Resource methods can access the context id, if required, by injecting it via the JAX-RS @HeaderParam
annotation or via the SRAClient
API. This may be useful, for example, for associating
business work with an SRA.-
Nested Class Summary
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionjakarta.ws.rs.core.Response.Status[]
The cancelOn element can be set to indicate which HTTP response codes will cause the SRA to canceljakarta.ws.rs.core.Response.Status.Family[]
The cancelOnFamily element can be set to indicate which families of HTTP response codes will cause the SRA to cancel.boolean
Create a local JTA transaction context such that existing transactional JavaEE code may be called within the scope of the SRA.boolean
Normally if an SRA is present when a bean method is invoked it will not be ended when the method returns.The Type element of the SRA annotation indicates whether a bean method is to be executed within the context of a SRA.
-
Element Details
-
value
SRA.Type valueThe Type element of the SRA annotation indicates whether a bean method is to be executed within the context of a SRA.- Default:
REQUIRED
-
enableJTABridge
boolean enableJTABridgeCreate a local JTA transaction context such that existing transactional JavaEE code may be called within the scope of the SRA. This enables JTA resources to participate in the SRA and will be committed or rolled back when the SRA finishes.- Returns:
- whether or not JTA bridging is enabled
- Default:
false
-
end
boolean endNormally if an SRA is present when a bean method is invoked it will not be ended when the method returns. To override this behaviour use the end element to force its termination- Returns:
- true if an SRA that was present before method execution will be closed when the bean method finishes.
- Default:
true
-
cancelOnFamily
jakarta.ws.rs.core.Response.Status.Family[] cancelOnFamilyThe cancelOnFamily element can be set to indicate which families of HTTP response codes will cause the SRA to cancel. By default client errors (4xx codes) and server errors (5xx codes) will result in cancellation of the SRA.- Returns:
- the
Response.Status.Family
families that will cause cancellation of the SRA
- Default:
{CLIENT_ERROR, SERVER_ERROR}
-
cancelOn
jakarta.ws.rs.core.Response.Status[] cancelOnThe cancelOn element can be set to indicate which HTTP response codes will cause the SRA to cancel- Returns:
- the
Response.Status
HTTP status codes that will cause cancellation of the SRA
- Default:
{}
-