File tree Expand file tree Collapse file tree 7 files changed +56
-3
lines changed
net.adoptopenjdk.v3.tests/src/test/java/net/adoptopenjdk/v3/tests
net.adoptopenjdk.v3.vanilla
net/adoptopenjdk/v3/vanilla
resources/META-INF/services Expand file tree Collapse file tree 7 files changed +56
-3
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,17 @@ A Java client for the [AdoptOpenJDK REST API](https://api.adoptopenjdk.net/).
1111
1212![ adoptopenjdk] ( ./src/site/resources/adoptopenjdk.jpg?raw=true )
1313
14- Usage
15- ===
14+ ## Features
15+
16+ * Efficient, type-safe access to the AdoptOpenJDK API
17+ * Clean API/implementation separation for easy API mocking in applications
18+ * [ JPMS] ( https://openjdk.java.net/projects/jigsaw/spec/ ) -ready
19+ * [ OSGi] ( https://www.osgi.org ) -ready
20+ * High coverage automated test suite
21+ * Apache 2.0 license
22+ * Fully documented (JavaDOC)
23+
24+ ## Usage
1625
1726Use the following Maven dependencies:
1827
@@ -44,3 +53,20 @@ try (var client = clients.createClient()) {
4453
4554The API operates entirely synchronously and raises checked exceptions on
4655failures.
56+
57+ The ` net.adoptopenjdk.v3.api.AOV3ClientProviderType ` interface is published
58+ both as a JPMS service and an [ OSGi service] ( https://www.osgi.org ) in order to
59+ allow for decoupling consumers from the ` vanilla ` implementation package:
60+
61+ ```
62+ var clients =
63+ ServiceLoader.load(AOV3ClientProviderType.class)
64+ .findFirst()
65+ .orElseThrow(() -> new IllegalStateException(
66+ String.format("No implementations of %s are available", AOV3ClientProviderType.class)));
67+
68+ try (var client = clients.createClient()) {
69+ var request = client.availableReleases(...);
70+ var releases = request.execute();
71+ }
72+ ```
Original file line number Diff line number Diff line change 1414
1515package net .adoptopenjdk .v3 .tests ;
1616
17+ import net .adoptopenjdk .v3 .api .AOV3ClientProviderType ;
1718import net .adoptopenjdk .v3 .api .AOV3Error ;
1819import net .adoptopenjdk .v3 .api .AOV3ExceptionHTTPRequestFailed ;
1920import net .adoptopenjdk .v3 .api .AOV3ReleaseKind ;
3839import java .util .ArrayList ;
3940import java .util .Map ;
4041import java .util .Optional ;
42+ import java .util .ServiceLoader ;
4143
4244public final class AOV3ClientsTest
4345{
@@ -124,4 +126,15 @@ public void testRequestFailure0()
124126 );
125127 }
126128 }
129+
130+ @ Test
131+ public void testService ()
132+ throws Exception
133+ {
134+ final var clients =
135+ ServiceLoader .load (AOV3ClientProviderType .class )
136+ .findFirst ()
137+ .orElseThrow (() -> new IllegalStateException (
138+ String .format ("No implementations of %s are available" , AOV3ClientProviderType .class )));
139+ }
127140}
Original file line number Diff line number Diff line change 4242 <artifactId >slf4j-api</artifactId >
4343 </dependency >
4444
45+ <dependency >
46+ <groupId >org.osgi</groupId >
47+ <artifactId >org.osgi.service.component.annotations</artifactId >
48+ <scope >provided</scope >
49+ </dependency >
4550 <dependency >
4651 <groupId >org.osgi</groupId >
4752 <artifactId >org.osgi.annotation.bundle</artifactId >
Original file line number Diff line number Diff line change 1717
1818module net .adoptopenjdk .v3 .vanilla
1919{
20+ requires static com .fasterxml .jackson .annotation ;
2021 requires static org .osgi .annotation .bundle ;
2122 requires static org .osgi .annotation .versioning ;
22- requires static com . fasterxml . jackson . annotation ;
23+ requires static org . osgi . service . component . annotations ;
2324
2425 requires transitive net .adoptopenjdk .v3 .api ;
2526
Original file line number Diff line number Diff line change 1616
1717import net .adoptopenjdk .v3 .api .AOV3ClientProviderType ;
1818import net .adoptopenjdk .v3 .api .AOV3ClientType ;
19+ import org .osgi .service .component .annotations .Component ;
1920
2021import java .net .http .HttpClient ;
2122import java .util .Objects ;
2526 * The default provider of v3 clients.
2627 */
2728
29+ @ Component (service = AOV3ClientProviderType .class )
2830public final class AOV3Clients implements AOV3ClientProviderType
2931{
3032 private final Supplier <HttpClient > clients ;
Original file line number Diff line number Diff line change 1+ net.adoptopenjdk.v3.vanilla.AOV3Clients
Original file line number Diff line number Diff line change 117117 <artifactId >org.osgi.annotation.versioning</artifactId >
118118 <version >1.1.0</version >
119119 </dependency >
120+ <dependency >
121+ <groupId >org.osgi</groupId >
122+ <artifactId >org.osgi.service.component.annotations</artifactId >
123+ <version >1.4.0</version >
124+ </dependency >
120125 <dependency >
121126 <groupId >org.immutables</groupId >
122127 <artifactId >value</artifactId >
You can’t perform that action at this time.
0 commit comments