Resolves checkstyle errors for event-* (#1070)
* Reduces checkstyle errors in event-aggregator * Reduces checkstyle errors in event-asynchronous * Reduces checkstyle errors in event-driven-architecture * Reduces checkstyle errors in event-queue * Reduces checkstyle errors in event-sourcing
This commit is contained in:
committed by
Ilkka Seppälä
parent
7c888e8886
commit
5ae2ce6e2e
@ -34,11 +34,11 @@ import com.iluwatar.eda.model.User;
|
||||
/**
|
||||
* An event-driven architecture (EDA) is a framework that orchestrates behavior around the
|
||||
* production, detection and consumption of events as well as the responses they evoke. An event is
|
||||
* any identifiable occurrence that has significance for system hardware or software. <p> The
|
||||
* example below uses an {@link EventDispatcher} to link/register {@link Event} objects to their
|
||||
* respective handlers once an {@link Event} is dispatched, it's respective handler is invoked and
|
||||
* the {@link Event} is handled accordingly.
|
||||
* any identifiable occurrence that has significance for system hardware or software.
|
||||
*
|
||||
* <p>The example below uses an {@link EventDispatcher} to link/register {@link Event} objects to
|
||||
* their respective handlers once an {@link Event} is dispatched, it's respective handler is invoked
|
||||
* and the {@link Event} is handled accordingly.
|
||||
*/
|
||||
public class App {
|
||||
|
||||
@ -47,9 +47,8 @@ public class App {
|
||||
* made known to the dispatcher by registering them. In this case the {@link UserCreatedEvent} is
|
||||
* bound to the UserCreatedEventHandler, whilst the {@link UserUpdatedEvent} is bound to the
|
||||
* {@link UserUpdatedEventHandler}. The dispatcher can now be called to dispatch specific events.
|
||||
* When a user is saved, the {@link UserCreatedEvent} can be dispatched.
|
||||
* On the other hand, when a user is updated, {@link UserUpdatedEvent} can be dispatched.
|
||||
*
|
||||
* When a user is saved, the {@link UserCreatedEvent} can be dispatched. On the other hand, when a
|
||||
* user is updated, {@link UserUpdatedEvent} can be dispatched.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
@ -23,12 +23,12 @@
|
||||
|
||||
package com.iluwatar.eda.event;
|
||||
|
||||
import com.iluwatar.eda.framework.EventDispatcher;
|
||||
import com.iluwatar.eda.framework.Event;
|
||||
import com.iluwatar.eda.framework.EventDispatcher;
|
||||
|
||||
/**
|
||||
* The {@link AbstractEvent} class serves as a base class for defining custom events happening with your
|
||||
* system. In this example we have two types of events defined.
|
||||
* The {@link AbstractEvent} class serves as a base class for defining custom events happening with
|
||||
* your system. In this example we have two types of events defined.
|
||||
* <ul>
|
||||
* <li>{@link UserCreatedEvent} - used when a user is created</li>
|
||||
* <li>{@link UserUpdatedEvent} - used when a user is updated</li>
|
||||
@ -38,9 +38,8 @@ import com.iluwatar.eda.framework.Event;
|
||||
public abstract class AbstractEvent implements Event {
|
||||
|
||||
/**
|
||||
* Returns the event type as a {@link Class} object
|
||||
* In this example, this method is used by the {@link EventDispatcher} to
|
||||
* dispatch events depending on their type.
|
||||
* Returns the event type as a {@link Class} object In this example, this method is used by the
|
||||
* {@link EventDispatcher} to dispatch events depending on their type.
|
||||
*
|
||||
* @return the AbstractEvent type as a {@link Class}.
|
||||
*/
|
||||
|
@ -26,9 +26,9 @@ package com.iluwatar.eda.event;
|
||||
import com.iluwatar.eda.model.User;
|
||||
|
||||
/**
|
||||
* The {@link UserCreatedEvent} should should be dispatched whenever a user has been created.
|
||||
* This class can be extended to contain details about the user has been created. In this example,
|
||||
* the entire {@link User} object is passed on as data with the event.
|
||||
* The {@link UserCreatedEvent} should should be dispatched whenever a user has been created. This
|
||||
* class can be extended to contain details about the user has been created. In this example, the
|
||||
* entire {@link User} object is passed on as data with the event.
|
||||
*/
|
||||
public class UserCreatedEvent extends AbstractEvent {
|
||||
|
||||
|
@ -26,9 +26,9 @@ package com.iluwatar.eda.event;
|
||||
import com.iluwatar.eda.model.User;
|
||||
|
||||
/**
|
||||
* The {@link UserUpdatedEvent} should should be dispatched whenever a user has been updated.
|
||||
* This class can be extended to contain details about the user has been updated. In this example,
|
||||
* the entire {@link User} object is passed on as data with the event.
|
||||
* The {@link UserUpdatedEvent} should should be dispatched whenever a user has been updated. This
|
||||
* class can be extended to contain details about the user has been updated. In this example, the
|
||||
* entire {@link User} object is passed on as data with the event.
|
||||
*/
|
||||
public class UserUpdatedEvent extends AbstractEvent {
|
||||
|
||||
|
@ -24,14 +24,15 @@
|
||||
package com.iluwatar.eda.framework;
|
||||
|
||||
/**
|
||||
* A {@link Event} is an object with a specific type that is associated
|
||||
* to a specific {@link Handler}.
|
||||
* A {@link Event} is an object with a specific type that is associated to a specific {@link
|
||||
* Handler}.
|
||||
*/
|
||||
public interface Event {
|
||||
|
||||
/**
|
||||
* Returns the message type as a {@link Class} object. In this example the message type is
|
||||
* used to handle events by their type.
|
||||
* Returns the message type as a {@link Class} object. In this example the message type is used to
|
||||
* handle events by their type.
|
||||
*
|
||||
* @return the message type as a {@link Class}.
|
||||
*/
|
||||
Class<? extends Event> getType();
|
||||
|
@ -27,8 +27,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Handles the routing of {@link Event} messages to associated handlers.
|
||||
* A {@link HashMap} is used to store the association between events and their respective handlers.
|
||||
* Handles the routing of {@link Event} messages to associated handlers. A {@link HashMap} is used
|
||||
* to store the association between events and their respective handlers.
|
||||
*/
|
||||
public class EventDispatcher {
|
||||
|
||||
|
@ -24,16 +24,18 @@
|
||||
package com.iluwatar.eda.framework;
|
||||
|
||||
/**
|
||||
* This interface can be implemented to handle different types of messages.
|
||||
* Every handler is responsible for a single of type message
|
||||
* This interface can be implemented to handle different types of messages. Every handler is
|
||||
* responsible for a single of type message
|
||||
*
|
||||
* @param <E> Handler can handle events of type E
|
||||
*/
|
||||
public interface Handler<E extends Event> {
|
||||
|
||||
/**
|
||||
* The onEvent method should implement and handle behavior related to the event.
|
||||
* This can be as simple as calling another service to handle the event on publishing the event on
|
||||
* a queue to be consumed by other sub systems.
|
||||
* The onEvent method should implement and handle behavior related to the event. This can be as
|
||||
* simple as calling another service to handle the event on publishing the event on a queue to be
|
||||
* consumed by other sub systems.
|
||||
*
|
||||
* @param event the {@link Event} object to be handled.
|
||||
*/
|
||||
void onEvent(E event);
|
||||
|
@ -27,8 +27,8 @@ import com.iluwatar.eda.event.UserCreatedEvent;
|
||||
import com.iluwatar.eda.event.UserUpdatedEvent;
|
||||
|
||||
/**
|
||||
* This {@link User} class is a basic pojo used to demonstrate user data sent along with
|
||||
* the {@link UserCreatedEvent} and {@link UserUpdatedEvent} events.
|
||||
* This {@link User} class is a basic pojo used to demonstrate user data sent along with the {@link
|
||||
* UserCreatedEvent} and {@link UserUpdatedEvent} events.
|
||||
*/
|
||||
public class User {
|
||||
|
||||
|
Reference in New Issue
Block a user