Architectural pattern: publisher-subscriber

Introduction This pattern is also know as ’Observer’ (GoF). The mainly difference is that in architectural patterns there is a distinction for what is a components and what is a connectors. Here i want show just a basic working without this distinction. Besides i want show how implement it using the API of java, utility class that simplify the java implementation. What is the problem I have one or more objects (observer or listner or subscriber) that are interested to know when there are some events from another object (subject or publisher) and they want be informed when it happen. When that event happen the subscriber can perform their action that can be different from subscriber to subscriber. How the publisher-subscriber work The first thing to do for the subscribers (or observers) is registering to the publisher (or subject) so they can be notified when a event happen. To do that they just use attach() method of ConcreteSubject. When there is an event (that maybe als...