Class ALcdWeakLayeredListener<T>

java.lang.Object
com.luciad.view.ALcdWeakLayeredListener<T>
Type Parameters:
T - The type of the short-lived object
All Implemented Interfaces:
ILcdLayeredListener, Serializable, EventListener

public abstract class ALcdWeakLayeredListener<T> extends Object implements ILcdLayeredListener

An ILcdLayeredListener implementation which only keeps a WeakReference to the object it wants to update when layered events are received. This avoids memory leaks, even without removing the listener.

The class javadoc of ALcdWeakModelListener contains an example of a weak listener, and some rules on the usage of weak listeners.

Since:
2015.1
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ALcdWeakLayeredListener(T aObjectToModify)
    Creates a new ALcdWeakLayeredListener instance which can update aObjectToModify when it receives events.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Notify this ILcdLayeredListener that the state of an ILcdLayered has changed.
    protected abstract void
    layeredStateChangeImpl(T aToModify, TLcdLayeredEvent aLayeredEvent)
    This method is called each time a TLcdLayeredEvent is received by this listener, and the short-living object to modify passed in the constructor of this listener is not yet GC-ed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ALcdWeakLayeredListener

      protected ALcdWeakLayeredListener(T aObjectToModify)

      Creates a new ALcdWeakLayeredListener instance which can update aObjectToModify when it receives events.

      Parameters:
      aObjectToModify - The object you want to modify when a TLcdLayeredEvent is received. This is a short-lived object, while the listener will be attached to a long-living ILcdLayered object.
  • Method Details

    • layeredStateChanged

      public final void layeredStateChanged(TLcdLayeredEvent aLayeredEvent)
      Notify this ILcdLayeredListener that the state of an ILcdLayered has changed.

      This method will check whether the short-living object is still available. If it is, this method will pass the short-living object and the event to the layeredStateChangeImpl(Object, TLcdLayeredEvent) method. If the short-living object is already garbage collected, this method will de-register the listener from the source.

      Specified by:
      layeredStateChanged in interface ILcdLayeredListener
      See Also:
    • layeredStateChangeImpl

      protected abstract void layeredStateChangeImpl(T aToModify, TLcdLayeredEvent aLayeredEvent)

      This method is called each time a TLcdLayeredEvent is received by this listener, and the short-living object to modify passed in the constructor of this listener is not yet GC-ed.

      Parameters:
      aToModify - The object to modify, as passed in the constructor of this class.
      aLayeredEvent - The received event