Wiki
Clone wikievent / Home
Java Event System
A Java Lib for Handling Events fired from an Application.
Features
- Fireing events to a List of EventHanders
- Dynamic Adding and Removing of Handers
- Infinite EventHandlers in one class
Getting Started
Installation
#!xml ... <repository> <id>andr3as07</id> <name>Andr3as07.tk repo</name> <url>http://andr3as07.tk/maven/</url> </repository> ... <dependency> <groupId>tk.andr3as07.util</groupId> <artifactId>event</artifactId> <version>0.1.1</version> </dependency> ...
Usage
Basic Handlers
To create a basic EventHandeler just stick the @EventHandler Annotation to a method which needs one argument of type Event and the EventPublisher will do the rest.
#!java @EventHandler public void handle(Event event) { // ToDo: Handle Event }
Specific Handlers
To select a specific Event just set the type Parameter in the @EventHandler Annotation.
#!java @EventHandler(type=MyOwnEvent.class) public void handle(MyOwnEvent event) { // ToDo: Handle Event }
Adding Handlers
In order to proccess the Events the EventPublisher needs to now the classes the EventHandlers are contained in. To tell the EventPublisher these informations you have to register the Handlers by using the register method in the HandlerRegistry class.
#!java HandlerRegistry.register(MyEventHandlers.class);
Fireing Events
To Fire an Event simply call the fire method inside EventPublisher.
#!java EventPublisher.fire(new MyOwnEvent());
keep on hacking!
Updated