org.kordamp.jipsy:jipsy

Configurable Java Annotation Processor to simplify the use of the Service Provider Interface

License

License

GroupId

GroupId

org.kordamp.jipsy
ArtifactId

ArtifactId

jipsy
Last Version

Last Version

0.6.0
Release Date

Release Date

Type

Type

jar
Description

Description

Configurable Java Annotation Processor to simplify the use of the Service Provider Interface

Download jipsy

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.kordamp.jipsy : jipsy-annotations jar 0.6.0

Project Modules

There are no modules declared in this project.

Jipsy

jipsy logo

Build Status Download


Configurable Java Annotation Processor to simplify the use of the Service Provider Interface.

Introduction

JDK6 added a neat facility named ServiceLoader that enables library authors to hook in implementations using an SPI. As explained at the service loader documentation, services must follow certain rules in order to be considered as such; they also must be registered using an standard location based on a naming convention. The following rules apply to classes that may be considered services

  1. The class must implement at least one target interface (the service interface).

  2. The class must provide a no-args constructor.

  3. The class must be public.

  4. The class name should be added to a file named META-INF/services/<target_interface_name>

This library provides a mechanism for enforcing those rules by simply adding an annotation on each service implementation, for example say there exists the following Calculator service interface

package com.acme;

public interface Calculator {
    double add(double a, double b);
}

A basic implementation of such service may be as follows

package com.acme;

@org.kordamp.jipsy.annotations.ServiceProviderFor(Calculator.class)
public class BasicCalculator implements Calculator {
    public double add(double a, double b) { return a + b; }
}

Compile your code. If you look closely at your project’s output you’ll see a file named META-INF/services/com.acme.Calculator whose contents should look similar to

# Generated by org.kordamp.jipsy.processor.service.ServiceProviderProcessor (1.1.1)
com.acme.BasicCalculator

Et voilà! There are no additional sources to be touched nor files to be created; Jipsy will take care of the boiler plate.

Installing

Jipsy is packaged as a standalone jars with no additional dependencies. Jipsy requires JDK8 as a minimum as it relies on the Annotation Processor facility to do its work. You must enable annotation processing on your IDE if you want Jipsy to work correctly.

Jipsy can be downloaded directly from Maven Central, configure it via Maven or Gradle.

Maven
<dependency>
    <groupId>org.kordamp.jipsy</groupId>
    <artifactId>jipsy-processor</artifactId>
    <version>1.1.1</version>
    <scope>provided</scope>
</dependency>
Gradle
dependencies {
    annotationProcessor 'org.kordamp.jipsy:jipsy-processor:1.1.1'
    compileOnly 'org.kordamp.jipsy:jipsy-annotations:1.1.1'
}
Note
For Maven, use the provided scope in order to mark Jipsy as a compile-only dependency; this also avoids exposing Jipsy to consumers of your library.

Origin

Jipsy is a re-implementation of the org.mangosdk.spi project, original by Roel Spilker and Bart Enkelaar; copyrighted by TOPdesk; source distributed under Apache Software License 2.0

Creating Your Own Processors

TBD

Versions

Version
0.6.0
0.5.0
0.4.1