Class CalDavDeadline

java.lang.Object
org.exoplatform.caldav.client.CalDavDeadline
All Implemented Interfaces:
AutoCloseable

public final class CalDavDeadline extends Object implements AutoCloseable
One overall time budget for a sequence of CalDAV calls made on one thread — a landing of a mail's invitation, which holds the user's click: every request HttpCalDavClient sends while it is open is sent with the smaller of its own timeout and the time left, a request asked for once nothing is left is refused before it leaves (CalDavDeadlineException), and a response body still being read when the time runs out is cut. The request timeout bounds the connection and the wait for the response's headers; the body read after them is bounded here.

Opened with start(java.time.Duration), closed with close() — a try-with-resources — and per thread: a call made on another thread is not bounded by it. Opening one inside another keeps the earlier end when it is the sooner.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Fails when the budget has run out, or a request was refused or cut for it — a call that swallows such a failure (a read that leaves "those days as they are") would otherwise let the sequence go on as if it had read.
    void
    Closes the budget: the thread's previous one, if any, applies again.
    static Duration
    The time left of the budget open on the current thread, for a write channel that does not send through HttpCalDavClient — one another add-on contributes for an account (CalendarObjectWriters) — so that it bounds its own calls by it.
    start(Duration budget)
    Opens a budget on the current thread.

    Methods inherited from class java.lang.Object

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

    • start

      public static CalDavDeadline start(Duration budget)
      Opens a budget on the current thread.
      Parameters:
      budget - the time the calls made until close() may take altogether
      Returns:
      the budget, to close
    • remaining

      public static Duration remaining()
      The time left of the budget open on the current thread, for a write channel that does not send through HttpCalDavClient — one another add-on contributes for an account (CalendarObjectWriters) — so that it bounds its own calls by it.
      Returns:
      the time left, Duration.ZERO once it has run out (the budget is then spent), null when no budget is open
    • checkNotSpent

      public void checkNotSpent(String what)
      Fails when the budget has run out, or a request was refused or cut for it — a call that swallows such a failure (a read that leaves "those days as they are") would otherwise let the sequence go on as if it had read.
      Parameters:
      what - the step about to run, for the refusal
      Throws:
      CalDavDeadlineException - when it has run out
    • close

      public void close()
      Closes the budget: the thread's previous one, if any, applies again.
      Specified by:
      close in interface AutoCloseable