Class 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 using ensureProcessed(), which will trigger processing of the bean's properties via process(). After processing, no setter guarded with assertNotProcessed() (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 Detail

      • mProcessed

        private boolean mProcessed
      • mProcessing

        private boolean mProcessing
    • Constructor Detail

      • LazyBean

        public LazyBean()
    • 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.
      • ensureProcessed

        protected void ensureProcessed()
        Ensures that the receiver is already processed, possibly by invoking process().
        Throws:
        I18NRuntimeException - Thrown if a nested invocation occurs.
      • process

        protected abstract void process()
        Processes the receiver. This method will only be called once through ensureProcessed().
      • forceProcess

        public void forceProcess()
        Processes or re-processes the receiver, regardless of whether it has been processed before or not.