java.lang.Object
ch.ralscha.extdirectspring.controller.Configuration

public class Configuration extends Object
Configuration class to configure different aspects of extdirectspring.
  • Constructor Details

    • Configuration

      public Configuration()
  • Method Details

    • getDefaultExceptionMessage

      public String getDefaultExceptionMessage()
    • setDefaultExceptionMessage

      public void setDefaultExceptionMessage(String defaultExceptionMessage)
      Changes the default message when an exception occurred and there is no mapping found in getExceptionToMessage() and isSendExceptionMessage() is false.

      Default value is "Server Error".

      This value is set into BaseResponse.setMessage(String) and sent to the client.

      Parameters:
      defaultExceptionMessage - new default exception message
      See Also:
    • isSendExceptionMessage

      public boolean isSendExceptionMessage()
    • setSendExceptionMessage

      public void setSendExceptionMessage(boolean sendExceptionMessage)
      Changes the way BaseResponse.setMessage(String) is called.

      If this flag is set to true and an exception occurred instead of getDefaultExceptionMessage() Throwable.getMessage() is put into the message field of the response. Only if there is no mapping found in getExceptionToMessage().

      Default value is false.

      Parameters:
      sendExceptionMessage - new flag
      See Also:
    • isSendStacktrace

      public boolean isSendStacktrace()
    • setSendStacktrace

      public void setSendStacktrace(boolean sendStacktrace)
      If sendStacktrace is true, the library sends, in case of an exception, the full stacktrace in BaseResponse.setWhere(String) back to the client.

      Should only set to true in development.

      Default value is false

      Parameters:
      sendStacktrace - new flag
    • getExceptionToMessage

      public Map<Class<?>,String> getExceptionToMessage()
    • setExceptionToMessage

      public void setExceptionToMessage(Map<Class<?>,String> exceptionToMessage)
      Sets the new exception-to-message map.

      If there is a mapping for the exception in getExceptionToMessage() and the value is not null put this value in BaseResponse.setMessage(String).

      If there is a mapping for the exception in getExceptionToMessage() and the value is null use Throwable.getMessage().

      If there is no mapping and isSendExceptionMessage() is true use Throwable.getMessage().

      If there is no mapping and isSendExceptionMessage() is false use getDefaultExceptionMessage().

      Parameters:
      exceptionToMessage - new mapping from exception to message
      See Also:
    • isAlwaysWrapStoreResponse

      public boolean isAlwaysWrapStoreResponse()
    • setAlwaysWrapStoreResponse

      public void setAlwaysWrapStoreResponse(boolean alwaysWrapStoreResponse)
      If alwaysWrapStoreResponse is true, responses of STORE_READ and STORE_MODIFY methods are always wrapped in an ExtDirectStoreResult object.
      Parameters:
      alwaysWrapStoreResponse - new flag
    • isSynchronizeOnSession

      public boolean isSynchronizeOnSession()
    • setSynchronizeOnSession

      public void setSynchronizeOnSession(boolean synchronizeOnSession)
      If synchronizeOnSession is true, execution of all methods is synchronized on the session object. To serialize parallel invocations from the same client and to prevent concurrency issues if the server accesses global or session resources.

      Instead of globally enable this it's possible to set the flag on a per method basis with ExtDirectMethod.synchronizeOnSession().

      Parameters:
      synchronizeOnSession - new flag
    • getTimeout

      public Integer getTimeout()
    • setTimeout

      public void setTimeout(Integer timeout)
      Sets the timeout in milliseconds for remote calls. This parameter is part of the configuration object api.js sends to the client and configures the timeout property of the RemotingProvider.
      Parameters:
      timeout - new timeout value
    • getMaxRetries

      public Integer getMaxRetries()
    • setMaxRetries

      public void setMaxRetries(Integer maxRetries)
      Sets the number of times the client will try to send a message to the server before throwing a failure. Default value is 1. This parameter is part of the configuration object api.js sends to the client and configures the maxRetries property of the RemotingProvider.
      Parameters:
      maxRetries - new number of max retries
    • getEnableBuffer

      public Object getEnableBuffer()
    • setEnableBuffer

      public void setEnableBuffer(Object enableBuffer)
      true or false to enable or disable combining of method calls. If a number is specified this is the amount of time in milliseconds to wait before sending a batched request. Calls which are received within the specified timeframe will be concatenated together and sent in a single request, optimizing the application by reducing the amount of round trips that have to be made to the server.

      This parameter is part of the configuration object api.js sends to the client and configures the enableBuffer property of the RemotingProvider.

      Defaults to: 10

      Parameters:
      enableBuffer - new enableBuffer value
    • getBufferLimit

      public Integer getBufferLimit()
    • setBufferLimit

      public void setBufferLimit(Integer bufferLimit)
      The maximum number of requests to batch together. By default, an unlimited number of requests will be batched. This option will allow to wait only for a certain number of Direct method calls before dispatching a request to the server, even if enableBuffer timeout has not yet expired.

      Note that this option does nothing if enableBuffer is set to `false`.

      Defaults to: Number.MAX_VALUE

      Parameters:
      bufferLimit - new value for buffer limit
    • getMessage

      public String getMessage(Throwable exception)
      Returns an error message for the supplied exception and based on this configuration.
      Parameters:
      exception - the thrown exception
      Returns:
      exception message
      See Also:
    • isStreamResponse

      public boolean isStreamResponse()
    • setStreamResponse

      public void setStreamResponse(boolean streamResponse)
      If streamResponse is true, the JSON response will be directly written into the ServletResponse.getOutputStream() without setting the Content-Length header. The old ExtDirectSpring 1.0.x behavior.

      If false the RouterController writes the JSON into an internal buffer, sets the Content-Length header in HttpServletResponse and writes the buffer into ServletResponse.getOutputStream().

      Instead of globally enable this it's possible to set the flag on a per method basis with ExtDirectMethod.streamResponse().

      Default value is false

      Parameters:
      streamResponse - new flag
    • setJsContentType

      public void setJsContentType(String jsContentType)
      Specifies the Content-Type for api.js and api-debug.js.

      Until version 1.2.1 extdirectspring sends "application/x-javascript". But according to RFC4329 the official mime type is 'application/javascript'.

      Default value is "application/javascript"

      Parameters:
      jsContentType - new Content-type
    • getJsContentType

      public String getJsContentType()
    • getBatchedMethodsExecutionPolicy

      public BatchedMethodsExecutionPolicy getBatchedMethodsExecutionPolicy()
    • setBatchedMethodsExecutionPolicy

      public void setBatchedMethodsExecutionPolicy(BatchedMethodsExecutionPolicy batchedMethodsExecutionPolicy)
      Specifies how batched methods sent from the client should be executed on the server. BatchedMethodsExecutionPolicy.SEQUENTIAL executes methods one after the other. BatchedMethodsExecutionPolicy.CONCURRENT executes methods concurrently with the help of a thread pool.

      Default value is BatchedMethodsExecutionPolicy.SEQUENTIAL

      Parameters:
      batchedMethodsExecutionPolicy - new policy
      See Also:
    • getBatchedMethodsExecutorService

      public ExecutorService getBatchedMethodsExecutorService()
    • setBatchedMethodsExecutorService

      public void setBatchedMethodsExecutorService(ExecutorService batchedMethodsExecutorService)
      Sets the thread pool used for executing batched methods concurrently.

      If batchedMethodsExecutionPolicy is set to BatchedMethodsExecutionPolicy.CONCURRENT but no batchedMethodsExecutorService is specified the library creates a Executors.newFixedThreadPool(int) with 5 threads.

      Parameters:
      batchedMethodsExecutorService - the new thread pool
      See Also:
    • getProviderType

      public String getProviderType()
    • setProviderType

      public void setProviderType(String providerType)
      Sets the type of the provider. The type is sent to the client in the api configuration.

      Default value is "remoting" and it creates an Ext.direct.RemotingProvider on the client side.

      Parameters:
      providerType - new provider type
    • getFrameDomain

      public String getFrameDomain()
    • setFrameDomain

      public void setFrameDomain(String frameDomain)
      Sets the passed domain to be included in the file upload's temporary frame. This is used to grant the main document access to the POST response on the frame in a cross-domain environment.
      Parameters:
      frameDomain - the new domain to set the frame to
    • getFrameDomainScript

      public String getFrameDomainScript()
    • setFrameDomainScript

      public void setFrameDomainScript(String frameDomainScript)
      Updates the script that is used to set the domain values on the file upload frame. This is useful for cross-browser compatibility. If other browsers require a modified script as workaround, frameDomainScript should allow for it.
      Parameters:
      frameDomainScript - the javascript code used to set the frame domain
    • getApiNs

      public String getApiNs()
    • setApiNs

      public void setApiNs(String apiNs)
      Sets the name of the namespace in which the remotingApiVar variable will reside.

      Defaults to Ext.app

      Parameters:
      apiNs - new namespace
    • getActionNs

      public String getActionNs()
    • setActionNs

      public void setActionNs(String actionNs)
      Sets the name of the namespace in which the actions will reside.

      Defaults to none

      Parameters:
      actionNs - new namespace
    • getRemotingApiVar

      public String getRemotingApiVar()
    • setRemotingApiVar

      public void setRemotingApiVar(String remotingApiVar)
      Changes the name of the remoting api variable.

      Defaults to REMOTING_API

      Parameters:
      remotingApiVar - new remoting api varaible name
    • getPollingUrlsVar

      public String getPollingUrlsVar()
    • setPollingUrlsVar

      public void setPollingUrlsVar(String pollingUrlsVar)
      Changes the name of the polling urls object variable

      Defaults to POLLING_URLS

      Parameters:
      pollingUrlsVar - new polling urls object variable name
    • isFullRouterUrl

      public boolean isFullRouterUrl()
    • setFullRouterUrl

      public void setFullRouterUrl(boolean fullRouterUrl)
      Specifies if the router property should contain the full URL including protocol, server name, port number, and server path (true) or only the server path (false)

      Defaults to false

      Parameters:
      fullRouterUrl - new flag value
    • getBaseRouterUrl

      public String getBaseRouterUrl()
    • setBaseRouterUrl

      public void setBaseRouterUrl(String baseRouterUrl)
      If not null the ApiController does not use the url of the request to determine the router url instead he uses the value of this variable as the base and adds /router and /poll.
      The fullRouterUrl setting is ignored when this variable is not null

      Defaults to null.

      Parameters:
      baseRouterUrl - new base router url
    • getConversionService

      public org.springframework.core.convert.ConversionService getConversionService()
    • setConversionService

      public void setConversionService(org.springframework.core.convert.ConversionService conversionService)
    • getJsonHandler

      public JsonHandler getJsonHandler()
    • setJsonHandler

      public void setJsonHandler(JsonHandler jsonHandler)
    • postProcessRequestUrl

      public String postProcessRequestUrl(jakarta.servlet.http.HttpServletRequest request, String requestUrlString)