org.springframework.batch.repeat.context
Class RepeatContextSupport

java.lang.Object
  extended by org.springframework.batch.repeat.context.SynchronizedAttributeAccessor
      extended by org.springframework.batch.repeat.context.RepeatContextSupport
All Implemented Interfaces:
RepeatContext, AttributeAccessor
Direct Known Subclasses:
CompositeCompletionPolicy.CompositeBatchContext, CountingCompletionPolicy.CountingBatchContext, SimpleCompletionPolicy.SimpleTerminationContext, TimeoutTerminationPolicy.TimeoutBatchContext

public class RepeatContextSupport
extends SynchronizedAttributeAccessor
implements RepeatContext


Constructor Summary
RepeatContextSupport(RepeatContext parent)
          Constructor for RepeatContextSupport.
 
Method Summary
 void close()
          Allow resources to be cleared, especially in destruction callbacks.
 RepeatContext getParent()
          If batches are nested, then the inner batch will be created with the outer one as a parent.
 int getStartedCount()
          Public access to a counter for the number of operations attempted.
 void increment()
          Used by clients to increment the started count.
 boolean isCompleteOnly()
          Public accessor for the complete flag.
 boolean isTerminateOnly()
          Public accessor for the termination flag.
 void registerDestructionCallback(String name, Runnable callback)
          Register a callback to be executed on close, associated with the attribute having the given name.
 void setCompleteOnly()
          Signal to the framework that the current batch should complete normally, independent of the current CompletionPolicy.
 void setTerminateOnly()
          Signal to the framework that the current batch should complete abnormally, independent of the current CompletionPolicy.
 
Methods inherited from class org.springframework.batch.repeat.context.SynchronizedAttributeAccessor
attributeNames, equals, getAttribute, hasAttribute, hashCode, removeAttribute, setAttribute, setAttributeIfAbsent, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.core.AttributeAccessor
attributeNames, getAttribute, hasAttribute, removeAttribute, setAttribute
 

Constructor Detail

RepeatContextSupport

public RepeatContextSupport(RepeatContext parent)
Constructor for RepeatContextSupport. The parent can be null, but should be set to the enclosing repeat context if there is one, e.g. if this context is an inner loop.

Parameters:
parent -
Method Detail

isCompleteOnly

public boolean isCompleteOnly()
Description copied from interface: RepeatContext
Public accessor for the complete flag.

Specified by:
isCompleteOnly in interface RepeatContext

setCompleteOnly

public void setCompleteOnly()
Description copied from interface: RepeatContext
Signal to the framework that the current batch should complete normally, independent of the current CompletionPolicy.

Specified by:
setCompleteOnly in interface RepeatContext

isTerminateOnly

public boolean isTerminateOnly()
Description copied from interface: RepeatContext
Public accessor for the termination flag. If this flag is set then the complete flag will also be.

Specified by:
isTerminateOnly in interface RepeatContext

setTerminateOnly

public void setTerminateOnly()
Description copied from interface: RepeatContext
Signal to the framework that the current batch should complete abnormally, independent of the current CompletionPolicy.

Specified by:
setTerminateOnly in interface RepeatContext

getParent

public RepeatContext getParent()
Description copied from interface: RepeatContext
If batches are nested, then the inner batch will be created with the outer one as a parent. This is an accessor for the parent if it exists.

Specified by:
getParent in interface RepeatContext
Returns:
the parent context or null if there is none

increment

public void increment()
Used by clients to increment the started count.


getStartedCount

public int getStartedCount()
Description copied from interface: RepeatContext
Public access to a counter for the number of operations attempted.

Specified by:
getStartedCount in interface RepeatContext
Returns:
the number of batch operations started.

registerDestructionCallback

public void registerDestructionCallback(String name,
                                        Runnable callback)
Description copied from interface: RepeatContext
Register a callback to be executed on close, associated with the attribute having the given name. The Runnable callback should not throw any exceptions.

Specified by:
registerDestructionCallback in interface RepeatContext
Parameters:
name - the name of the attribute to associated this callback with. If this attribute is removed the callback should never be called.
callback - a Runnable to execute when the context is closed.

close

public void close()
Description copied from interface: RepeatContext
Allow resources to be cleared, especially in destruction callbacks. Implementations should ensure that any registered destruction callbacks are executed here, as long as the corresponding attribute is still available.

Specified by:
close in interface RepeatContext


Copyright © 2008 SpringSource. All Rights Reserved.