Skip to content

Commit e75a9b7

Browse files
aepfliclaude
andcommitted
feat: Update documentation for multi-module architecture and improve encapsulation
- Update README.md with comprehensive documentation for new API/SDK separation - Add clear installation instructions for both API-only and complete SDK usage - Document architecture benefits and module responsibilities - Update provider and hook development sections to reference API module - Make DefaultOpenFeatureAPI package-private with package-private constructor 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 517c98f commit e75a9b7

File tree

2 files changed

+67
-7
lines changed

2 files changed

+67
-7
lines changed

README.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ Note that this library is intended to be used in server-side contexts and has no
5252

5353
### Install
5454

55-
#### Maven
55+
OpenFeature Java is now structured as a multi-module project with separate API and SDK artifacts. In most cases, you'll want to use the full SDK, but you can also use just the API if you're building a provider or need a lighter dependency.
56+
57+
#### Complete SDK (Recommended)
58+
59+
For full OpenFeature functionality, use the SDK module:
5660

5761
<!-- x-release-please-start-version -->
5862
```xml
@@ -64,6 +68,20 @@ Note that this library is intended to be used in server-side contexts and has no
6468
```
6569
<!-- x-release-please-end-version -->
6670

71+
#### API Only
72+
73+
For provider development or minimal dependencies, use the API module:
74+
75+
<!-- x-release-please-start-version -->
76+
```xml
77+
<dependency>
78+
<groupId>dev.openfeature</groupId>
79+
<artifactId>api</artifactId>
80+
<version>1.16.0</version>
81+
</dependency>
82+
```
83+
<!-- x-release-please-end-version -->
84+
6785
If you would like snapshot builds, this is the relevant repository information:
6886

6987
```xml
@@ -81,6 +99,7 @@ If you would like snapshot builds, this is the relevant repository information:
8199

82100
#### Gradle
83101

102+
Complete SDK:
84103
<!-- x-release-please-start-version -->
85104
```groovy
86105
dependencies {
@@ -89,6 +108,15 @@ dependencies {
89108
```
90109
<!-- x-release-please-end-version -->
91110

111+
API only:
112+
<!-- x-release-please-start-version -->
113+
```groovy
114+
dependencies {
115+
implementation 'dev.openfeature:api:1.16.0'
116+
}
117+
```
118+
<!-- x-release-please-end-version -->
119+
92120
### Usage
93121

94122
```java
@@ -123,6 +151,19 @@ public void example(){
123151

124152
See [here](https://javadoc.io/doc/dev.openfeature/sdk/latest/) for the Javadocs.
125153

154+
## 🏗️ Architecture
155+
156+
OpenFeature Java SDK is structured as a multi-module project:
157+
158+
- **`openfeature-api`**: Core interfaces, data types, and contracts. Use this if you're building providers or hooks, or if you need minimal dependencies.
159+
- **`openfeature-sdk`**: Full implementation with all OpenFeature functionality. This is what most applications should use.
160+
161+
This separation allows for:
162+
- **Cleaner dependencies**: Provider and hook developers only need the lightweight API module
163+
- **Better modularity**: Clear separation between contracts (API) and implementation (SDK)
164+
- **Easier testing**: Components can be tested against the API contracts
165+
- **Reduced coupling**: Implementation details are isolated in the SDK module
166+
126167
## 🌟 Features
127168

128169
| Status | Features | Description |
@@ -327,9 +368,17 @@ Additionally, you can develop a custom transaction context propagator by impleme
327368

328369
### Develop a provider
329370

330-
To develop a provider, you need to create a new project and include the OpenFeature SDK as a dependency.
371+
To develop a provider, you need to create a new project and include the OpenFeature API as a dependency (you only need the API module for provider development).
331372
This can be a new repository or included in [the existing contrib repository](https://github.com/open-feature/java-sdk-contrib) available under the OpenFeature organization.
332-
You’ll then need to write the provider by implementing the `FeatureProvider` interface exported by the OpenFeature SDK.
373+
You'll then need to write the provider by implementing the `FeatureProvider` interface exported by the OpenFeature API.
374+
375+
```xml
376+
<dependency>
377+
<groupId>dev.openfeature</groupId>
378+
<artifactId>api</artifactId>
379+
<version>1.16.0</version>
380+
</dependency>
381+
```
333382

334383
```java
335384
public class MyProvider implements FeatureProvider {
@@ -413,10 +462,18 @@ OpenFeatureAPI.getInstance().getClient().getProviderState();
413462
414463
### Develop a hook
415464

416-
To develop a hook, you need to create a new project and include the OpenFeature SDK as a dependency.
465+
To develop a hook, you need to create a new project and include the OpenFeature API as a dependency (you only need the API module for hook development).
417466
This can be a new repository or included in [the existing contrib repository](https://github.com/open-feature/java-sdk-contrib) available under the OpenFeature organization.
418467
Implement your own hook by conforming to the `Hook interface`.
419468

469+
```xml
470+
<dependency>
471+
<groupId>dev.openfeature</groupId>
472+
<artifactId>api</artifactId>
473+
<version>1.16.0</version>
474+
</dependency>
475+
```
476+
420477
```java
421478
class MyHook implements Hook {
422479

openfeature-sdk/src/main/java/dev/openfeature/sdk/DefaultOpenFeatureAPI.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
* Default implementation of OpenFeature API that provides full SDK functionality.
3232
* This implementation extends the abstract API and provides all OpenFeature capabilities including
3333
* provider management, event handling, transaction context management, and lifecycle management.
34+
* Package-private - users should access this through OpenFeatureAPI.getInstance().
3435
*/
3536
@SuppressWarnings("PMD.UnusedLocalVariable")
36-
public class DefaultOpenFeatureAPI extends OpenFeatureAPI {
37+
class DefaultOpenFeatureAPI extends OpenFeatureAPI {
3738
private static final Logger log = LoggerFactory.getLogger(DefaultOpenFeatureAPI.class);
3839
// package-private multi-read/single-write lock
3940
static AutoCloseableReentrantReadWriteLock lock = new AutoCloseableReentrantReadWriteLock();
@@ -47,8 +48,9 @@ public class DefaultOpenFeatureAPI extends OpenFeatureAPI {
4748
* Creates a new DefaultOpenFeatureAPI instance with default settings.
4849
* Initializes the API with empty hooks, a provider repository, event support,
4950
* and a no-op transaction context propagator.
51+
* Package-private constructor - this class should only be instantiated by the SDK.
5052
*/
51-
public DefaultOpenFeatureAPI() {
53+
DefaultOpenFeatureAPI() {
5254
apiHooks = new ConcurrentLinkedQueue<>();
5355
providerRepository = new ProviderRepository(this);
5456
eventSupport = new EventSupport();
@@ -435,7 +437,8 @@ void addHandler(String domain, ProviderEvent event, Consumer<EventDetails> handl
435437
.orElse(ProviderState.READY)
436438
.matchesEvent(event)) {
437439
eventSupport.runHandler(
438-
handler, dev.openfeature.api.EventDetails.eventDetailsBuilder().domain(domain).build());
440+
handler,
441+
EventDetails.eventDetailsBuilder().domain(domain).build());
439442
}
440443
eventSupport.addClientHandler(domain, event, handler);
441444
}

0 commit comments

Comments
 (0)