@Provider public class AsynchronousJobPool extends Object implements javax.ws.rs.ext.ContextResolver<AsynchronousJobPool>
| Modifier and Type | Class and Description |
|---|---|
static class |
AsynchronousJobPool.ManyJobsPolicy |
| Modifier and Type | Field and Description |
|---|---|
protected String |
asynchronousServicePath |
protected int |
jobTimeout
When timeout (in minutes) reached then an asynchronous job may be removed from the pool.
|
protected int |
maxCacheSize
Max cache size.
|
| Constructor and Description |
|---|
AsynchronousJobPool(EverrestConfiguration config) |
| Modifier and Type | Method and Description |
|---|---|
AsynchronousJob |
addJob(Object resource,
ResourceMethodDescriptor resourceMethod,
Object[] params) |
List<AsynchronousJob> |
getAll() |
protected javax.ws.rs.core.UriBuilder |
getAsynchronousJobUriBuilder(AsynchronousJob job) |
AsynchronousJobPool |
getContext(Class<?> type) |
AsynchronousJob |
getJob(Long jobId) |
protected void |
initAsynchronousJobContext(AsynchronousJob job)
Init context of asynchronous job.
|
protected ExecutorService |
makeExecutorService(EverrestConfiguration config) |
protected Callable<Object> |
newCallable(Object resource,
Method method,
Object[] params) |
boolean |
registerListener(AsynchronousJobListener listener)
Register new listener if it is not registered yet.
|
AsynchronousJob |
removeJob(Long jobId) |
void |
stop() |
boolean |
unregisterListener(AsynchronousJobListener listener)
Unregister listener.
|
protected final String asynchronousServicePath
protected final int jobTimeout
protected final int maxCacheSize
public AsynchronousJobPool(EverrestConfiguration config)
protected ExecutorService makeExecutorService(EverrestConfiguration config)
public AsynchronousJobPool getContext(Class<?> type)
getContext in interface javax.ws.rs.ext.ContextResolver<AsynchronousJobPool>ContextResolver.getContext(java.lang.Class)public final AsynchronousJob addJob(Object resource, ResourceMethodDescriptor resourceMethod, Object[] params) throws AsynchronousJobRejectedException
resource - object that contains resource methodresourceMethod - resource or sub-resource method to invokeparams - method parametersAsynchronousJobRejectedException - if this task cannot be added to poolprotected void initAsynchronousJobContext(AsynchronousJob job)
AsynchronousJob.getContext()
and add required context parameter. This method is invoked by thread that adds new job.
This implementation does nothing, but may be customized in subclasses.protected javax.ws.rs.core.UriBuilder getAsynchronousJobUriBuilder(AsynchronousJob job)
public AsynchronousJob getJob(Long jobId)
public AsynchronousJob removeJob(Long jobId)
public List<AsynchronousJob> getAll()
public boolean registerListener(AsynchronousJobListener listener)
listener - listenertrue if new listener registered and false otherwise.AsynchronousJobListenerpublic boolean unregisterListener(AsynchronousJobListener listener)
listener - listener to unregistertrue if listener unregistered and false otherwise.AsynchronousJobListener@PreDestroy public void stop()
Copyright © 2015. All rights reserved.