CALL - is the generic type of the RemoteInvocationCall.REQUEST - is the generic type of the GenericRemoteInvocationRequest.RESPONSE - is the generic type of the GenericRemoteInvocationResponse.HANDLER - is the generic type of the GenericRemoteInvocationCallHandler.public abstract class AbstractGenericRemoteInvocationService<CALL extends RemoteInvocationCall,REQUEST extends GenericRemoteInvocationRequest<CALL,? extends GenericRemoteInvocationTransactionalCalls<CALL>>,RESPONSE extends GenericRemoteInvocationResponse,HANDLER extends GenericRemoteInvocationCallHandler<CALL>> extends AbstractLoggableComponent
GenericRemoteInvocationRpcService and
GenericRemoteInvocationCommandService. custom security checks or override the error
handling.| Modifier and Type | Class and Description |
|---|---|
class |
AbstractGenericRemoteInvocationService.RequestContext
A context object for stateful information related to the current
GenericRemoteInvocationRequest. |
| Modifier and Type | Field and Description |
|---|---|
private Map<String,HANDLER> |
callHandlerMap |
private ExceptionUtil |
exceptionUtil |
private int |
maximumCallsPerRequest |
private int |
maximumCallsPerTransaction |
private int |
maximumTransactionsPerRequest |
private RemoteInvocationSecurityDetector |
securityDetector |
private javax.validation.Validator |
validator |
private CsrfTokenManager |
xsrfTokenManager |
| Constructor and Description |
|---|
AbstractGenericRemoteInvocationService()
The constructor.
|
createLogger, getLoggerdoInitialized, getInitializationState, initializeprivate final Map<String,HANDLER extends GenericRemoteInvocationCallHandler<CALL>> callHandlerMap
private CsrfTokenManager xsrfTokenManager
getXsrfTokenManager()private RemoteInvocationSecurityDetector securityDetector
getSecurityDetector()private ExceptionUtil exceptionUtil
getExceptionUtil()private int maximumTransactionsPerRequest
getMaximumTransactionsPerRequest()private int maximumCallsPerTransaction
getMaximumCallsPerTransaction()private int maximumCallsPerRequest
getMaximumCallsPerRequest()private javax.validation.Validator validator
getValidator()public AbstractGenericRemoteInvocationService()
public RemoteInvocationSecurityDetector getSecurityDetector()
RemoteInvocationSecurityDetector to use.@Inject public void setSecurityDetector(RemoteInvocationSecurityDetector securityDetector)
securityDetector - is the RemoteInvocationSecurityDetector to Inject.public CsrfTokenManager getXsrfTokenManager()
@Inject public void setXsrfTokenManager(CsrfTokenManager xsrfTokenManager)
xsrfTokenManager - is the CsrfTokenManager to Inject.public ExceptionUtil getExceptionUtil()
ExceptionUtil to use.@Inject public void setExceptionUtil(ExceptionUtil exceptionUtil)
exceptionUtil - is the ExceptionUtil to Inject.public javax.validation.Validator getValidator()
Validator instance to use.@Inject public void setValidator(javax.validation.Validator validator)
validator - is the Validator to Inject.protected void doInitialize()
initialization. It is called when AbstractComponent.initialize() is
invoked for the first time. super.AbstractComponent.doInitialize().doInitialize in class AbstractLoggableComponentpublic int getMaximumTransactionsPerRequest()
transactions allowed per
request to prevent Denial of Service (DoS) attacks.public void setMaximumTransactionsPerRequest(int maximumTransactionsPerRequest)
maximumTransactionsPerRequest - is new value of getMaximumTransactionsPerRequest().public int getMaximumCallsPerTransaction()
RemoteInvocationCalls allowed per
transactions to prevent Denial of Service (DoS)
attacks.public void setMaximumCallsPerTransaction(int maximumCallsPerTransaction)
maximumCallsPerTransaction - is new value of getMaximumCallsPerTransaction().public int getMaximumCallsPerRequest()
RemoteInvocationCalls allowed per
request to prevent Denial of Service (DoS) attacks.public void setMaximumCallsPerRequest(int maximumCallsPerRequest)
maximumCallsPerRequest - is new value of getMaximumCallsPerRequest().protected void doSecurityCheck(AbstractGenericRemoteInvocationService.RequestContext context)
context - is the AbstractGenericRemoteInvocationService.RequestContext to check.private void checkDosLimit(int actualCount,
int maximumAllowedCount)
actualCount is less or equal to the given
maximumAllowedCount. Otherwise an exception is thrown.actualCount - the actual count.maximumAllowedCount - the maximum allowed count.protected RESPONSE processRequest(REQUEST request)
GenericRemoteInvocationRequest and creates the corresponding
GenericRemoteInvocationResponse.request - is the GenericRemoteInvocationRequest to process.GenericRemoteInvocationResponse to send back to the client.protected abstract RESPONSE createResponse(int requestId, CsrfToken xsrfToken, GenericRemoteInvocationTransactionalResults[] transactionalResults)
requestId - is the requestId.xsrfToken - is the xsrfToken.transactionalResults - are the transactional results.GenericRemoteInvocationRequest.protected abstract GenericRemoteInvocationTransactionalResults processCallsInTransaction(GenericRemoteInvocationTransactionalCalls<CALL> transactionalCalls, AbstractGenericRemoteInvocationService.RequestContext context) throws Exception
processTransactionalCalls(GenericRemoteInvocationTransactionalCalls, RequestContext) in a new
transaction. @Transactional you need to be aware that
you have to keep the annotated method out of this class as spring-aop uses dynamic proxies by default
that only support transactions when a method is called from outside the class and not for method calls
within a class. This is a typical pitfall and one of the reasons why we are using
mmm-transaction by default.transactionalCalls - is the GenericRemoteInvocationTransactionalCalls.context - is the AbstractGenericRemoteInvocationService.RequestContext to pass.GenericRemoteInvocationTransactionalResults.Exception - if anything goes wrong.protected GenericRemoteInvocationTransactionalResults processTransactionalCalls(GenericRemoteInvocationTransactionalCalls<CALL> transactionalCalls, AbstractGenericRemoteInvocationService.RequestContext context)
GenericRemoteInvocationTransactionalCalls.transactionalCalls - is the GenericRemoteInvocationTransactionalCalls.context - is the AbstractGenericRemoteInvocationService.RequestContext to pass.GenericRemoteInvocationTransactionalResults.protected Serializable processCall(CALL call, AbstractGenericRemoteInvocationService.RequestContext context) throws Throwable
RemoteInvocationCall. This method does not need to handle any
Exceptions as this is already done by the caller of this method.call - is the RemoteInvocationCall to invoke.context - is the AbstractGenericRemoteInvocationService.RequestContext.null.Throwable - in case of any kind of error.protected void handleLoginOperation(AbstractGenericRemoteInvocationService.RequestContext context)
context - is the AbstractGenericRemoteInvocationService.RequestContext.protected HANDLER getHandler(CALL call) throws ObjectNotFoundException
call - is the RemoteInvocationCall.GenericRemoteInvocationCallHandler.ObjectNotFoundException - if no handler exists for the given call.protected void registerHandler(HANDLER handler)
handler.handler - is the GenericRemoteInvocationCallHandler to register.protected int getHandlerCount()
registered
GenericRemoteInvocationCallHandlers.protected abstract String getHandlerId(CALL call)
call - is the RemoteInvocationCall.ID.protected RemoteInvocationCallFailedException handleCallFailure(CALL call, Throwable error)
Throwable occurred while processing a
RemoteInvocationCall.call - is the RemoteInvocationCall.error - is the Throwable that occurred.RemoteInvocationCallFailedException to throw.protected GenericRemoteInvocationTransactionalResults handleTxCallsFailure(GenericRemoteInvocationTransactionalCalls<CALL> txCall, Throwable error)
Throwable occurred while processing
GenericRemoteInvocationTransactionalCalls.txCall - is the GenericRemoteInvocationTransactionalCalls.error - is the Throwable that occurred.RemoteInvocationCallFailedException to throw.protected void logFailure(Object source, Throwable error)
error that occurred while processing the given source.source - is the source object. We do not use Object.toString() here as this is for debug
output and might contain confidential information such as passwords or whatever that we do not
want to log.error - is the Throwable to log.Copyright © 2001–2016 mmm-Team. All rights reserved.