minibus-library

Lightweight publish/subscribe library inspired by Otto

Лицензия

Лицензия

Группа

Группа

fr.inria.minibus
Идентификатор

Идентификатор

minibus-library
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

minibus-library
Lightweight publish/subscribe library inspired by Otto
Ссылка на сайт

Ссылка на сайт

https://github.com/rouvoy/minibus
Система контроля версий

Система контроля версий

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

Скачать minibus-library

Как подключить последнюю версию

<!-- 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"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
fr.inria.jfilter : jfilter-library jar 1.3

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.11
org.mockito : mockito-all jar 1.9.5

Модули Проекта

Данный проект не имеет модулей.

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.

Версии библиотеки

Версия
1.0