Design and Architecture of Complex Software Systems (DACSS)

Assignment 2: The Reflection Pattern - Track A: Using reflective features of programming languages

Another EventBus

This is one of the choices for Assignment 2.

Objectives: Using reflective properties of programming languages - using Dynamic Method Discovery and Invocation

Assignment description

Using reflective capabilities of java (java.lang.reflection) or .NET (System.Reflection) implement another EventBus.

The EventNotifier implementation discussed in Lecture of Week 3 and used in Asignment 1 has a set of limitations: all Subscribers must implement a given interface, which is part of the EventBus API. This interface defines the signature of the accepted "handler" method, which establishes the type of the handler argument to the most general Event type. Subscribers that subscribe to specialized event types must explicitly cast.

Requirements

Implement another Event Bus, where subscribers do not have to implement a Subscriber interface which is predefined by the EventBus API, but they can freely subscribe to different Event Types and provide their own types of event handlers, which have as arguments their own specialized Event Type of interest.

The implementation of the EventBus will use Dynamic Method Discovery and Invocation in order to dispatch an event notification to the subscribers (use dynamic invocation by reflection to call the specific handler method).

The EventBus will keep a list of registrations. Each registration is defined by the following tuple: the subscriber object, the subscribed event type, the event handler function, and a filter with filter function, where the filter may also be null. More details about the requirements and possible ways to solutions are presented in slides with details for this assignment.

.