{"id":20607741,"url":"https://github.com/open-feature/java-sdk","last_synced_at":"2026-01-22T18:44:44.197Z","repository":{"id":37024074,"uuid":"483818036","full_name":"open-feature/java-sdk","owner":"open-feature","description":"Java implementation of the OpenFeature SDK","archived":false,"fork":false,"pushed_at":"2025-03-28T23:26:39.000Z","size":2308,"stargazers_count":96,"open_issues_count":12,"forks_count":42,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-29T10:55:16.765Z","etag":null,"topics":["java","openfeature","sdk"],"latest_commit_sha":null,"homepage":"https://openfeature.dev","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-feature.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-20T21:25:57.000Z","updated_at":"2025-03-28T23:26:13.000Z","dependencies_parsed_at":"2022-07-09T13:00:28.169Z","dependency_job_id":"f922a8d9-6dbb-48f8-a262-dc9ba61c913c","html_url":"https://github.com/open-feature/java-sdk","commit_stats":{"total_commits":1319,"total_committers":32,"mean_commits":41.21875,"dds":"0.28430629264594387","last_synced_commit":"f1817d8fef585f957de1cfb9222b03cb591ed2e9"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-feature%2Fjava-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-feature%2Fjava-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-feature%2Fjava-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-feature%2Fjava-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-feature","download_url":"https://codeload.github.com/open-feature/java-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256115,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","openfeature","sdk"],"created_at":"2024-11-16T10:08:29.377Z","updated_at":"2026-01-17T17:43:30.597Z","avatar_url":"https://github.com/open-feature.png","language":"Java","readme":"\u003c!-- markdownlint-disable MD033 --\u003e\n\u003c!-- x-hide-in-docs-start --\u003e\n\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/open-feature/community/0e23508c163a6a1ac8c0ced3e4bd78faafe627c7/assets/logo/horizontal/white/openfeature-horizontal-white.svg\" /\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/open-feature/community/0e23508c163a6a1ac8c0ced3e4bd78faafe627c7/assets/logo/horizontal/black/openfeature-horizontal-black.svg\" /\u003e\n    \u003cimg align=\"center\" alt=\"OpenFeature Logo\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003ch2 align=\"center\"\u003eOpenFeature Java SDK\u003c/h2\u003e\n\n\u003c!-- x-hide-in-docs-end --\u003e\n\u003c!-- The 'github-badges' class is used in the docs --\u003e\n\u003cp align=\"center\" class=\"github-badges\"\u003e\n  \u003ca href=\"https://github.com/open-feature/spec/releases/tag/v0.7.0\"\u003e\n    \u003cimg alt=\"Specification\" src=\"https://img.shields.io/static/v1?label=specification\u0026message=v0.7.0\u0026color=yellow\u0026style=for-the-badge\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- x-release-please-start-version --\u003e\n\n  \u003ca href=\"https://github.com/open-feature/java-sdk/releases/tag/v1.20.0\"\u003e\n    \u003cimg alt=\"Release\" src=\"https://img.shields.io/static/v1?label=release\u0026message=v1.20.0\u0026color=blue\u0026style=for-the-badge\" /\u003e\n  \u003c/a\u003e  \n\n  \u003c!-- x-release-please-end --\u003e\n  \u003cbr/\u003e\n  \u003ca href=\"https://javadoc.io/doc/dev.openfeature/sdk\"\u003e\n    \u003cimg alt=\"Javadoc\" src=\"https://javadoc.io/badge2/dev.openfeature/sdk/javadoc.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://maven-badges.herokuapp.com/maven-central/dev.openfeature/sdk\"\u003e\n    \u003cimg alt=\"Maven Central\" src=\"https://maven-badges.herokuapp.com/maven-central/dev.openfeature/sdk/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/open-feature/java-sdk\"\u003e\n    \u003cimg alt=\"Codecov\" src=\"https://codecov.io/gh/open-feature/java-sdk/branch/main/graph/badge.svg?token=XMS9L7PBY1\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://bestpractices.coreinfrastructure.org/projects/6241\"\u003e\n    \u003cimg alt=\"CII Best Practices\" src=\"https://bestpractices.coreinfrastructure.org/projects/6241/badge\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c!-- x-hide-in-docs-start --\u003e\n\n[OpenFeature](https://openfeature.dev) is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool.\n\n\u003c!-- x-hide-in-docs-end --\u003e\n## 🚀 Quick start\n\n### Requirements\n\n- Java 11+ (compiler target is 11)\n\nNote that this library is intended to be used in server-side contexts and has not been evaluated for use on mobile devices.\n\n### Install\n\n#### Maven\n\n\u003c!-- x-release-please-start-version --\u003e\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003edev.openfeature\u003c/groupId\u003e\n    \u003cartifactId\u003esdk\u003c/artifactId\u003e\n    \u003cversion\u003e1.20.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\u003c!-- x-release-please-end-version --\u003e\n\nIf you would like snapshot builds, this is the relevant repository information:\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003csnapshots\u003e\n            \u003cenabled\u003etrue\u003c/enabled\u003e\n        \u003c/snapshots\u003e\n        \u003cid\u003esonatype\u003c/id\u003e\n        \u003cname\u003eSonatype Repository\u003c/name\u003e\n        \u003curl\u003ehttps://s01.oss.sonatype.org/content/repositories/snapshots/\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n#### Gradle\n\n\u003c!-- x-release-please-start-version --\u003e\n```groovy\ndependencies {\n    implementation 'dev.openfeature:sdk:1.20.0'\n}\n```\n\u003c!-- x-release-please-end-version --\u003e\n\n### Usage\n\n```java\npublic void example(){\n\n    // flags defined in memory\n    Map\u003cString, Flag\u003c?\u003e\u003e myFlags = new HashMap\u003c\u003e();\n    myFlags.put(\"v2_enabled\", Flag.builder()\n        .variant(\"on\", true)\n        .variant(\"off\", false)\n        .defaultVariant(\"on\")\n        .build());\n\n    // configure a provider\n    OpenFeatureAPI api = OpenFeatureAPI.getInstance();\n    try {\n        api.setProviderAndWait(new InMemoryProvider(myFlags));\n    } catch (Exception e) {\n        // handle initialization failure\n        e.printStackTrace();\n    }\n\n    // create a client\n    Client client = api.getClient();\n\n    // get a bool flag value\n    boolean flagValue = client.getBooleanValue(\"v2_enabled\", false);\n}\n```\n\n### API Reference\n\nSee [here](https://javadoc.io/doc/dev.openfeature/sdk/latest/) for the Javadocs.\n\n## 🌟 Features\n\n| Status | Features                                                            | Description                                                                                                                                                   |\n| ------ |---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ✅     | [Providers](#providers)                                             | Integrate with a commercial, open source, or in-house feature management tool.                                                                                |\n| ✅     | [Targeting](#targeting)                                             | Contextually-aware flag evaluation using [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context).                            |\n| ✅     | [Multi-provider (experimental)](#multi-provider-experimental)       | Combine multiple providers and delegate evaluations according to a strategy.                                                                                  |\n| ✅     | [Hooks](#hooks)                                                     | Add functionality to various stages of the flag evaluation life-cycle.                                                                                        |\n| ✅     | [Tracking](#tracking)                                               | Associate user actions with feature flag evaluations.                                                                                                         |\n| ✅     | [Logging](#logging)                                                 | Integrate with popular logging packages.                                                                                                                      |\n| ✅     | [Domains](#domains)                                                 | Logically bind clients with providers.                                                                                                                        |\n| ✅     | [Eventing](#eventing)                                               | React to state changes in the provider or flag management system.                                                                                             |\n| ✅     | [Shutdown](#shutdown)                                               | Gracefully clean up a provider during application shutdown.                                                                                                   |\n| ✅     | [Transaction Context Propagation](#transaction-context-propagation) | Set a specific [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context) for a transaction (e.g. an HTTP request or a thread). |   \n| ✅     | [Extending](#extending)                                             | Extend OpenFeature with custom providers and hooks.                                                                                                           |\n\n\u003csub\u003eImplemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌\u003c/sub\u003e\n\n### Providers\n\n[Providers](https://openfeature.dev/docs/reference/concepts/provider) are an abstraction between a flag management system and the OpenFeature SDK.\nLook [here](https://openfeature.dev/ecosystem?instant_search%5BrefinementList%5D%5Btype%5D%5B0%5D=Provider\u0026instant_search%5BrefinementList%5D%5Btechnology%5D%5B0%5D=Java) for a complete list of available providers.\nIf the provider you're looking for hasn't been created yet, see the [develop a provider](#develop-a-provider) section to learn how to build it yourself.\n\nOnce you've added a provider as a dependency, it can be registered with OpenFeature like this:\n\nIn some situations, it may be beneficial to register multiple providers in the same application.\nThis is possible using [domains](#domains), which is covered in more detail below.\n\n#### Multi-provider (experimental)\n\nIn addition to domains, you may want to delegate flag evaluation across multiple providers using a configurable strategy.\nThe multi-provider allows you to compose several `FeatureProvider` implementations and determine which provider's result to use.\n\n\u003e **Experimental:** This API is experimental and may change in future releases.\n\n```java\nimport dev.openfeature.sdk.OpenFeatureAPI;\nimport dev.openfeature.sdk.Client;\nimport dev.openfeature.sdk.FeatureProvider;\nimport dev.openfeature.sdk.multiprovider.MultiProvider;\n\nimport java.util.List;\n\npublic void multiProviderExample() throws Exception {\n    FeatureProvider primaryProvider = new MyPrimaryProvider();\n    FeatureProvider fallbackProvider = new MyFallbackProvider();\n\n    MultiProvider multiProvider = new MultiProvider(List.of(primaryProvider, fallbackProvider));\n\n    OpenFeatureAPI api = OpenFeatureAPI.getInstance();\n    api.setProviderAndWait(multiProvider);\n\n    Client client = api.getClient();\n    boolean value = client.getBooleanValue(\"some-flag\", false);\n}\n```\n\n\n#### Synchronous  \n  \nTo register a provider in a blocking manner to ensure it is ready before further actions are taken, you can use the `setProviderAndWait` method as shown below:     \n  \n```java\n    OpenFeatureAPI api = OpenFeatureAPI.getInstance();\n    try {\n        api.setProviderAndWait(new MyProvider());\n    }  catch (Exception e) {\n        // handle initialization failure\n        e.printStackTrace();\n    }\n```  \n  \n#### Asynchronous    \n\nTo register a provider in a non-blocking manner, you can use the `setProvider` method as shown below:  \n\n```java\n    OpenFeatureAPI.getInstance().setProvider(new MyProvider());\n```    \n\nIn some situations, it may be beneficial to register multiple providers in the same application.\nThis is possible using [domains](#domains), which is covered in more detail below.\n\n### Targeting\n\nSometimes, the value of a flag must consider some dynamic criteria about the application or user, such as the user's location, IP, email address, or the server's location.\nIn OpenFeature, we refer to this as [targeting](https://openfeature.dev/specification/glossary#targeting).\nIf the flag management system you're using supports targeting, you can provide the input data using the [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context).\n\n```java\n// set a value to the global context\nOpenFeatureAPI api = OpenFeatureAPI.getInstance();\nMap\u003cString, Value\u003e apiAttrs = new HashMap\u003c\u003e();\napiAttrs.put(\"region\", new Value(System.getEnv(\"us-east-1\")));\nEvaluationContext apiCtx = new ImmutableContext(apiAttrs);\napi.setEvaluationContext(apiCtx);\n\n// set a value to the client context\nMap\u003cString, Value\u003e clientAttrs = new HashMap\u003c\u003e();\nclientAttrs.put(\"region\", new Value(System.getEnv(\"us-east-1\")));\nEvaluationContext clientCtx = new ImmutableContext(clientAttrs);\nClient client = api.getInstance().getClient();\nclient.setEvaluationContext(clientCtx);\n\n// set a value to the invocation context\nMap\u003cString, Value\u003e requestAttrs = new HashMap\u003c\u003e();\nrequestAttrs.put(\"email\", new Value(session.getAttribute(\"email\")));\nrequestAttrs.put(\"product\", new Value(\"productId\"));\nString targetingKey = session.getId();\nEvaluationContext reqCtx = new ImmutableContext(targetingKey, requestAttrs);\n\nboolean flagValue = client.getBooleanValue(\"some-flag\", false, reqCtx);\n```\n\n### Hooks\n\n[Hooks](https://openfeature.dev/docs/reference/concepts/hooks) allow for custom logic to be added at well-defined points of the flag evaluation life-cycle\nLook [here](https://openfeature.dev/ecosystem?instant_search%5BrefinementList%5D%5Btype%5D%5B0%5D=Hook\u0026instant_search%5BrefinementList%5D%5Btechnology%5D%5B0%5D=Java) for a complete list of available hooks.\nIf the hook you're looking for hasn't been created yet, see the [develop a hook](#develop-a-hook) section to learn how to build it yourself.\n\nOnce you've added a hook as a dependency, it can be registered at the global, client, or flag invocation level.\n\n```java\n  // add a hook globally, to run on all evaluations\n  OpenFeatureAPI api = OpenFeatureAPI.getInstance();\n  api.addHooks(new ExampleHook());\n  \n  // add a hook on this client, to run on all evaluations made by this client\n  Client client = api.getClient();        \n  client.addHooks(new ExampleHook());\n  \n  // add a hook for this evaluation only\n  Boolean retval = client.getBooleanValue(flagKey, false, null,\n          FlagEvaluationOptions.builder().hook(new ExampleHook()).build());\n```\n\n### Tracking\n\nThe [tracking API](https://openfeature.dev/specification/sections/tracking/) allows you to use OpenFeature abstractions to associate user actions with feature flag evaluations.\nThis is essential for robust experimentation powered by feature flags. Note that, unlike methods that handle feature flag evaluations, calling `track(...)` may throw an `IllegalArgumentException` if an empty string is passed as the `trackingEventName`.\n\n```java\nOpenFeatureAPI api = OpenFeatureAPI.getInstance();\napi.getClient().track(\"visited-promo-page\", new MutableTrackingEventDetails(99.77).add(\"currency\", \"USD\"));\n```\n\n### Logging\n\nThe Java SDK uses SLF4J. See the [SLF4J manual](https://slf4j.org/manual.html) for complete documentation.\nNote that in accordance with the OpenFeature specification, the SDK doesn't generally log messages during flag evaluation.\n\n#### Logging Hook\n\nThe Java SDK includes a `LoggingHook`, which logs detailed information at key points during flag evaluation, using SLF4J's structured logging API.\nThis hook can be particularly helpful for troubleshooting and debugging; simply attach it at the global, client or invocation level and ensure your log level is set to \"debug\".\n\nSee [hooks](#hooks) for more information on configuring hooks.\n\n### Domains\n\nClients can be assigned to a domain.\nA domain is a logical identifier which can be used to associate clients with a particular provider.\nIf a domain has no associated provider, the global provider is used.  \n\n```java\nFeatureProvider scopedProvider = new MyProvider();\n\n// registering the default provider\nOpenFeatureAPI.getInstance().setProvider(LocalProvider());\n// registering a provider to a domain\nOpenFeatureAPI.getInstance().setProvider(\"my-domain\", new CachedProvider());\n\n// A client bound to the default provider\nClient clientDefault = OpenFeatureAPI.getInstance().getClient();\n// A client bound to the CachedProvider provider\nClient domainScopedClient = OpenFeatureAPI.getInstance().getClient(\"my-domain\");\n```\n\nProviders for domains can be set in a blocking or non-blocking way. \nFor more details, please refer to the [providers](#providers) section.  \n\n### Eventing\n\nEvents allow you to react to state changes in the provider or underlying flag management system, such as flag definition changes, provider readiness, or error conditions.\nInitialization events (`PROVIDER_READY` on success, `PROVIDER_ERROR` on failure) are dispatched for every provider.\nSome providers support additional events, such as `PROVIDER_CONFIGURATION_CHANGED`.\n\nPlease refer to the documentation of the provider you're using to see what events are supported.\n\n```java\n// add an event handler to a client\nClient client = OpenFeatureAPI.getInstance().getClient();\nclient.onProviderConfigurationChanged((EventDetails eventDetails) -\u003e {\n    // do something when the provider's flag settings change\n});\n\n// add an event handler to the global API\nOpenFeatureAPI.getInstance().onProviderStale((EventDetails eventDetails) -\u003e {\n    // do something when the provider's cache goes stale\n});\n```\n\n### Shutdown\n\nThe OpenFeature API provides a close function to perform a cleanup of all registered providers.\nThis should only be called when your application is in the process of shutting down.\n\n```java\n// shut down all providers\nOpenFeatureAPI.getInstance().shutdown();\n```\n\n### Transaction Context Propagation\nTransaction context is a container for transaction-specific evaluation context (e.g. user id, user agent, IP).\nTransaction context can be set where specific data is available (e.g. an auth service or request handler) and by using the transaction context propagator it will automatically be applied to all flag evaluations within a transaction (e.g. a request or thread).\nBy default, the `NoOpTransactionContextPropagator` is used, which doesn't store anything.\nTo register a `ThreadLocal` context propagator, you can use the `setTransactionContextPropagator` method as shown below.\n```java\n// registering the ThreadLocalTransactionContextPropagator\nOpenFeatureAPI.getInstance().setTransactionContextPropagator(new ThreadLocalTransactionContextPropagator());\n```\nOnce you've registered a transaction context propagator, you can propagate the data into request-scoped transaction context.\n\n```java\n// adding userId to transaction context\nOpenFeatureAPI api = OpenFeatureAPI.getInstance();\nMap\u003cString, Value\u003e transactionAttrs = new HashMap\u003c\u003e();\ntransactionAttrs.put(\"userId\", new Value(\"userId\"));\nEvaluationContext transactionCtx = new ImmutableContext(transactionAttrs);\napi.setTransactionContext(transactionCtx);\n```\nAdditionally, you can develop a custom transaction context propagator by implementing the `TransactionContextPropagator` interface and registering it as shown above.\n\n## Extending\n\n### Develop a provider\n\nTo develop a provider, you need to create a new project and include the OpenFeature SDK as a dependency.\nThis 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.\nYou’ll then need to write the provider by implementing the `FeatureProvider` interface exported by the OpenFeature SDK.\n\n```java\npublic class MyProvider implements FeatureProvider {\n    @Override\n    public Metadata getMetadata() {\n        return () -\u003e \"My Provider\";\n    }\n\n    @Override\n    public void initialize(EvaluationContext evaluationContext) throws Exception {\n        // start up your provider\n    }\n\n    @Override\n    public void shutdown() {\n        // shut down your provider\n    }\n\n    @Override\n    public ProviderEvaluation\u003cBoolean\u003e getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx) {\n        // resolve a boolean flag value\n    }\n\n    @Override\n    public ProviderEvaluation\u003cString\u003e getStringEvaluation(String key, String defaultValue, EvaluationContext ctx) {\n        // resolve a string flag value\n    }\n\n    @Override\n    public ProviderEvaluation\u003cInteger\u003e getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx) {\n        // resolve an int flag value\n    }\n\n    @Override\n    public ProviderEvaluation\u003cDouble\u003e getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx) {\n        // resolve a double flag value\n    }\n\n    @Override\n    public ProviderEvaluation\u003cValue\u003e getObjectEvaluation(String key, Value defaultValue, EvaluationContext ctx) {\n        // resolve an object flag value\n    }\n}\n```\n\nIf you'd like your provider to support firing events, such as events for when flags are changed in the flag management system, extend `EventProvider`.\n\n```java\nclass MyEventProvider extends EventProvider {\n    @Override\n    public Metadata getMetadata() {\n        return () -\u003e \"My Event Provider\";\n    }\n\n    @Override\n    public void initialize(EvaluationContext evaluationContext) throws Exception {\n        // emit events when flags are changed in a hypothetical REST API\n        this.restApiClient.onFlagsChanged(() -\u003e {\n            ProviderEventDetails details = ProviderEventDetails.builder().message(\"flags changed in API!\").build();\n            this.emitProviderConfigurationChanged(details);\n        });\n    }\n\n    @Override\n    public void shutdown() {\n        // shut down your provider\n    }\n\n    // remaining provider methods...\n}\n```\n\nProviders no longer need to manage their own state, this is done by the SDK itself. If desired, the state of a provider \ncan be queried through the client that uses the provider.\n\n```java\nOpenFeatureAPI.getInstance().getClient().getProviderState();\n```\n\n\u003e Built a new provider? [Let us know](https://github.com/open-feature/openfeature.dev/issues/new?assignees=\u0026labels=provider\u0026projects=\u0026template=document-provider.yaml\u0026title=%5BProvider%5D%3A+) so we can add it to the docs!\n\n### Develop a hook\n\nTo develop a hook, you need to create a new project and include the OpenFeature SDK as a dependency.\nThis 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.\nImplement your own hook by conforming to the `Hook interface`.\n\n```java\nclass MyHook implements Hook {\n\n    @Override\n    public Optional before(HookContext ctx, Map hints) {\n        // code that runs before the flag evaluation\n    }\n\n    @Override\n    public void after(HookContext ctx, FlagEvaluationDetails details, Map hints) {\n        // code that runs after the flag evaluation succeeds\n    }\n\n    @Override\n    public void error(HookContext ctx, Exception error, Map hints) {\n        // code that runs when there's an error during a flag evaluation\n    }\n\n    @Override\n    public void finallyAfter(HookContext ctx, FlagEvaluationDetails details, Map hints) {\n        // code that runs regardless of success or error\n    }\n};\n```\n\n\u003e Built a new hook? [Let us know](https://github.com/open-feature/openfeature.dev/issues/new?assignees=\u0026labels=hook\u0026projects=\u0026template=document-hook.yaml\u0026title=%5BHook%5D%3A+) so we can add it to the docs!\n\n\u003c!-- x-hide-in-docs-start --\u003e\n## ⭐️ Support the project\n\n- Give this repo a ⭐️!\n- Follow us on social media:\n  - Twitter: [@openfeature](https://twitter.com/openfeature)\n  - LinkedIn: [OpenFeature](https://www.linkedin.com/company/openfeature/)\n- Join us on [Slack](https://cloud-native.slack.com/archives/C0344AANLA1)\n- For more, check out our [community page](https://openfeature.dev/community/)\n\n## 🤝 Contributing\n\nInterested in contributing? Great, we'd love your help! To get started, take a look at the [CONTRIBUTING](CONTRIBUTING.md) guide.\n\n### Thanks to everyone who has already contributed\n\n\u003ca href=\"https://github.com/open-feature/java-sdk/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=open-feature/java-sdk\" alt=\"Pictures of the folks who have contributed to the project\" /\u003e\n\u003c/a\u003e\n\nMade with [contrib.rocks](https://contrib.rocks).\n\u003c!-- x-hide-in-docs-end --\u003e\n","funding_links":[],"categories":["功能切换"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-feature%2Fjava-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-feature%2Fjava-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-feature%2Fjava-sdk/lists"}