Package com.helger.servlet.async
Class ServletAsyncSpec
- java.lang.Object
-
- com.helger.servlet.async.ServletAsyncSpec
-
@Immutable public class ServletAsyncSpec extends Object
This class encapsulates all the parameters necessary to handle asynchronous servlet requests.- Since:
- 8.8.0
- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static longNO_TIMEOUTThe constant defining "no timeout defined"static ServletAsyncSpecSYNC_SPECThe constant for synchronous invocations
-
Constructor Summary
Constructors Modifier Constructor Description protectedServletAsyncSpec(boolean bAsynchronous, long nTimeoutMillis, Iterable<? extends jakarta.servlet.AsyncListener> aAsyncListeners)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyToAsyncContext(jakarta.servlet.AsyncContext aAsyncCtx)static ServletAsyncSpeccreateAsync(long nTimeoutMillis, Iterable<? extends jakarta.servlet.AsyncListener> aAsyncListeners)Create an async spec.static ServletAsyncSpeccreateAsyncDefault()Create an async spec with 999999 (debug mode) or 30 (production) seconds timeout and no async listeners.com.helger.commons.collection.impl.ICommonsList<jakarta.servlet.AsyncListener>getAllAsyncListeners()static ServletAsyncSpecgetSync()longgetTimeoutMillis()booleanhasAsyncListeners()booleanhasTimeoutMillis()booleanisAsynchronous()StringtoString()
-
-
-
Field Detail
-
NO_TIMEOUT
public static final long NO_TIMEOUT
The constant defining "no timeout defined"- See Also:
- Constant Field Values
-
SYNC_SPEC
public static final ServletAsyncSpec SYNC_SPEC
The constant for synchronous invocations
-
-
Constructor Detail
-
ServletAsyncSpec
protected ServletAsyncSpec(boolean bAsynchronous, @CheckForSigned long nTimeoutMillis, @Nullable Iterable<? extends jakarta.servlet.AsyncListener> aAsyncListeners)Constructor- Parameters:
bAsynchronous-truefor asynchronous stuff,falsefor synchronous spec.nTimeoutMillis- The timeout in milliseconds. Must be ≤ 0 for synchronous usage.aAsyncListeners-AsyncListeners to be added to the AsyncContext. Must benullfor synchronous usage.
-
-
Method Detail
-
getTimeoutMillis
@CheckForSigned public long getTimeoutMillis()
- Returns:
- The timeout in milliseconds. Only value > 0 are defined. Values ≤ 0 must be ignored.
-
hasTimeoutMillis
public boolean hasTimeoutMillis()
- Returns:
trueif a timeout is defined,falseotherwise. Only asynchronous definitions can have timeouts.
-
isAsynchronous
public boolean isAsynchronous()
- Returns:
truefor asynchronous,falsefor synchronous.
-
getAllAsyncListeners
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<jakarta.servlet.AsyncListener> getAllAsyncListeners()
- Returns:
- A copy of the list of all
AsyncListener. Only contains items if this is an asynchronous spec.
-
hasAsyncListeners
public boolean hasAsyncListeners()
- Returns:
trueif any async listener is present,falseotherwise.
-
applyToAsyncContext
public void applyToAsyncContext(@Nonnull jakarta.servlet.AsyncContext aAsyncCtx)
-
getSync
@Nonnull public static ServletAsyncSpec getSync()
- Returns:
- A synchronous spec. This always returns the constant value
SYNC_SPEC. Nevernull.
-
createAsync
@Nonnull public static ServletAsyncSpec createAsync(@CheckForSigned long nTimeoutMillis, @Nullable Iterable<? extends jakarta.servlet.AsyncListener> aAsyncListeners)
Create an async spec.- Parameters:
nTimeoutMillis- Timeout in milliseconds. Only value > 0 are considered.aAsyncListeners- The async listeners to use. May benull.- Returns:
- A new
ServletAsyncSpecand nevernull.
-
createAsyncDefault
@Nonnull public static ServletAsyncSpec createAsyncDefault()
Create an async spec with 999999 (debug mode) or 30 (production) seconds timeout and no async listeners.- Returns:
- A new
ServletAsyncSpecand nevernull.
-
-