Skip to content

Commit 24bf298

Browse files
committed
Merge branch 'develop'
2 parents 8f5ccaa + 4b5c349 commit 24bf298

File tree

33 files changed

+385
-222
lines changed

33 files changed

+385
-222
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The annotation processor should be applied by defining it in annotation processo
3737

3838
<plugin>
3939
<artifactId>maven-compiler-plugin</artifactId>
40-
<configuration combine.self="append">
40+
<configuration>
4141
<annotationProcessorPaths>
4242
<path>
4343
<groupId>io.toolisticon.spiap</groupId>
@@ -90,7 +90,7 @@ To create multiple service locators in the same package use @SpiServiceLocators:
9090
## How to register a service implementation
9191
Just add a Service annotation to your service implementation:
9292

93-
@Service(value = ExampleSpiInterface.class, id = "YOUR_OPTIONAL_SERVICE_ID", description = "OPTIONAL DESCRIPTION", priority = 0)
93+
@SpiService(value = ExampleSpiInterface.class, id = "YOUR_OPTIONAL_SERVICE_ID", description = "OPTIONAL DESCRIPTION", priority = 0)
9494
public class ExampleSpiService implements ExampleSpiInterface {
9595
@Override
9696
public String doSomething() {
@@ -107,9 +107,9 @@ All other annotation attributes are optional.
107107

108108
It's also possible to implement more than one SPI in a class by using the Services annotation:
109109

110-
@Services({
111-
@Service(value = ExampleSpiInterface1.class, id = "YOUR_OPTIONAL_SERVICE_ID", description = "OPTIONAL DESCRIPTION", priority = 0),
112-
@Service(value = ExampleSpiInterface2.class)
110+
@SpiServices({
111+
@SpiService(value = ExampleSpiInterface1.class, id = "YOUR_OPTIONAL_SERVICE_ID", description = "OPTIONAL DESCRIPTION", priority = 0),
112+
@SpiService(value = ExampleSpiInterface2.class)
113113
})
114114
public class ExampleSpiService implements ExampleSpiInterface1, ExampeSpiInterface2 {
115115
@Override

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.spiap</groupId>
99
<artifactId>spiap-parent</artifactId>
10-
<version>0.9.0</version>
10+
<version>0.10.0</version>
1111
</parent>
1212

1313
<name>spiap-api</name>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package io.toolisticon.spiap.api;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* Marks an implementation of one or more SPI.
10+
*/
11+
@Retention(RetentionPolicy.RUNTIME)
12+
@Target(value = {ElementType.TYPE})
13+
public @interface SpiService {
14+
15+
/**
16+
* The SPI interface implemented by the annotated class.
17+
*/
18+
Class<?> value();
19+
20+
/**
21+
* This optional attribute is used to declare an identifier for this implementation.
22+
* If not set, the full qualified class name of the service implementation will be used as id.
23+
*/
24+
String id() default "";
25+
26+
/**
27+
* This optional attribute is used to add a short description about the implementing class.
28+
*/
29+
String description() default "";
30+
31+
/**
32+
* This optional attribute defines the order of the service implementations returned by the generated service allocator.
33+
* Lower value are defining a higher priority. Defaults to 0.
34+
*/
35+
int priority() default 0;
36+
37+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.toolisticon.spiap.api;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
9+
/**
10+
* Binder for supporting several spis in a single class.
11+
*/
12+
@Retention(RetentionPolicy.RUNTIME)
13+
@Target(value = {ElementType.TYPE})
14+
public @interface SpiServices {
15+
SpiService[] value();
16+
}

example/api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.spiap</groupId>
1010
<artifactId>example-parent</artifactId>
11-
<version>0.9.0</version>
11+
<version>0.10.0</version>
1212
</parent>
1313

1414
<name>example-api</name>
@@ -18,7 +18,7 @@
1818

1919
<dependency>
2020
<groupId>io.toolisticon.spiap</groupId>
21-
<artifactId>spiap-api</artifactId>
21+
<artifactId>spiap-legacy-api</artifactId>
2222
<scope>provided</scope>
2323
</dependency>
2424

example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.toolisticon.spiap</groupId>
99
<artifactId>spiap-parent</artifactId>
10-
<version>0.9.0</version>
10+
<version>0.10.0</version>
1111
</parent>
1212

1313
<name>example-parent</name>

example/service/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>io.toolisticon.spiap</groupId>
1010
<artifactId>example-parent</artifactId>
11-
<version>0.9.0</version>
11+
<version>0.10.0</version>
1212
</parent>
1313

1414
<name>example-service</name>
@@ -17,7 +17,7 @@
1717

1818
<dependency>
1919
<groupId>io.toolisticon.spiap</groupId>
20-
<artifactId>spiap-api</artifactId>
20+
<artifactId>spiap-legacy-api</artifactId>
2121
</dependency>
2222

2323
<dependency>

example/service/src/main/java/io/toolisticon/example/spiapexample/service/AdditionDecimalOperationImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
import io.toolisticon.example.spiapexample.api.DecimalCalculationOperation;
44
import io.toolisticon.spiap.api.Service;
5+
import io.toolisticon.spiap.api.SpiService;
56

67
/**
78
* Implements the addition decimal operation
89
*/
9-
@Service(value = DecimalCalculationOperation.class, id = "ADDITION", description = "Does the addition operation on two int values", priority = -10)
10+
@SpiService(value = DecimalCalculationOperation.class, id = "ADDITION", description = "Does the addition operation on two int values", priority = -10)
1011
public class AdditionDecimalOperationImpl implements DecimalCalculationOperation {
1112

1213
@Override

example/service/src/main/java/io/toolisticon/example/spiapexample/service/DivisionDecimalOperationImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import io.toolisticon.example.spiapexample.api.DecimalCalculationOperation;
44
import io.toolisticon.spiap.api.Service;
5+
import io.toolisticon.spiap.api.SpiService;
56

67

78
/**
89
* Implements the division decimal operation.
910
*
1011
* It's ok not to set the id. The full qualified class name will be used as fallback value for id.
1112
*/
12-
@Service(DecimalCalculationOperation.class)
13+
@SpiService(DecimalCalculationOperation.class)
1314
public class DivisionDecimalOperationImpl implements DecimalCalculationOperation {
1415

1516
@Override

example/service/src/main/java/io/toolisticon/example/spiapexample/service/HelloWorldSpiService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
/**
77
* Example about how to use the {@link Service} annotation.
8+
* This class is kept to use {@link Service} to test backward compatibility.
89
*/
910

10-
@Service(HelloWorldSpiInterface.class)
11+
@Service(value = HelloWorldSpiInterface.class, description = "Hi again")
1112
public class HelloWorldSpiService implements HelloWorldSpiInterface {
1213
@Override
1314
public String doSomething() {

0 commit comments

Comments
 (0)