Decorative site banner
Project icon

com.io7m.repetoir

  • About
  • Releases
  • Manual
  • Sources
  • License
  • Issues
Maven Central Version Maven Snapshot Code Coverage

repetoir


A minimalist application service directory.

Features


  • Register and deregister application services.
  • Subscribe to service events to be notified of changes.
  • Written in pure Java 21.
  • OSGi ready.
  • JPMS ready.
  • ISC license.
  • High-coverage automated test suite.

Motivation


Most applications end up using some kind of dependency injection. That is, a given class in an application is not responsible for instantiating the other classes on which it depends, but it instead has instances of those classes injected into its constructor. Many systems provide basically incomprehensible and error-prone annotation-based approaches that can be considered as push-based; a class has its own private fields reflectively assigned by an external system.

The repetoir system provides a strongly-typed, easily-understood service directory for pull-based dependency injection. An application creates a service directory (a plain Java object) on startup, manually instantiates and registers services into it, and then passes that service directory around the application. Parts of the application that require services explicitly pull those services from the service directory.

There is never any confusion, as is common with annotation and push-based dependency injection systems, where and how services are being instantiated; there is exactly one place in the code that creates services, and the instantiations are explicit and clearly visible.

Additionally, because the system is represented by a single, very simple interface type, there is no need to involve complicated mocking extensions in unit tests in order to get services correctly injected into all of the classes involves; simply create a service directory directly in the unit tests, publish the required services to it, and pass that directory into the classes under test.

Building


$ mvn clean verify

Usage


Create a service directory:

var directory = new RPServiceDirectory();

Register services:

interface ExampleServiceType extends RPServiceType { } class ExampleServiceService implements ExampleServiceType { } directory.register(ExampleServiceType.class, new ExampleServiceService());

Later, fetch required services:

ExampleServiceType service = directory.requireService(ExampleServiceType.class);

Fetch optional services:

interface ExampleOptionalServiceType extends RPServiceType { } Optional<ExampleOptionalServiceType> service = directory.optionalService(ExampleOptionalServiceType.class);

It is a requirement that services implement the trivial RPServiceType interface in order to be registered in a directory. Services that also implement AutoCloseable will be closed when the service directory is closed.

Releases & Development Snapshots


Releases


You can subscribe to the atom feed to be notified of project releases.

The most recently released version of the package is 1.1.0.

1.1.0 Release (2025-04-20Z)

  • Add serviceKeys().

The compiled artifacts for the release (and all previous releases) are available on Maven Central.

Maven Modules


<dependency> <group>com.io7m.repetoir</group> <artifactId>com.io7m.repetoir.core</artifactId> <version>1.1.0</version> </dependency><dependency> <group>com.io7m.repetoir</group> <artifactId>com.io7m.repetoir.tests</artifactId> <version>1.1.0</version> </dependency>

Previous Releases


The changelogs for the most recent previous releases are as follows:

1.0.1 Release (2024-05-11Z)

  • Update junit.version:5.10.1 → 5.10.2.
  • Update org.slf4j:slf4j-api:2.0.10 → 2.0.13.
  • Update org.mockito:mockito-core:5.8.0 → 5.11.0.
  • Update ch.qos.logback:logback-classic:1.4.14 → 1.5.6.
  • Move to new organization.
  • Update org.mockito:mockito-core:5.11.0 → 5.12.0.

1.0.0 Release (2023-06-11Z)

  • Initial major release.

Development Snapshots


At the time of writing, the current unstable development version of the package is 1.1.0-SNAPSHOT.

Development snapshots may be available in the Central Portal Snapshots repository. Snapshots are published to this repository every time the project is built by the project's continuous integration system, but snapshots do expire after around ninety days and so may or may not be available depending on when a build of the package was last triggered.

Manual


This project does not have any user manuals or other documentation beyond what might be present on the page above.

Sources


This project uses Git to manage source code.

Repository: https://www.github.com/io7m-com/repetoir

$ git clone --recursive https://www.github.com/io7m-com/repetoir

Issues


This project uses GitHub Issues to track issues.

License


Copyright © 2023 Mark Raynsford <code@io7m.com> https://www.io7m.com Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Last Updated 2025-08-09T14:58:21Z