Skip to content

Commit

Permalink
Update README, prepare for version 1.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Jun 11, 2023
1 parent 078e0ff commit 5fbd9a2
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.linux.temurin.current.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ jobs:
distribution: 'temurin'
- name: Build
run: mvn --errors clean verify site
- name: Upload test logs
uses: actions/upload-artifact@v3
if: always()
with:
name: test-logs
path: ./com.io7m.repetoir.tests/target/surefire-reports
6 changes: 6 additions & 0 deletions .github/workflows/main.linux.temurin.lts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
distribution: 'temurin'
- name: Build
run: mvn --errors clean verify site
- name: Upload test logs
uses: actions/upload-artifact@v3
if: always()
with:
name: test-logs
path: ./com.io7m.repetoir.tests/target/surefire-reports
- name: Coverage
uses: codecov/codecov-action@v1
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/main.windows.temurin.current.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ jobs:
distribution: 'temurin'
- name: Build
run: mvn --errors clean verify site
- name: Upload test logs
uses: actions/upload-artifact@v3
if: always()
with:
name: test-logs
path: ./com.io7m.repetoir.tests/target/surefire-reports
6 changes: 6 additions & 0 deletions .github/workflows/main.windows.temurin.lts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ jobs:
distribution: 'temurin'
- name: Build
run: mvn --errors clean verify site
- name: Upload test logs
uses: actions/upload-artifact@v3
if: always()
with:
name: test-logs
path: ./com.io7m.repetoir.tests/target/surefire-reports
87 changes: 87 additions & 0 deletions README.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

## 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 17.
* [OSGi](https://www.osgi.org/) ready.
* [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System) 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.
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,91 @@ repetoir
| OpenJDK (Temurin) LTS | Linux | [![Build (OpenJDK (Temurin) LTS, Linux)](https://img.shields.io/github/actions/workflow/status/io7m/repetoir/main.linux.temurin.lts.yml)](https://github.com/io7m/repetoir/actions?query=workflow%3Amain.linux.temurin.lts)|
| OpenJDK (Temurin) Current | Windows | [![Build (OpenJDK (Temurin) Current, Windows)](https://img.shields.io/github/actions/workflow/status/io7m/repetoir/main.windows.temurin.current.yml)](https://github.com/io7m/repetoir/actions?query=workflow%3Amain.windows.temurin.current)|
| OpenJDK (Temurin) LTS | Windows | [![Build (OpenJDK (Temurin) LTS, Windows)](https://img.shields.io/github/actions/workflow/status/io7m/repetoir/main.windows.temurin.lts.yml)](https://github.com/io7m/repetoir/actions?query=workflow%3Amain.windows.temurin.lts)|

## 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 17.
* [OSGi](https://www.osgi.org/) ready.
* [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System) 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.

2 changes: 1 addition & 1 deletion com.io7m.repetoir.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.io7m.repetoir</groupId>
<artifactId>com.io7m.repetoir</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.io7m.repetoir.core</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion com.io7m.repetoir.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.io7m.repetoir</groupId>
<artifactId>com.io7m.repetoir</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.io7m.repetoir.tests</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.io7m.repetoir</groupId>
<artifactId>com.io7m.repetoir</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>

<packaging>pom</packaging>
<name>com.io7m.repetoir</name>
Expand Down

0 comments on commit 5fbd9a2

Please sign in to comment.