Package org.dspace.services.sessions
Class StatelessRequestServiceImpl
- java.lang.Object
-
- org.dspace.services.sessions.StatelessRequestServiceImpl
-
- All Implemented Interfaces:
RequestService
public final class StatelessRequestServiceImpl extends Object implements RequestService
Implementation of the session service.This depends on having something (a filter typically) which is placing the current requests into a request storage cache.
- Author:
- Aaron Zeckoski (azeckoski @ gmail.com), Tom Desair (tom dot desair at atmire dot com)
-
-
Field Summary
-
Fields inherited from interface org.dspace.services.RequestService
AUTHENTICATED_EPERSON
-
-
Constructor Summary
Constructors Constructor Description StatelessRequestServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears out the settings inside this service.String
endRequest(Exception failure)
Ends the current running request, this can indicate success or failure of the request, this will trigger the interceptors and normally would be caused by a servlet request ending, note that a request cannot be ended twice, once it is ended this will just return nullRequest
getCurrentRequest()
Finds out of there is a request running in this thread and if so returns itString
getCurrentRequestId()
Finds out of there is a request running in this thread and if so what the id of that request is.String
getCurrentUserId()
Access the current user id for the current session.void
init()
void
registerRequestInterceptor(RequestInterceptor interceptor)
Allows developers to perform actions on the start and end of the request cycle, if you decide you do not need to use your interceptor anymore then simply destroy it (dereference it) and the service will stop calling it, along those lines you should not register an interceptor that you do not keep a reference to (like an inline class or registerRequestListener(new YourInterceptor())) as this will be destroyed immediately, this registration is ClassLoader safevoid
setConfigurationService(ConfigurationService configurationService)
void
setCurrentUserId(UUID epersonId)
Set the ID of the current authenticated uservoid
shutdown()
String
startRequest()
Initiates a request in the system.String
startRequest(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
Initiates a request in the system, normally this would be triggered by a servlet request starting
Only one request can be associated with the current thread so if another one is running it will be destroyed and a new one will be created
Note that requests are expected to be manually ended somehow and will not be closed out automatically
-
-
-
Method Detail
-
setConfigurationService
@Autowired(required=true) public void setConfigurationService(ConfigurationService configurationService)
-
init
@PostConstruct public void init()
-
shutdown
@PreDestroy public void shutdown()
-
clear
public void clear()
Clears out the settings inside this service. Mostly for testing.
-
startRequest
public String startRequest()
Description copied from interface:RequestService
Initiates a request in the system. Normally this would be triggered by a servlet request starting.Only one request can be associated with the current thread, so if another one is running it will be destroyed and a new one will be created.
Note that requests are expected to be manually ended somehow and will not be closed out automatically.
- Specified by:
startRequest
in interfaceRequestService
- Returns:
- the unique generated id for the new request
-
startRequest
public String startRequest(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
Description copied from interface:RequestService
Initiates a request in the system, normally this would be triggered by a servlet request starting
Only one request can be associated with the current thread so if another one is running it will be destroyed and a new one will be created
Note that requests are expected to be manually ended somehow and will not be closed out automatically- Specified by:
startRequest
in interfaceRequestService
- Parameters:
request
- servlet requestresponse
- servlet response- Returns:
- the unique generated id for the new request
-
endRequest
public String endRequest(Exception failure)
Description copied from interface:RequestService
Ends the current running request, this can indicate success or failure of the request, this will trigger the interceptors and normally would be caused by a servlet request ending, note that a request cannot be ended twice, once it is ended this will just return null- Specified by:
endRequest
in interfaceRequestService
- Parameters:
failure
- (optional) this is the exception associated with the failure. Leave as null if the request is ending successfully. You can make up aRuntimeException
if you just need to indicate that the request failed.- Returns:
- the request ID if the request closes successfully and is not already closed OR null if there is no current request.
-
registerRequestInterceptor
public void registerRequestInterceptor(RequestInterceptor interceptor)
Description copied from interface:RequestService
Allows developers to perform actions on the start and end of the request cycle, if you decide you do not need to use your interceptor anymore then simply destroy it (dereference it) and the service will stop calling it, along those lines you should not register an interceptor that you do not keep a reference to (like an inline class or registerRequestListener(new YourInterceptor())) as this will be destroyed immediately, this registration is ClassLoader safe- Specified by:
registerRequestInterceptor
in interfaceRequestService
- Parameters:
interceptor
- an implementation ofRequestInterceptor
-
getCurrentUserId
public String getCurrentUserId()
Description copied from interface:RequestService
Access the current user id for the current session. (also available from the current session)- Specified by:
getCurrentUserId
in interfaceRequestService
- Returns:
- the id of the user associated with the current thread OR null if there is no user
-
setCurrentUserId
public void setCurrentUserId(UUID epersonId)
Description copied from interface:RequestService
Set the ID of the current authenticated user- Specified by:
setCurrentUserId
in interfaceRequestService
-
getCurrentRequestId
public String getCurrentRequestId()
Description copied from interface:RequestService
Finds out of there is a request running in this thread and if so what the id of that request is.- Specified by:
getCurrentRequestId
in interfaceRequestService
- Returns:
- the id of the current request for this thread OR null if there is not one
-
getCurrentRequest
public Request getCurrentRequest()
Description copied from interface:RequestService
Finds out of there is a request running in this thread and if so returns it- Specified by:
getCurrentRequest
in interfaceRequestService
- Returns:
- the current request for this thread OR null if there is not one
-
-