Package org.dspace.utils.servicemanager
Class RequestExecutor
- java.lang.Object
-
- org.dspace.utils.servicemanager.RequestExecutor
-
- All Implemented Interfaces:
Runnable
public final class RequestExecutor extends Object implements Runnable
This will execute a request and ensure that it closes even if the thing that is being executed (run) dies. It will appropriately end the request based on the result of the execution and can start a new request or tie into an existing request if there is one.This is also a Runnable so it can be used as a wrapper which allows something to be executed inside a request.
- Author:
- Aaron Zeckoski (azeckoski @ gmail.com)
-
-
Constructor Summary
Constructors Constructor Description RequestExecutor(RequestService requestService, Runnable toExecute)
Create an executor which can be used to execute the runnable within a request by calling the execute method.RequestExecutor(RequestService requestService, Runnable toExecute, boolean useExistingRequestIfPossible)
Create an executor which can be used to execute the runnable within a request by calling the execute method.
-
-
-
Constructor Detail
-
RequestExecutor
public RequestExecutor(RequestService requestService, Runnable toExecute)
Create an executor which can be used to execute the runnable within a request by calling the execute method. This will create a new request to execute the code in when the execute method is called. All parameters are required.- Parameters:
requestService
- the request servicetoExecute
- the code to execute- Throws:
IllegalArgumentException
- if the params are null
-
RequestExecutor
public RequestExecutor(RequestService requestService, Runnable toExecute, boolean useExistingRequestIfPossible)
Create an executor which can be used to execute the runnable within a request by calling the execute method. All parameters are required.- Parameters:
requestService
- the request servicetoExecute
- the code to executeuseExistingRequestIfPossible
- if true then this will try to attach to an existing request and will create a new request if none is found, if false it will create a new request to execute in- Throws:
IllegalArgumentException
- if the params are null
-
-
Method Detail
-
execute
public void execute()
- Throws:
RequestInterceptor.RequestInterruptionException
- if the method fails
-
-