Class AutoReleaseListener

  • All Implemented Interfaces:
    EventListener, WindowListener

    public class AutoReleaseListener
    extends Object
    implements WindowListener

    A specialized WindowListener implementation for implementing the auto release mechanism supported by builders.

    The results produced by a Builder usually need to be released when they are no longer needed to free the resources used by them. This can be done manually by invoking the Builder.release(BuilderData) method with the BuilderData object used for specifying the parameters of the builder operation.

    When a window is generated by a builder script, there is an alternative: it is possible to let the framework perform the release() invocation automatically when the window is closed. This is often useful, for instance when a dialog window is created from a builder script: when the user closes the dialog all resources associated with it (including beans defined in the script) are no more needed and can be released. To enable this mechanism the autoRelease property of BuilderData has to be set to true.

    This class implements the functionality for automatically releasing a BuilderData object when a window (i.e. the main window produced by the builder script) is closed. It does not rely on a concrete Builder implementation and thus can be used with arbitrary implementations. Concrete implementations of the Builder interface only need to create an instance and register it at the main window of the builder results.

    Client code typically will not have to use this class directly. The framework will create and initialize and instance behind the scenes when a BuilderData object configured appropriately is passed to a Builder.

    Version:
    $Id: AutoReleaseListener.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • AutoReleaseListener

        public AutoReleaseListener​(BuilderData data)
        Creates a new instance of AutoReleaseListener and sets the BuilderData object to be released automatically. This object must be fully initialized.
        Parameters:
        data - the BuilderData object (must not be null)
        Throws:
        IllegalArgumentException - if the data object is null or properties required are not set
    • Method Detail

      • windowActivated

        public void windowActivated​(WindowEvent event)
        Window activated event. This is just a dummy implementation.
        Specified by:
        windowActivated in interface WindowListener
        Parameters:
        event - the event
      • windowClosed

        public void windowClosed​(WindowEvent event)
        The window was closed. This will cause the BuilderData object to be released.
        Specified by:
        windowClosed in interface WindowListener
        Parameters:
        event - the event
      • windowDeactivated

        public void windowDeactivated​(WindowEvent event)
        Window deactivated event. This is just a dummy implementation.
        Specified by:
        windowDeactivated in interface WindowListener
        Parameters:
        event - the event
      • windowDeiconified

        public void windowDeiconified​(WindowEvent event)
        Window deiconified event. This is just a dummy implementation.
        Specified by:
        windowDeiconified in interface WindowListener
        Parameters:
        event - the event
      • windowIconified

        public void windowIconified​(WindowEvent event)
        Window iconified event. This is just a dummy implementation.
        Specified by:
        windowIconified in interface WindowListener
        Parameters:
        event - the event
      • windowOpened

        public void windowOpened​(WindowEvent event)
        Window opened event. This is just a dummy implementation.
        Specified by:
        windowOpened in interface WindowListener
        Parameters:
        event - the event
      • windowClosing

        public void windowClosing​(WindowEvent event)
        Window closing event. This is just a dummy implementation.
        Specified by:
        windowClosing in interface WindowListener
        Parameters:
        event - the event