{"id":37020702,"url":"https://github.com/dragonzone/dropwizard-hk2","last_synced_at":"2026-01-14T02:25:05.368Z","repository":{"id":54974751,"uuid":"69465296","full_name":"dragonzone/dropwizard-hk2","owner":"dragonzone","description":"Dropwizard bundle enabling injection support for HealthChecks, Managed, Tasks, and more","archived":false,"fork":false,"pushed_at":"2023-08-19T15:28:19.000Z","size":191,"stargazers_count":22,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-05T22:49:12.868Z","etag":null,"topics":["dropwizard","hk2"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dragonzone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-28T13:20:32.000Z","updated_at":"2024-08-23T01:17:08.000Z","dependencies_parsed_at":"2022-08-14T07:50:52.479Z","dependency_job_id":null,"html_url":"https://github.com/dragonzone/dropwizard-hk2","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/dragonzone/dropwizard-hk2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonzone%2Fdropwizard-hk2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonzone%2Fdropwizard-hk2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonzone%2Fdropwizard-hk2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonzone%2Fdropwizard-hk2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dragonzone","download_url":"https://codeload.github.com/dragonzone/dropwizard-hk2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonzone%2Fdropwizard-hk2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dropwizard","hk2"],"created_at":"2026-01-14T02:25:04.903Z","updated_at":"2026-01-14T02:25:05.351Z","avatar_url":"https://github.com/dragonzone.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dropwizard HK2 Integration [![Build Status](https://jenkins.dragon.zone/buildStatus/icon?job=dragonzone/dropwizard-hk2/master)](https://jenkins.dragon.zone/blue/organizations/jenkins/dragonzone%2Fdropwizard-hk2/activity?branch=master) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/zone.dragon.dropwizard/dropwizard-hk2/badge.svg)](https://maven-badges.herokuapp.com/maven-central/zone.dragon.dropwizard/dropwizard-hk2/) [![Javadoc](https://javadoc.io/badge2/zone.dragon.dropwizard/dropwizard-hk2/javadoc.svg)](http://www.javadoc.io/doc/zone.dragon.dropwizard/dropwizard-hk2)\n\nThis bundle binds and integrates Dropwizard's `HealthCheck`, `Metric`, `MetricSet`, `LifeCycle`, `LifeCycle.Listener`, and `Managed`\nobjects with HK2, allowing these components to be registered directly with Jersey and fully injected with any other services also known to\nHK2. Additionally, it provides access to the Jersey `ServiceLocator` from the admin `ServletContext`, default bindings for many Dropwizard\ncomponents such as the `Validator`, `ObjectMapper`, `MetricRegistry`, `HealthCheckRegistry`, your `Application`, your `Configuration`, the\n`Environment` and `LifecycleEnvironment`, as well as each bundle added to your application.\n\nTo use this bundle, add it to your application in the initialize method:\n\n    @Override\n    public void initialize(Bootstrap\u003cYourConfig\u003e bootstrap) {\n        // This ensures there's only ever one HK2 bundle; don't use bootstrap.addBundle(new HK2Bundle\u003c\u003e());\n        HK2Bundle.addTo(bootstrap);\n    }\n\nThen, update your health checks, metrics, and managed components to use the custom Jersey component marker interfaces:\n`InjectableHealthCheck`, `InjectableManaged`, `InjectableLifeCycle`, `InjectableLifeCycleListener`, `InjectableMetric`, or\n`InjectableMetricSet`. These are necessary for Jersey to identify the components as a valid Jersey component, and just extend the\nDropwizard interfaces of similar name. Here is an example health check:\n\n    @Named(\"TestHealthCheck\")\n    public class TestInjectableHealthCheck extends InjectableHealthCheck {\n        private final TestConfig config;\n\n        @Inject\n        public TestInjectableHealthCheck(TestConfig config) {\n            this.config = config;\n        }\n\n        public TestConfig getConfig() {\n            return config;\n        }\n\n        @Override\n        protected Result check() throws Exception {\n            return Result.healthy();\n        }\n    }\n\nHealth checks and Metrics can also make use of the `@Named()` annotation to identify the name under which the component should be\nregistered. If a name is not provided, a warning will be printed and a name generated in the format of `ClassName.RandomUUID` under which\nthe component will be registered.\n\nLastly, register your components directly with Jersey:\n\n    @Override\n    public void run(TestConfig testConfig, Environment environment) throws Exception {\n        environment.jersey().register(YourInjectableHealthCheck.class);\n        environment.jersey().register(YourInjectableLifeCycle.class);\n    }\n\nThey will now be injected and registered properly with Dropwizard after HK2 and Jersey are initialized.\n\nTo access the `ServiceLocator` from the admin `ServletContext`, query the context attribute identified by `HK2Bundle.SERVICE_LOCATOR`:\n\n    ServiceLocator locator = (ServiceLocator) getServletConfig().getServletContext().getAttribute(HK2Bundle.SERVICE_LOCATOR);\n\n`RequestScoped` bindings are unavailable in the admin context, but singletons and other scopes are available.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdragonzone%2Fdropwizard-hk2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdragonzone%2Fdropwizard-hk2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdragonzone%2Fdropwizard-hk2/lists"}