org.springframework.batch.core.step.item
Class SkipLimitStepFactoryBean

java.lang.Object
  extended by org.springframework.batch.core.step.item.AbstractStepFactoryBean
      extended by org.springframework.batch.core.step.item.SimpleStepFactoryBean
          extended by org.springframework.batch.core.step.item.SkipLimitStepFactoryBean
All Implemented Interfaces:
BeanNameAware, FactoryBean
Direct Known Subclasses:
StatefulRetryStepFactoryBean

public class SkipLimitStepFactoryBean
extends SimpleStepFactoryBean

Factory bean for step that provides options for configuring skip behavior. User can set setSkipLimit(int) to set how many exceptions of setSkippableExceptionClasses(Class[]) types are tolerated. setFatalExceptionClasses(Class[]) will cause immediate termination of job - they are treated as higher priority than setSkippableExceptionClasses(Class[]), so the two lists don't need to be exclusive.

Author:
Dave Syer, Robert Kasanicky
See Also:
SimpleStepFactoryBean, StatefulRetryStepFactoryBean

Constructor Summary
SkipLimitStepFactoryBean()
           
 
Method Summary
 void addFatalExceptionIfMissing(Class cls)
           
protected  void applyConfiguration(ItemOrientedStep step)
          Uses the setSkipLimit(int) value to configure item handler and and exception handler.
protected  Class[] getFatalExceptionClasses()
          Protected getter for the fatal exceptions.
protected  ItemKeyGenerator getItemKeyGenerator()
          Protected getter for the ItemKeyGenerator.
protected  ItemSkipPolicy getItemSkipPolicy()
          Protected getter for the ItemSkipPolicy.
 void setFatalExceptionClasses(Class[] fatalExceptionClasses)
          Public setter for exception classes that should cause immediate failure.
 void setItemKeyGenerator(ItemKeyGenerator itemKeyGenerator)
          Public setter for the ItemKeyGenerator.
 void setSkipCacheCapacity(int skipCacheCapacity)
          Public setter for the capacity of the skipped item cache.
 void setSkipLimit(int skipLimit)
          Public setter for a limit that determines skip policy.
 void setSkippableExceptionClasses(Class[] exceptionClasses)
          Public setter for exception classes that when raised won't crash the job but will result in transaction rollback and the item which handling caused the exception will be skipped.
 
Methods inherited from class org.springframework.batch.core.step.item.SimpleStepFactoryBean
getChunkOperations, getExceptionHandler, getItemHandler, getListeners, getStepOperations, setCommitInterval, setExceptionHandler, setItemHandler, setListeners, setStreams, setTaskExecutor
 
Methods inherited from class org.springframework.batch.core.step.item.AbstractStepFactoryBean
getItemReader, getItemWriter, getName, getObject, getObjectType, isSingleton, setAllowStartIfComplete, setBeanName, setItemReader, setItemWriter, setJobRepository, setSingleton, setStartLimit, setTransactionManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SkipLimitStepFactoryBean

public SkipLimitStepFactoryBean()
Method Detail

setSkipLimit

public void setSkipLimit(int skipLimit)
Public setter for a limit that determines skip policy. If this value is positive then an exception in chunk processing will cause the item to be skipped and no exception propagated until the limit is reached. If it is zero then all exceptions will be propagated from the chunk and cause the step to abort.

Parameters:
skipLimit - the value to set. Default is 0 (never skip).

setSkippableExceptionClasses

public void setSkippableExceptionClasses(Class[] exceptionClasses)
Public setter for exception classes that when raised won't crash the job but will result in transaction rollback and the item which handling caused the exception will be skipped.

Parameters:
exceptionClasses - defaults to Exception

setFatalExceptionClasses

public void setFatalExceptionClasses(Class[] fatalExceptionClasses)
Public setter for exception classes that should cause immediate failure.

Parameters:
fatalExceptionClasses - Error by default

getFatalExceptionClasses

protected Class[] getFatalExceptionClasses()
Protected getter for the fatal exceptions.

Returns:
the fatalExceptionClasses

setItemKeyGenerator

public void setItemKeyGenerator(ItemKeyGenerator itemKeyGenerator)
Public setter for the ItemKeyGenerator. This is used to identify failed items so they can be skipped if encountered again, generally in another transaction.

Parameters:
itemKeyGenerator - the ItemKeyGenerator to set.

getItemKeyGenerator

protected ItemKeyGenerator getItemKeyGenerator()
Protected getter for the ItemKeyGenerator.

Returns:
the ItemKeyGenerator

getItemSkipPolicy

protected ItemSkipPolicy getItemSkipPolicy()
Protected getter for the ItemSkipPolicy.

Returns:
the itemSkipPolicy

setSkipCacheCapacity

public void setSkipCacheCapacity(int skipCacheCapacity)
Public setter for the capacity of the skipped item cache. If a large number of items are failing and not being recognized as skipped, it usually signals a problem with the key generation (often equals and hashCode in the item itself). So it is better to enforce a strict limit than have weird looking errors, where a skip limit is reached without anything being skipped.
The default value is 1024 which should be high enough and more for most purposes. To breach the limit in a single-threaded step typically you have to have this many failures in a single transaction.

Parameters:
skipCacheCapacity - the capacity to set

applyConfiguration

protected void applyConfiguration(ItemOrientedStep step)
Uses the setSkipLimit(int) value to configure item handler and and exception handler.

Overrides:
applyConfiguration in class SimpleStepFactoryBean

addFatalExceptionIfMissing

public void addFatalExceptionIfMissing(Class cls)


Copyright © 2008 SpringSource. All Rights Reserved.