net.sf.xaj.web
Class XmlDbBatchWebService

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.support.WebContentGenerator
              extended by org.springframework.web.servlet.mvc.AbstractController
                  extended by org.springframework.web.servlet.mvc.BaseCommandController
                      extended by org.springframework.web.servlet.mvc.AbstractCommandController
                          extended by net.sf.xaj.web.XmlDbBatchWebService
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.web.servlet.mvc.Controller

public class XmlDbBatchWebService
extends org.springframework.web.servlet.mvc.AbstractCommandController
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

Web service for managing long-running batch operations.

This web service allows for long-running transactions that span any number of HTTP requests. The normal use case is this:

  1. Call this service with the XmlDbWebConstants.BatchOperation.BEGIN_BATCH operation to begin the batch transaction. This will return a special HTTP header in the response, XmlDbWebConstants.TRANSACTION_ID_HEADER_NAME, whose value is the transaction ID of the transaction. You will need to also specify the XmlDb service for which you want to perform this batch operation against, using the XmlDbBatchWebService.Command.setXmlDbServiceName(String) value.
  2. Call this service again any number of times, passing the transaction ID returned in the first step as the XmlDbBatchWebService.Command.setTxId(String) value and the XmlDbWebConstants.BatchOperation.CONTINUE_BATCH operation. In this way you can store several XLM documents.
  3. When finished performing batch operations, call this service once more with the XmlDbWebConstants.BatchOperation.COMMIT_BATCH operation. This will commit the transaction and return a List of XmlResource IDs that were affected by the transaction. Alternatively, you can cll this service with the XmlDbWebConstants.BatchOperation.ABORT_BATCH operation, which will cause the transaction to rollback.

The configurable properties of this class are:

commitView
The name of the view to forward to for the XmlDbWebConstants.BatchOperation.COMMIT_BATCH operation. Defaults to batch-commit.
xmlDbManager
The XmlDbManager to use for obtaining XmlDb instances.

Version:
$Revision: 62 $ $Date: 2007-11-21 11:37:17 +1300 (Wed, 21 Nov 2007) $
Author:
matt

Nested Class Summary
static class XmlDbBatchWebService.Command
          Controller command object.
 
Field Summary
static int DEFAULT_BATCH_QUEUE_SIZE
          The default value for the batchQueueSize property.
static int DEFAULT_INFO_BATCH_PROCESS
          The default value for the infoBatchProgress property.
static long DEFAULT_MAX_SECONDS_OFFER_QUEUE
          The default value for the maxSecondsOfferQueue property.
static long DEFAULT_MAX_WAIT_BATCH_RESULTS
          The default value for the maxWaitForBatchResults property (14 hours).
static long DEFAULT_PAUSE_AFTER_DELETE
          The default value for the pauseAfterDeleteMs property.
static long DEFAULT_TRANSACTION_TIMEOUT
          The default value for the transactionTimeoutMs property (4 hours).
static long DEFAULT_TRANSACTION_TIMEOUT_PERIOD
          The default value for the transactionTimoutPeriodMs property.
static java.lang.String DELETE_RESULT_MODEL_KEY
          The model key for the Integer number resulting from a batch delete.
static java.lang.String XML_RESOURCE_IDS_MODEL_KEY
          The model key for the List of XmlResource IDs after a commit.
 
Fields inherited from class org.springframework.web.servlet.mvc.BaseCommandController
DEFAULT_COMMAND_NAME
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
HEADER_CACHE_CONTROL, HEADER_EXPIRES, HEADER_PRAGMA, METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
XmlDbBatchWebService()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 int getBatchQueueSize()
           
protected  java.lang.Object getCommand(javax.servlet.http.HttpServletRequest request)
           
 java.lang.String getCommitView()
           
 int getInfoBatchProgress()
           
 long getMaxSecondsOfferQueue()
           
 long getMaxWaitForBatchResults()
           
 long getPauseAfterDeleteMs()
           
 long getTransactionTimeoutMs()
           
 java.util.Timer getTransactionTimeoutTimer()
           
 long getTransactionTimoutPeriodMs()
           
 XmlDbManager getXmlDbManager()
           
protected  org.springframework.web.servlet.ModelAndView handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors)
           
 void setBatchQueueSize(int batchQueueSize)
           
 void setCommitView(java.lang.String commitView)
           
 void setInfoBatchProgress(int infoBatchProgress)
           
 void setMaxSecondsOfferQueue(long maxSecondsOfferQueue)
           
 void setMaxWaitForBatchResults(long maxWaitForBatchResults)
           
 void setPauseAfterDeleteMs(long pauseAfterDeleteMs)
           
 void setTransactionTimeoutMs(long transactionTimeoutMs)
           
 void setTransactionTimeoutTimer(java.util.Timer transactionTimeoutTimer)
           
 void setTransactionTimoutPeriodMs(long transactionTimoutPeriodMs)
           
 void setXmlDbManager(XmlDbManager xmlDbManager)
           
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractCommandController
handleRequestInternal
 
Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getValidator, getValidators, initApplicationContext, initBinder, isValidateOnBinding, onBind, onBind, onBindAndValidate, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setValidateOnBinding, setValidator, setValidators, suppressBinding, suppressValidation
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_RESOURCE_IDS_MODEL_KEY

public static final java.lang.String XML_RESOURCE_IDS_MODEL_KEY
The model key for the List of XmlResource IDs after a commit.

