Package org.jboss.resteasy.core
Class AsynchronousDispatcher
- java.lang.Object
-
- org.jboss.resteasy.core.SynchronousDispatcher
-
- org.jboss.resteasy.core.AsynchronousDispatcher
-
- All Implemented Interfaces:
Dispatcher
@Path("/") public class AsynchronousDispatcher extends SynchronousDispatcher
- Version:
- $Revision: 1 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AsynchronousDispatcher.Cache
private static class
AsynchronousDispatcher.SecureRandomWrapper
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
basePath
private AsynchronousDispatcher.Cache
cache
private AsynchronousDispatcher.SecureRandomWrapper
counter
protected java.util.concurrent.ExecutorService
executor
private java.util.Map<java.lang.String,java.util.concurrent.Future<MockHttpResponse>>
jobs
private int
maxCacheSize
private long
maxWaitMilliSeconds
private int
threadPoolSize
-
Fields inherited from class org.jboss.resteasy.core.SynchronousDispatcher
bufferExceptionEntity, bufferExceptionEntityRead, defaultContextObjects, providerFactory, registry, requestPreprocessors, unwrappedExceptions
-
-
Constructor Summary
Constructors Constructor Description AsynchronousDispatcher(ResteasyProviderFactory providerFactory)
AsynchronousDispatcher(ResteasyProviderFactory providerFactory, ResourceMethodRegistry registry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.core.Response
get(long wait, java.lang.String jobId)
void
invoke(HttpRequest in, HttpResponse response, ResourceInvoker invoker)
Invoke and write responsevoid
invokeSuper(HttpRequest in, HttpResponse response, ResourceInvoker invoker)
boolean
isAsynchrnousRequest(HttpRequest in)
void
oneway(HttpRequest request, HttpResponse response, ResourceInvoker invoker)
void
postJob(HttpRequest request, HttpResponse response, ResourceInvoker invoker)
protected javax.ws.rs.core.Response
process(long wait, java.lang.String jobId, boolean eatJob)
javax.ws.rs.core.Response
readAndRemove(long wait, java.lang.String jobId)
void
remove(java.lang.String jobId)
void
setBasePath(java.lang.String basePath)
Set the base path to find jobsvoid
setExecutor(java.util.concurrent.ExecutorService executor)
Plug in your own executor to process requestsvoid
setMaxCacheSize(int maxCacheSize)
Max response cache size default is 100void
setMaxWaitMilliSeconds(long maxWaitMilliSeconds)
Maximum wait time.void
setThreadPoolSize(int threadPoolSize)
Fixed thread pool size of asynchronous deliveryvoid
start()
void
stop()
-
Methods inherited from class org.jboss.resteasy.core.SynchronousDispatcher
addHttpPreprocessor, asynchronousDelivery, asynchronousExceptionDelivery, clearContextData, execute, getDefaultContextObjects, getInvoker, getProviderFactory, getRegistry, getUnwrappedExceptions, internalInvocation, invoke, invokePropagateNotFound, preprocess, preprocess, pushContextObjects, writeException, writeResponse
-
-
-
-
Field Detail
-
executor
protected java.util.concurrent.ExecutorService executor
-
threadPoolSize
private int threadPoolSize
-
jobs
private java.util.Map<java.lang.String,java.util.concurrent.Future<MockHttpResponse>> jobs
-
cache
private AsynchronousDispatcher.Cache cache
-
basePath
private java.lang.String basePath
-
counter
private AsynchronousDispatcher.SecureRandomWrapper counter
-
maxWaitMilliSeconds
private long maxWaitMilliSeconds
-
maxCacheSize
private int maxCacheSize
-
-
Constructor Detail
-
AsynchronousDispatcher
public AsynchronousDispatcher(ResteasyProviderFactory providerFactory)
-
AsynchronousDispatcher
public AsynchronousDispatcher(ResteasyProviderFactory providerFactory, ResourceMethodRegistry registry)
-
-
Method Detail
-
setMaxCacheSize
public void setMaxCacheSize(int maxCacheSize)
Max response cache size default is 100- Parameters:
maxCacheSize
-
-
setMaxWaitMilliSeconds
public void setMaxWaitMilliSeconds(long maxWaitMilliSeconds)
Maximum wait time. This overrides any wait query parameter- Parameters:
maxWaitMilliSeconds
-
-
setBasePath
public void setBasePath(java.lang.String basePath)
Set the base path to find jobs- Parameters:
basePath
-
-
setThreadPoolSize
public void setThreadPoolSize(int threadPoolSize)
Fixed thread pool size of asynchronous delivery- Parameters:
threadPoolSize
-
-
setExecutor
public void setExecutor(java.util.concurrent.ExecutorService executor)
Plug in your own executor to process requests- Parameters:
executor
-
-
start
public void start()
-
stop
public void stop()
-
remove
@Path("{job-id}") @DELETE public void remove(@PathParam("job-id") java.lang.String jobId)
-
readAndRemove
@Path("{job-id}") @POST public javax.ws.rs.core.Response readAndRemove(@QueryParam("wait") @DefaultValue("-1") long wait, @PathParam("job-id") java.lang.String jobId)
-
get
@Path("{job-id}") @GET public javax.ws.rs.core.Response get(@QueryParam("wait") @DefaultValue("-1") long wait, @PathParam("job-id") java.lang.String jobId)
-
process
protected javax.ws.rs.core.Response process(long wait, java.lang.String jobId, boolean eatJob)
-
isAsynchrnousRequest
public boolean isAsynchrnousRequest(HttpRequest in)
-
invokeSuper
public void invokeSuper(HttpRequest in, HttpResponse response, ResourceInvoker invoker)
-
invoke
public void invoke(HttpRequest in, HttpResponse response, ResourceInvoker invoker)
Description copied from class:SynchronousDispatcher
Invoke and write response- Overrides:
invoke
in classSynchronousDispatcher
-
postJob
public void postJob(HttpRequest request, HttpResponse response, ResourceInvoker invoker)
-
oneway
public void oneway(HttpRequest request, HttpResponse response, ResourceInvoker invoker)
-
-