1 package org.djutils.event;
2
3 /**
4 * The LocalEventProducer defines the registration and fireEvent operations of an event producer. This behavior includes adding
5 * and removing listeners for a specific event type, and firing events for all kinds of different payloads. The EventListener
6 * and EventProducer together form a combination of the Publish-Subscribe design pattern and the Observer design pattern using
7 * the notify(event) method. See <a href="https://en.wikipedia.org/wiki/Publish-subscribe_pattern" target=
8 * "_blank">https://en.wikipedia.org/wiki/Publish-subscribe_pattern</a>,
9 * <a href="https://en.wikipedia.org/wiki/Observer_pattern" target="_blank">https://en.wikipedia.org/wiki/Observer_pattern</a>,
10 * and <a href="https://howtodoinjava.com/design-patterns/behavioral/observer-design-pattern/" target=
11 * "_blank">https://howtodoinjava.com/design-patterns/behavioral/observer-design-pattern/</a>.
12 * <p>
13 * The EventProducer forms the reference implementation of the publish side of the pub/sub design pattern. The storage of the
14 * listeners is done in a Map with the EventType as the key, and a List of References (weak or strong) to the Listeners. Note
15 * that the term 'Local' used in the class name is opposed to remote event producers such as the RmiEventProducer.
16 * </p>
17 * <p>
18 * Copyright (c) 2002-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
19 * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is
20 * distributed under a three-clause BSD-style license, which can be found at
21 * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>. This class was
22 * originally part of the DSOL project, see <a href="https://simulation.tudelft.nl/dsol/manual" target="_blank">
23 * https://simulation.tudelft.nl/dsol/manual</a>.
24 * </p>
25 * @author <a href="https://www.linkedin.com/in/peterhmjacobs">Peter Jacobs </a>
26 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
27 */
28 public class LocalEventProducer implements EventProducer
29 {
30 /** The collection of interested listeners. */
31 private EventListenerMap eventListenerMap = new EventListenerMap();
32
33 @Override
34 public EventListenerMap getEventListenerMap()
35 {
36 return this.eventListenerMap;
37 }
38
39 }