diff --git a/README.md b/README.md index 48845cd..0f839c5 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ This library allows passing events between different objects without them having a direct reference to each other. Any object can serve as an event. -Using an instance of the `EventBus` class, an instant of the event class can be dispatched. +Using an instance of the `EventBus` class, an instance of the event class can be dispatched. This means that it will be forwarded to all listeners registered for it at the event bus. In addition, a singleton instance of the event bus is provided by the `EventBus#getInstance()` method. To listen to events, register event handling methods using the `Event` annotation. -For this to work, the method must have a return type of `void` and declare a single parameter of the desired event type. +For this to work, the method must declare a single parameter of the desired event type. Alternatively, a parameter-less event handler can be declared as shown [below](#parameter-less-event-handlers). ## A Simple Example @@ -125,21 +125,14 @@ As event handlers are ordered by priority, it is not defined which of them will ## Installation -Event Bus is currently hosted at [kske.dev](https://kske.dev/maven-repo/dev/kske/event-bus/). -To include it inside your project, just add the Maven repository and the dependency to your `pom.xml`: +Event Bus is available in Maven Central. +To include it inside your project, just add the following dependency to your `pom.xml`: ```xml - - - kske-repo - https://kske.dev/maven-repo - - - dev.kske - event-bus + event-bus-core 1.0.0 @@ -175,7 +168,7 @@ When using Maven, it can be registered using the Maven Compiler Plugin: dev.kske - event-bus-ap + event-bus-proc 1.0.0 @@ -183,4 +176,4 @@ When using Maven, it can be registered using the Maven Compiler Plugin: ``` -Alternatively, a JAR file containing the processor is offered with each release for the use within IDEs and environments without Maven support. \ No newline at end of file +Alternatively, a JAR file containing the processor is offered with each release for the use within IDEs and environments without Maven support. diff --git a/event-bus-core/src/main/java/dev/kske/eventbus/core/Event.java b/event-bus-core/src/main/java/dev/kske/eventbus/core/Event.java index 743c803..6ef1dd9 100644 --- a/event-bus-core/src/main/java/dev/kske/eventbus/core/Event.java +++ b/event-bus-core/src/main/java/dev/kske/eventbus/core/Event.java @@ -6,17 +6,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.*; /** - * Indicates that a method is an event handler. To be successfully used as such, the method has to - * comply with the following specifications: - * + * Indicates that a method is an event handler. + *

+ * To be successfully used as such, the method has to specify the event type by either declaring one + * parameter of that type or setting the annotation value to the corresponding class. * * @author Kai S. K. Engelbart * @since 0.0.1 diff --git a/event-bus-core/src/main/java/dev/kske/eventbus/core/EventHandler.java b/event-bus-core/src/main/java/dev/kske/eventbus/core/EventHandler.java index f1bbea3..91c2078 100644 --- a/event-bus-core/src/main/java/dev/kske/eventbus/core/EventHandler.java +++ b/event-bus-core/src/main/java/dev/kske/eventbus/core/EventHandler.java @@ -43,7 +43,7 @@ final class EventHandler implements Comparable { this.method = method; useParameter = annotation.value() == USE_PARAMETER.class; - // Check for correct method signature and return type + // Check handler signature if (method.getParameterCount() == 0 && useParameter) throw new EventBusException(method + " does not define an event type!"); @@ -53,9 +53,6 @@ final class EventHandler implements Comparable { if (method.getParameterCount() > 1) throw new EventBusException(method + " defines more than one parameter!"); - if (!method.getReturnType().equals(void.class)) - throw new EventBusException(method + " does not have a return type of void!"); - // Determine handler properties eventType = useParameter ? method.getParameterTypes()[0] : annotation.value(); polymorphic = method.isAnnotationPresent(Polymorphic.class); diff --git a/event-bus-proc/pom.xml b/event-bus-proc/pom.xml index b1be683..56e8c84 100644 --- a/event-bus-proc/pom.xml +++ b/event-bus-proc/pom.xml @@ -50,6 +50,21 @@ true + + + dev.kske:event-bus-core + + META-INF/MANIFEST.MF + + + + *:* + + module-info.class + META-INF/maven/** + + + diff --git a/event-bus-proc/src/main/java/dev/kske/eventbus/proc/EventProcessor.java b/event-bus-proc/src/main/java/dev/kske/eventbus/proc/EventProcessor.java index 19c670b..355cfd7 100644 --- a/event-bus-proc/src/main/java/dev/kske/eventbus/proc/EventProcessor.java +++ b/event-bus-proc/src/main/java/dev/kske/eventbus/proc/EventProcessor.java @@ -60,8 +60,6 @@ public class EventProcessor extends AbstractProcessor { "Either the method or the annotation must define the event type"); else if (eventHandler.getParameters().size() > 1) error(eventHandler, "Method must not have more than one parameter"); - else if (eventHandler.getReturnType().getKind() != TypeKind.VOID) - error(eventHandler, "Method must return void"); else pass = true; diff --git a/pom.xml b/pom.xml index c4ce552..3772da5 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,7 @@ scm:git:https://git.kske.dev/kske/event-bus.git scm:git:ssh://git@git.kske.dev:420/kske/event-bus.git + https://git.kske.dev/kske/event-bus @@ -50,6 +51,18 @@ 11 + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + @@ -64,7 +77,7 @@ 3.8.1 - + org.apache.maven.plugins maven-source-plugin @@ -78,6 +91,8 @@ + + org.apache.maven.plugins maven-javadoc-plugin @@ -92,6 +107,22 @@ + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + +