ResultType
- The class that is used for the result of the request.RequesteeType
- The type of a context parameter to pass from calls to getRequest
to getCallable.public abstract class RequestMaker<ResultType extends IRequestResult,RequesteeInterfaceType,RequesteeType extends RequesteeInterfaceType> extends Object
This class hides the complicated process of creating and reusing request objects. Sub classes just need to return a Callable from getCallable that will return the result of the request.
Constructor and Description |
---|
RequestMaker() |
Modifier and Type | Method and Description |
---|---|
protected abstract Callable<ResultType> |
getCallable(RequesteeType u)
Called to get the callable that computes the result of the request.
|
IRequest<ResultType,RequesteeInterfaceType> |
getRequest(RequesteeType u,
AtomicReference<IRequest<ResultType,RequesteeInterfaceType>> atomicRef,
Workspace workspace,
boolean isNeededForFileScope)
Gets a reference to a request object, by either creating a new IRequest
or returning an existing one from the specified AtomicReference.
|
protected abstract ResultType |
getResultForThrowable(RequesteeType u,
Throwable t)
Called to get the Result when an uncaught throwable was detected.
|
public final IRequest<ResultType,RequesteeInterfaceType> getRequest(RequesteeType u, AtomicReference<IRequest<ResultType,RequesteeInterfaceType>> atomicRef, Workspace workspace, boolean isNeededForFileScope)
If a new IRequest is created the atomicRef is updated to point at it.
u
- Parameter that is passed through to getCallable if a new Request
is created.atomicRef
- An AtomicReference which contains a reference to an
existing IRequest or which will be updated to point to the IRequest this
method creates.workspace
- The workspace which contains the ExecutorService which
is used to schedule processing to compute the IRequestResult.isNeededForFileScope
- true if the request is needed to build a file
scope.protected abstract Callable<ResultType> getCallable(RequesteeType u)
u
- Parameter that was passed to getRequest.protected abstract ResultType getResultForThrowable(RequesteeType u, Throwable t)
u
- Parameter that was passed to getRequest.t
- Throwable that was thrown from the Callable returned from
getCallable.Copyright © 2016 The Apache Software Foundation. All rights reserved.