minibus-library

Lightweight publish/subscribe library inspired by Otto

License

License

GroupId

GroupId

fr.inria.minibus
ArtifactId

ArtifactId

minibus-library
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

minibus-library
Lightweight publish/subscribe library inspired by Otto
Project URL

Project URL

https://github.com/rouvoy/minibus
Source Code Management

Source Code Management

https://github.com/rouvoy/minibus.git

Download minibus-library

How to add to project

<!-- https://jarcasting.com/artifacts/fr.inria.minibus/minibus-library/ -->
<dependency>
    <groupId>fr.inria.minibus</groupId>
    <artifactId>minibus-library</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/fr.inria.minibus/minibus-library/
implementation 'fr.inria.minibus:minibus-library:1.0'
// https://jarcasting.com/artifacts/fr.inria.minibus/minibus-library/
implementation ("fr.inria.minibus:minibus-library:1.0")
'fr.inria.minibus:minibus-library:jar:1.0'
<dependency org="fr.inria.minibus" name="minibus-library" rev="1.0">
  <artifact name="minibus-library" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.inria.minibus', module='minibus-library', version='1.0')
)
libraryDependencies += "fr.inria.minibus" % "minibus-library" % "1.0"
[fr.inria.minibus/minibus-library "1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
fr.inria.jfilter : jfilter-library jar 1.3

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-all jar 1.9.5

Project Modules

There are no modules declared in this project.

MiniBus Library

Lightweight implementation of a publish/subscribe library inspired by Otto

Maven artefact

Release

The latest released version of the Minibus library artefact is available as:

<dependency>
    <groupId>fr.inria.minibus</groupId>
    <artifactId>minibus-library</artifactId>
    <version>1.0</version>
</dependency>

Snapshot

The currently developed version of the MiniBus library artefact is available as:

<dependency>
    <groupId>fr.inria.minibus</groupId>
    <artifactId>minibus-library</artifactId>
    <version>1.1-SNAPSHOT</version>
</dependency>

Maven compilation

MiniBus is a Maven managed project. All you have to do is to invoke the install command from the root directory (MINIBUS_DIR):

cd $MINIBUS_DIR
mvn install

API Usage

Declaring an event

MiniBus supports the usage of POJO events as long as the filtered fields are exposed:

public class Event {
    public final int value;
    
    public Event(int v) {
        this.value = v;
    }
}

Subscribing to an event

Enlistment of event handlers is achieved through the interface Subscriber and the annotation Subscribe:

public class SubscribingObject {
    public SubscribingObject(Subscriber bus) {
        bus.subscribe(this);
    }
  
    @Subscribe
    public String onAnyValue(Event e) {
        return "Received event with value " + e.value;
    }
  
    @Subscribe("value>0")
    public String onStrictPositiveValue(Event e) {
        return "Event "+e+" is strictly positive ";
    }
    
    @Subscribe
    public void print(String msg) {
        System.out.println(msg);
    }
}

Publishing an event

Delivery of events is ensured by the interface Publisher, which can be used to asynchronously post events:

public class PublishingObject {
    public PublishingObject(Publisher bus) {
        bus.publish(new Event(10))
        bus.publish(new Event(-10))
    }
}

Configuring the event bus

public class Application {
    public static void main (String[] args) {
    	Bus bus = new EventBus(10);
    	new SubscribingObject(bus);
    	new PublishingObject(bus);
    }
}

Licence

Copyright (C) 2014 University Lille 1, Inria

This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.

Versions

Version
1.0