Annotation Type SRA


@Inherited @InterceptorBinding @Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface 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

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    jakarta.ws.rs.core.Response.Status[]
    The cancelOn element can be set to indicate which HTTP response codes will cause the SRA to cancel
    jakarta.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 value
      The 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 enableJTABridge
      Create 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 end
      Normally 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[] cancelOnFamily
      The 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[] cancelOn
      The 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:
      {}