Skip to content

djutils v2.1.2

Compare
Choose a tag to compare
@averbraeck averbraeck released this 04 Jan 00:22
· 460 commits to main since this release

Further enhanced the remote event producing and event listening capabilities of djutils to help the RmiEventProducer and RmiEventListener to work without issues.

djutils project, event package

  • New hashCode() and equals() implementation for Event and EventType
  • The EventListener and EventProducer interfaces are now Remote. Note that since Java 8u241, a not so well documented change has been made in Remote classes for RMI. See https://bugs.openjdk.org/browse/JDK-8237213: Only those methods specified in a "remote interface", an interface that DIRECTLY extends java.rmi.Remote are available remotely. This means that when the Remote interface is added in a sub-interface, methods are NOT available remotely. Repeating the method declaration in the interface that extends Remote will correctly indicate the method is a remote method. The base interface does not need to extend Remote if the method is re-declared in the Remote interface.
  • The EventProducer interface also implements all fireEvent() methods. This is to make it easier for classes implementing the EventProducer interface to immediately have all the publisher's behavior available. All methods throw RemoteException; the LocalEventProducer (which only needs to implement 1 real method now) wraps all methods with a try-catch, as no RemoteExceptions are to be expected from a LocalEventProducer. If such an Exception would happen, it wraps it in a RuntimeException.
  • The LocalEventProducer now extends the 'rich' EventProducer interface. All method implementations are embedded in the interface (addListener, removeListener, fireEvent, fireTimedEvent, etc.). The LocalEventProducer wraps these methods because it is not expected to throw a RemoteException.
  • The RmiEventProducer now extends the 'rich' EventProducer interface. All method implementations are embedded in the interface (addListener, removeListener, fireEvent, fireTimedEvent, etc.). Since all methods throw RemoteException, and the EventProducer interface extends Remote, the RmiEventProducer only has to implement a single method for the Event producing behavior.