Easybus Mongodb

Simple, No Frills Event Bus for Java - Mongodb Backing Bus

License

License

Categories

Categories

MongoDB Data Databases
GroupId

GroupId

me.kisoft
ArtifactId

ArtifactId

easybus-mongodb
Last Version

Last Version

2.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

Easybus Mongodb
Simple, No Frills Event Bus for Java - Mongodb Backing Bus

Download easybus-mongodb

How to add to project

<!-- https://jarcasting.com/artifacts/me.kisoft/easybus-mongodb/ -->
<dependency>
    <groupId>me.kisoft</groupId>
    <artifactId>easybus-mongodb</artifactId>
    <version>2.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/me.kisoft/easybus-mongodb/
implementation 'me.kisoft:easybus-mongodb:2.1.2'
// https://jarcasting.com/artifacts/me.kisoft/easybus-mongodb/
implementation ("me.kisoft:easybus-mongodb:2.1.2")
'me.kisoft:easybus-mongodb:jar:2.1.2'
<dependency org="me.kisoft" name="easybus-mongodb" rev="2.1.2">
  <artifact name="easybus-mongodb" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.kisoft', module='easybus-mongodb', version='2.1.2')
)
libraryDependencies += "me.kisoft" % "easybus-mongodb" % "2.1.2"
[me.kisoft/easybus-mongodb "2.1.2"]

Dependencies

compile (3)

Group / Artifact Type Version
org.jongo : jongo jar 1.4.0
me.kisoft : easybus-core jar 2.1.2
org.mongodb : mongo-java-driver jar 3.5.0

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.12

test (1)

Group / Artifact Type Version
junit : junit jar 4.13

Project Modules

There are no modules declared in this project.

Maven Central

EasyBus

Easy bus is a simple, event bus for java designed for simplicity and java practices in mind

  • Annotation-Based
  • Sync and Async
  • Auto-Registration of Events
  • Compile-Time checking for events & handlers

Useage

Installation

To use the easybus, add the following into your pom.xml

<dependency>
  <groupId>me.kisoft</groupId>
  <artifactId>easybus-core</artifactId>
  <version>${LATEST_VERSION}</version>
</dependency>

If you want to use a specific backing implementation of easybus, you can also import that specific implementation which will also import easybus

Defining Events and Handlers

Afterwards, you will need to define your events and handlers using the @Handle and @Event annotations

Defining Events

@Event
public class MyEvent{
  // your code here
}

Defining Handlers

@Handle(event=MyEvent.class)
public class MyEventHandler{
   public void handle(MyEvent event){
     // your code here
   }
}

Note that the handle(MyEvent event) method is mandatory, and it is the method that will be called by the event bus. The Method MUST be called handle and have the same type as your target event.

Adding Events and Handlers

You must also create a new event bus and specify the packages or classloaders your events are in

EasyBus bus = new EasyBus();
bus.search("my.package.name")
.search("my.second.package");

You will probably need to wrap the event bus as a singleton or maintain some reference to it, but that is just you coding.

Posting Events

bus.post(new MyEvent());

Async Handlers

Async Handlers are defined in the same way as handlers, except that they run in a seperate thread from the current thread. This is more of a hint to the backing bus; its not mandatory to honor async execution.

@Handle(event=MyEvent.class,async=true)
public class MyEventAsyncHandler{
   public void handle(MyEvent event){
     // your code here
   }
}

Implementing a Backing Bus

To implement a backing bus, all you need to do is implement the me.kisoft.easybus.Bus Interface, and when creating a new EasyBus, you need to use the new EasyBus(Bus bus) constructor to change the backing bus, or create your own factory

Versions

Version
2.1.2
2.1.1
2.1.0
2.0.0