Class RequestInterceptorExample
- java.lang.Object
-
- org.dspace.servicemanager.example.RequestInterceptorExample
-
- All Implemented Interfaces:
OrderedService
,RequestInterceptor
public final class RequestInterceptorExample extends Object implements RequestInterceptor
A sample RequestInterceptor which simply logs request start and end calls.- Version:
- $Revision$
- Author:
- Mark Diggory (mdiggory at atmire.com)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.dspace.services.model.RequestInterceptor
RequestInterceptor.RequestInterruptionException
-
-
Constructor Summary
Constructors Constructor Description RequestInterceptorExample(RequestService service)
Constructor which will inject the instantiated Interceptor into a service handed to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getOrder()
Sets the order to load the bean which implements this method compared to other beans of the same type.void
onEnd(String requestId, boolean succeeded, Exception failure)
Take actions after the request is handled for an operation.void
onStart(String requestId)
Take actions before the request is handled for an operation.
-
-
-
Constructor Detail
-
RequestInterceptorExample
public RequestInterceptorExample(RequestService service)
Constructor which will inject the instantiated Interceptor into a service handed to it.- Parameters:
service
- the service
-
-
Method Detail
-
onEnd
public void onEnd(String requestId, boolean succeeded, Exception failure)
Description copied from interface:RequestInterceptor
Take actions after the request is handled for an operation. This will be called just before each operation is totally completed. For example: closing a transaction would happen at this point.If you want to interrupt the handling of this request (stop it) then throw a
RequestInterceptor.RequestInterruptionException
.NOTE: it is important to realize that this will be called even if the request fails. Please check the incoming success param to see if this request was successful or not. This is your cue to rollback or commit, for example.
- Specified by:
onEnd
in interfaceRequestInterceptor
- Parameters:
requestId
- the unique id of the requestsucceeded
- true if the request operations were successful, false if there was a failurefailure
- this is the exception associated with the failure, it is null if there is no associated exception
-
onStart
public void onStart(String requestId)
Description copied from interface:RequestInterceptor
Take actions before the request is handled for an operation. This will be called just before each request is sent to the correct request handler. For example: starting a transaction would happen at this point.If you want to interrupt the handling of this request (stop it) then throw a
RequestInterceptor.RequestInterruptionException
.- Specified by:
onStart
in interfaceRequestInterceptor
- Parameters:
requestId
- the unique id of the request
-
getOrder
public int getOrder()
Description copied from interface:OrderedService
Sets the order to load the bean which implements this method compared to other beans of the same type. Lower orders (numbers) will be loaded first (i.e. order 1 will appear before order 3 in the list). Orders do not have to be consecutive (there can be gaps). Beans with the same order or beans with no order set will be ordered randomly.- Specified by:
getOrder
in interfaceOrderedService
- Returns:
- an int which represents the loading order
-
-