Class AsyncJobRef

java.lang.Object
org.apache.juneau.console.views.AsyncJobRef

@BeanType(properties="jobId,streamUrl,cancelUrl") public class AsyncJobRef extends Object
The "job accepted" envelope a row action's submit returns instead of a terminal ActionResult when the write is asynchronous.
Why this is not a new RowAction wire field

Whether an action is asynchronous is a property of the response, not of the declared action: the same RowAction POST returns either a terminal ActionResult (synchronous) or this pointer (asynchronous). So the RowAction wire schema is untouched — no new field, no fail-loud contract bump — and the juneau-views.js runtime routes to the streaming path purely by recognizing a streamUrl in the 2xx body. It carries no data to render, only capability pointers, so it needs no version handshake of its own.

The URLs are capabilities

streamUrl points at the SSE progress stream and cancelUrl at the cancel endpoint; both embed the job's unguessable 256-bit id (see AsyncJob), which is the whole of the access control. The browser EventSource that consumes streamUrl cannot set a CSRF header, which is precisely why the id must be unguessable rather than CSRF-gated.

See Also:
Since:
10.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The URL of the cancel endpoint (a non-safe POST); embeds jobId.
    The job's unguessable capability id.
    The URL of the SSE progress stream (a browser EventSource target); embeds jobId.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    of(String jobId, String streamUrl, String cancelUrl)
    Builds a reference carrying explicit stream/cancel URLs (for a consumer that resolves URLs itself, e.g. a template-rendered surface downstream of the servlet: rewrite).
    of(AsyncJob job)
    Builds a reference to the given job using servlet:-relative URLs against the AsyncJobsMixin mount — the same servlet: convention ViewsMixin uses for its asset URLs.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • of

      public static AsyncJobRef of(AsyncJob job)
      Builds a reference to the given job using servlet:-relative URLs against the AsyncJobsMixin mount — the same servlet: convention ViewsMixin uses for its asset URLs. streamUrl and cancelUrl are @Uri-annotated, which is what opts them into resolution: Juneau's serializer only rewrites the servlet: pseudo-scheme for a property whose ClassMeta or BeanPropertyMeta reports isUri()==true, and a plain String field reports that only via an explicit @Uri (see MarshalledPropertyPostProcessor); without it the literal "servlet:..." string would reach the wire unresolved. With the annotation present, every REST response serializer (JSON, HTML, XML, ...) resolves it against the current request's UriContext.
      Parameters:
      job - The started job. Must not be null.
      Returns:
      A new reference carrying the job's id and its servlet:-relative stream + cancel URLs.
    • of

      public static AsyncJobRef of(String jobId, String streamUrl, String cancelUrl)
      Builds a reference carrying explicit stream/cancel URLs (for a consumer that resolves URLs itself, e.g. a template-rendered surface downstream of the servlet: rewrite).
      Parameters:
      jobId - The job's capability id. Must not be null or blank.
      streamUrl - The SSE stream URL. Must not be null or blank.
      cancelUrl - The cancel URL. Must not be null or blank.
      Returns:
      A new reference.