Package org.marketcetera.util.spring
Class LazyBean
- java.lang.Object
-
- org.marketcetera.util.spring.LazyBean
-
- Direct Known Subclasses:
SpringSessionDescriptor,SpringSessionSettings
public abstract class LazyBean extends Object
A base class for a Spring bean which allows for on-demand post-processing. That is, one of more getters (of computed properties) may be guarded usingensureProcessed(), which will trigger processing of the bean's properties viaprocess(). After processing, no setter guarded withassertNotProcessed()(of raw properties) may be called, or else the bean may find itself in an inconsistent state whereby the computed properties do not match the raw ones. The receiver detects and blocks circular processing attempts, whereby two separate but mutually dependent beans attempt to process each other during their own processing, thereby leading to an endless cycle.- Since:
- 1.0.0
- Version:
- $Id: LazyBean.java 17411 2017-04-28 14:50:38Z colin $
- Author:
- tlerios@marketcetera.com
-
-
Field Summary
Fields Modifier and Type Field Description private booleanmProcessedprivate booleanmProcessing
-
Constructor Summary
Constructors Constructor Description LazyBean()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidassertNotProcessed()Asserts that the receiver is not processed.protected voidensureProcessed()Ensures that the receiver is already processed, possibly by invokingprocess().voidforceProcess()Processes or re-processes the receiver, regardless of whether it has been processed before or not.private booleangetProcessed()Returns the receiver's flag indicating that processing is complete.private booleangetProcessing()Returns the receiver's flag indicating that processing is ongoing.protected abstract voidprocess()Processes the receiver.private voidsetProcessed(boolean processed)Sets the receiver's flag indicating that processing is complete to the given value.private voidsetProcessing(boolean processing)Sets the receiver's flag indicating that processing is ongoing to the given value.
-
-
-
Method Detail
-
setProcessed
private void setProcessed(boolean processed)
Sets the receiver's flag indicating that processing is complete to the given value.- Parameters:
processed- The flag.
-
getProcessed
private boolean getProcessed()
Returns the receiver's flag indicating that processing is complete.- Returns:
- The flag.
-
setProcessing
private void setProcessing(boolean processing)
Sets the receiver's flag indicating that processing is ongoing to the given value.- Parameters:
processing- The flag.
-
getProcessing
private boolean getProcessing()
Returns the receiver's flag indicating that processing is ongoing.- Returns:
- The flag.
-
assertNotProcessed
protected void assertNotProcessed() throws I18NRuntimeExceptionAsserts that the receiver is not processed.- Throws:
I18NRuntimeException- Thrown if it is.
-
ensureProcessed
protected void ensureProcessed()
Ensures that the receiver is already processed, possibly by invokingprocess().- Throws:
I18NRuntimeException- Thrown if a nested invocation occurs.
-
process
protected abstract void process()
Processes the receiver. This method will only be called once throughensureProcessed().
-
forceProcess
public void forceProcess()
Processes or re-processes the receiver, regardless of whether it has been processed before or not.
-
-