The first example - a centralized system for event notification
In our first example, we are going to implement a system to send items from generators of events to consumers of events. We're going to use the SubmissionPublisher class to implement the communication between the producers and the consumers of events.
The Event class
This class stores the information of every item. Each item contains three attributes:
- The msgattribute, to store a message in theEvent
- The sourceattribute, to store the name of the class that produces theEvent
- The dateattribute, to store the date when theEventwas produced
You have to declare the three attributes as private and include the methods to get() and set() the values of the attributes in the class.
The Producer class
We're going to use this class to implement tasks that generate events that will be sent to the consumers using a SubmissionPublisher object. The class implements the Runnable interface and stores two attributes:
- The publisherattribute, that...
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                