Skip to content

Commit 10b4ec3

Browse files
aepfliclaude
andcommitted
feat: Create OpenFeature SDK module with ServiceLoader provider
- Implement DefaultOpenFeatureAPI extending abstract API class - Add ServiceLoader provider registration for automatic discovery - Create META-INF/services configuration for SDK implementation - Move existing implementation to SDK module structure - Update imports to use API module for core interfaces - Register DefaultOpenFeatureAPIProvider with priority 0 Key components: - DefaultOpenFeatureAPI: Full SDK implementation extending API abstract class - DefaultOpenFeatureAPIProvider: ServiceLoader provider with standard priority - META-INF/services: Registration file for automatic discovery - NoOpProvider, NoOpTransactionContextPropagator: SDK utility classes (distinct from API fallbacks) Note: Import migration partially complete - some compilation errors remain Architecture is sound but needs additional import cleanup to fully compile 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 4961478 commit 10b4ec3

24 files changed

+2976
-0
lines changed

openfeature-sdk/pom.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>dev.openfeature</groupId>
9+
<artifactId>openfeature-java</artifactId>
10+
<version>2.0.0</version>
11+
</parent>
12+
13+
<artifactId>openfeature-sdk</artifactId>
14+
15+
<name>OpenFeature Java SDK</name>
16+
<description>OpenFeature Java SDK - Full implementation of OpenFeature API with advanced features</description>
17+
18+
<properties>
19+
<module-name>dev.openfeature.sdk</module-name>
20+
<testExclusions>**/e2e/*.java</testExclusions>
21+
</properties>
22+
23+
<dependencies>
24+
<!-- API dependency -->
25+
<dependency>
26+
<groupId>dev.openfeature</groupId>
27+
<artifactId>openfeature-api</artifactId>
28+
</dependency>
29+
30+
<!-- Lombok for clean code generation -->
31+
<dependency>
32+
<groupId>org.projectlombok</groupId>
33+
<artifactId>lombok</artifactId>
34+
<version>1.18.38</version>
35+
<scope>provided</scope>
36+
</dependency>
37+
38+
<!-- Spotbugs for annotations -->
39+
<dependency>
40+
<groupId>com.github.spotbugs</groupId>
41+
<artifactId>spotbugs</artifactId>
42+
<version>4.8.6</version>
43+
<scope>provided</scope>
44+
</dependency>
45+
46+
<!-- SLF4J already included from API module -->
47+
48+
<!-- Test dependencies will be added later -->
49+
</dependencies>
50+
51+
<build>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-compiler-plugin</artifactId>
56+
</plugin>
57+
58+
<plugin>
59+
<groupId>org.apache.maven.plugins</groupId>
60+
<artifactId>maven-jar-plugin</artifactId>
61+
<version>3.4.2</version>
62+
<configuration>
63+
<archive>
64+
<manifestEntries>
65+
<Automatic-Module-Name>${module-name}</Automatic-Module-Name>
66+
</manifestEntries>
67+
</archive>
68+
</configuration>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
73+
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package dev.openfeature.sdk;
2+
3+
/**
4+
* A class to help with synchronization by allowing the optional awaiting of the associated action.
5+
*/
6+
public class Awaitable {
7+
8+
/**
9+
* An already-completed Awaitable. Awaiting this will return immediately.
10+
*/
11+
public static final Awaitable FINISHED = new Awaitable(true);
12+
13+
private boolean isDone = false;
14+
15+
public Awaitable() {}
16+
17+
private Awaitable(boolean isDone) {
18+
this.isDone = isDone;
19+
}
20+
21+
/**
22+
* Lets the calling thread wait until some other thread calls {@link Awaitable#wakeup()}. If
23+
* {@link Awaitable#wakeup()} has been called before the current thread invokes this method, it will return
24+
* immediately.
25+
*/
26+
@SuppressWarnings("java:S2142")
27+
public synchronized void await() {
28+
while (!isDone) {
29+
try {
30+
this.wait();
31+
} catch (InterruptedException ignored) {
32+
// ignored, do not propagate the interrupted state
33+
}
34+
}
35+
}
36+
37+
/**
38+
* Wakes up all threads that have called {@link Awaitable#await()} and lets them proceed.
39+
*/
40+
public synchronized void wakeup() {
41+
isDone = true;
42+
this.notifyAll();
43+
}
44+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package dev.openfeature.sdk;
2+
3+
/**
4+
* Metadata specific to an OpenFeature {@code Client}.
5+
*/
6+
public interface ClientMetadata {
7+
String getDomain();
8+
9+
@Deprecated
10+
// this is here for compatibility with getName() exposed from {@link Metadata}
11+
default String getName() {
12+
return getDomain();
13+
}
14+
}

0 commit comments

Comments
 (0)