See Also:
Constant Field Values

DELETE_RESULT_MODEL_KEY

public static final java.lang.String DELETE_RESULT_MODEL_KEY
The model key for the Integer number resulting from a batch delete.

See Also:
Constant Field Values

DEFAULT_MAX_SECONDS_OFFER_QUEUE

public static final long DEFAULT_MAX_SECONDS_OFFER_QUEUE
The default value for the maxSecondsOfferQueue property.

See Also:
Constant Field Values

DEFAULT_BATCH_QUEUE_SIZE

public static final int DEFAULT_BATCH_QUEUE_SIZE
The default value for the batchQueueSize property.

See Also:
Constant Field Values

DEFAULT_MAX_WAIT_BATCH_RESULTS

public static final long DEFAULT_MAX_WAIT_BATCH_RESULTS
The default value for the maxWaitForBatchResults property (14 hours).

See Also:
Constant Field Values

DEFAULT_TRANSACTION_TIMEOUT

public static final long DEFAULT_TRANSACTION_TIMEOUT
The default value for the transactionTimeoutMs property (4 hours).

See Also:
Constant Field Values

DEFAULT_TRANSACTION_TIMEOUT_PERIOD

public static final long DEFAULT_TRANSACTION_TIMEOUT_PERIOD
The default value for the transactionTimoutPeriodMs property.

See Also:
Constant Field Values

DEFAULT_INFO_BATCH_PROCESS

public static final int DEFAULT_INFO_BATCH_PROCESS
The default value for the infoBatchProgress property.

See Also:
Constant Field Values

DEFAULT_PAUSE_AFTER_DELETE

public static final long DEFAULT_PAUSE_AFTER_DELETE
The default value for the pauseAfterDeleteMs property.

See Also:
Constant Field Values
Constructor Detail

XmlDbBatchWebService

public XmlDbBatchWebService()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

getCommand

protected java.lang.Object getCommand(javax.servlet.http.HttpServletRequest request)
                               throws java.lang.Exception
Overrides:
getCommand in class org.springframework.web.servlet.mvc.BaseCommandController
Throws:
java.lang.Exception

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

handle

protected org.springframework.web.servlet.ModelAndView handle(javax.servlet.http.HttpServletRequest request,
                                                              javax.servlet.http.HttpServletResponse response,
                                                              java.lang.Object command,
                                                              org.springframework.validation.BindException errors)
                                                       throws java.lang.Exception
Specified by:
handle in class org.springframework.web.servlet.mvc.AbstractCommandController
Throws:
java.lang.Exception

getCommitView

public java.lang.String getCommitView()
Returns:
the commitView

setCommitView

public void setCommitView(java.lang.String commitView)
Parameters:
commitView - the commitView to set

getXmlDbManager

public XmlDbManager getXmlDbManager()
Returns:
the xmlDbManager

setXmlDbManager

public void setXmlDbManager(XmlDbManager xmlDbManager)
Parameters:
xmlDbManager - the xmlDbManager to set

getBatchQueueSize

public int getBatchQueueSize()
Returns:
the batchQueueSize

setBatchQueueSize

public void setBatchQueueSize(int batchQueueSize)
Parameters:
batchQueueSize - the batchQueueSize to set

getMaxSecondsOfferQueue

public long getMaxSecondsOfferQueue()
Returns:
the maxSecondsOfferQueue

setMaxSecondsOfferQueue

public void setMaxSecondsOfferQueue(long maxSecondsOfferQueue)
Parameters:
maxSecondsOfferQueue - the maxSecondsOfferQueue to set

getMaxWaitForBatchResults

public long getMaxWaitForBatchResults()
Returns:
the maxWaitForBatchResults

setMaxWaitForBatchResults

public void setMaxWaitForBatchResults(long maxWaitForBatchResults)
Parameters:
maxWaitForBatchResults - the maxWaitForBatchResults to set

getTransactionTimeoutMs

public long getTransactionTimeoutMs()
Returns:
the transactionTimeoutMs

setTransactionTimeoutMs

public void setTransactionTimeoutMs(long transactionTimeoutMs)
Parameters:
transactionTimeoutMs - the transactionTimeoutMs to set

getTransactionTimeoutTimer

public java.util.Timer getTransactionTimeoutTimer()
Returns:
the transactionTimeoutTimer

setTransactionTimeoutTimer

public void setTransactionTimeoutTimer(java.util.Timer transactionTimeoutTimer)
Parameters:
transactionTimeoutTimer - the transactionTimeoutTimer to set

getTransactionTimoutPeriodMs

public long getTransactionTimoutPeriodMs()
Returns:
the transactionTimoutPeriodMs

setTransactionTimoutPeriodMs

public void setTransactionTimoutPeriodMs(long transactionTimoutPeriodMs)
Parameters:
transactionTimoutPeriodMs - the transactionTimoutPeriodMs to set

getInfoBatchProgress

public int getInfoBatchProgress()
Returns:
the infoBatchProgress

setInfoBatchProgress

public void setInfoBatchProgress(int infoBatchProgress)
Parameters:
infoBatchProgress - the infoBatchProgress to set

getPauseAfterDeleteMs

public long getPauseAfterDeleteMs()
Returns:
the pauseAfterDeleteMs

setPauseAfterDeleteMs

public void setPauseAfterDeleteMs(long pauseAfterDeleteMs)
Parameters:
pauseAfterDeleteMs - the pauseAfterDeleteMs to set