Class LocalEventProducer

java.lang.Object
org.djutils.event.LocalEventProducer
All Implemented Interfaces:
EventProducer
Direct Known Subclasses:
EventProducingCollection, EventProducingIterator, EventProducingList, EventProducingMap, EventProducingSet

public class LocalEventProducer extends Object implements EventProducer
The LocalEventProducer defines the registration and fireEvent operations of an event producer. This behavior includes adding and removing listeners for a specific event type, and firing events for all kinds of different payloads. The EventListener and EventProducer together form a combination of the Publish-Subscribe design pattern and the Observer design pattern using the notify(event) method. See https://en.wikipedia.org/wiki/Publish-subscribe_pattern, https://en.wikipedia.org/wiki/Observer_pattern, and https://howtodoinjava.com/design-patterns/behavioral/observer-design-pattern/.

The EventProducer forms the reference implementation of the publish side of the pub/sub design pattern. The storage of the listeners is done in a Map with the EventType as the key, and a List of References (weak or strong) to the Listeners. Note that the term 'Local' used in the class name is opposed to remote event producers such as the RmiEventProducer.

Copyright (c) 2002-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html. This class was originally part of the DSOL project, see https://simulation.tudelft.nl/dsol/manual.

Author:
Peter Jacobs , Alexander Verbraeck
  • Constructor Details

    • LocalEventProducer

      public LocalEventProducer()
  • Method Details

    • getEventListenerMap

      public EventListenerMap getEventListenerMap()
      Description copied from interface: EventProducer
      Return the map with the EventListener entries and the reference types.
      Specified by:
      getEventListenerMap in interface EventProducer
      Returns:
      the map with the EventListener entries and the reference types