M - The message type.public interface Channel<M>
In the context of a service or similar, events can occur about which interested participants may need to be
notified. For example, a property of the service may change. A Channel is defined for each relevant
event type in the context of the service and in this way the event type is linked to a message type.
Last but not least, the service is the origin of the messages to be sent. Each channel "knows" how the
service will deliver the message to be transmitted. Example:
public class SampleService {
private Path path;
private Instant timestamp;
// ...
public interface Channel<M> extends de.team33.patterns.notes.eris.Channel<M>, Function<SampleService, M> {
Channel<Path> NEW_PATH = service -> service.path;
Channel<Instant> NEW_TIMESTAMP = service -> service.timestamp;
Channel<SampleService> UPDATED = service -> service;
}
}
This example defines a context-specific derivation of Channel that also "knows" a method to get a
corresponding message from the service.
In principle, this is not necessary, but it simplifies the structuring and formulation of the individual constants.Copyright © 2024 Andreas Kluge-Kaindl, Bremen (de). All rights reserved.