{"id":15045848,"url":"https://github.com/microbean/microbean-helidon-webserver-cdi","last_synced_at":"2026-02-23T01:04:43.845Z","repository":{"id":80768279,"uuid":"154448333","full_name":"microbean/microbean-helidon-webserver-cdi","owner":"microbean","description":"Embeds the Helidon WebServer in CDI.","archived":false,"fork":false,"pushed_at":"2019-09-09T21:55:46.000Z","size":602,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T17:04:01.620Z","etag":null,"topics":["cdi","cdi-ecosystem","cdi-extension","cdi2","cdi20","helidon","helidon-se","helidon-webserver","java","java-se","portable-extension"],"latest_commit_sha":null,"homepage":"https://microbean.github.io/microbean-helidon-webserver-cdi","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/microbean.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-24T06:12:49.000Z","updated_at":"2019-09-09T21:55:48.000Z","dependencies_parsed_at":"2023-06-19T18:37:07.954Z","dependency_job_id":null,"html_url":"https://github.com/microbean/microbean-helidon-webserver-cdi","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/microbean/microbean-helidon-webserver-cdi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbean%2Fmicrobean-helidon-webserver-cdi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbean%2Fmicrobean-helidon-webserver-cdi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbean%2Fmicrobean-helidon-webserver-cdi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbean%2Fmicrobean-helidon-webserver-cdi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microbean","download_url":"https://codeload.github.com/microbean/microbean-helidon-webserver-cdi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbean%2Fmicrobean-helidon-webserver-cdi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29734133,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cdi","cdi-ecosystem","cdi-extension","cdi2","cdi20","helidon","helidon-se","helidon-webserver","java","java-se","portable-extension"],"created_at":"2024-09-24T20:52:20.936Z","updated_at":"2026-02-23T01:04:43.817Z","avatar_url":"https://github.com/microbean.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# microBean Helidon WebServer CDI\n\n[![Build Status](https://travis-ci.org/microbean/microbean-helidon-webserver-cdi.svg?branch=master)](https://travis-ci.org/microbean/microbean-helidon-webserver-cdi)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.microbean/microbean-helidon-webserver-cdi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.microbean/microbean-helidon-webserver-cdi)\n\n# Overview\n\nThis project consists of a [CDI portable\nextension](http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#spi) that\nembeds a [Helidon\n`WebServer`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/WebServer.html)\ninto a CDI environment and [starts\nit](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/WebServer.html#start--).\n\nThe portable extension will look for any\n[`Service`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/Service.html)\nclass it can find that [is\ndetectable](http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#packaging_deployment).\nIt will instantiate it and call its\n[`update(Routing.Rules)`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/Service.html#update-io.helidon.webserver.Routing.Rules-)\nmethod prior to starting the `WebServer`.\n\n# Why Would I Want To Use This?\n\nYou may be thinking: why would I want to put a web server in a CDI container?\nThis is probably because you are thinking of CDI as a component of a Java EE\napplication server.  But CDI 2.0 is usable in Java SE.\n\nIf you start the CDI container from your own `main` method like so:\n\n```\ntry (SeContainer container = SeContainerInitializer.newInstance().initialize()) {\n  // deliberately empty\n}\n```\n\n...or, equivalently, use the `microbean-main` project's `Main` class to do this\nfor you, then a CDI container comes up and goes down.  In between all of your\nCDI beans are instantiated and wired appropriately.\n\nSo don't think of a CDI container as something that lives inside a web server or\nalongside one.  Think instead of a web server as just another Java component in\nthe CDI ecosystem.\n\nAt this point you can probably see that if Helidon SE is just another component\nin the CDI ecosystem, and your `Service` implementations are just another\ncomponent in the CDI ecosystem, then the CDI container can instantiate and\nautowire all of them equivalently.\n\nThis gives you all the benefits of Helidon SE and all the benefits of CDI at the\nexpense of roughly 50 milliseconds of additional startup time while letting you\nwrite a simple Java SE application from a component-oriented perspective.\n\n# Simple Example\n\nSuppose you write a\n[`Service`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/Service.html)\nlike this:\n\n```\nimport io.helidon.webserver.Service;\nimport io.helidon.webserver.Routing;\nimport io.helidon.webserver.ServerRequest;\nimport io.helidon.webserver.ServerResponse;\n\n@ApplicationScoped\npublic class MyService implements Service {\n\n  private final SomeClientForSomething client;\n\n  @Inject\n  public MyService(final SomeClientForSomething client) {\n    super();\n    this.client = Objects.requireNonNull(client);\n  }\n\n  @Override\n  public void update(final Routing.Rules rules) {\n    rules.get(\"/foo\", this::handleFoo); // handle GET requests with the handleFoo method\n  }\n  \n  private void handleFoo(final ServerRequest request,\n                         final ServerResponse response) {\n    // You can use this.client here.\n  }\n\n}\n```\n\nThe presence of this class on the classpath will cause the CDI\ncontainer to create an instance of `MyService`, supply it with an\ninstance of `SomeClientForSomething` assuming that this bean is\npresent in the CDI container, and call its [`update`\nmethod](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/Service.html#update-io.helidon.webserver.Routing.Rules-).\nA [Helidon\n`WebServer`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/WebServer.html)\nwill then be created and\n[started](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/WebServer.html#start--)\nusing [default\nconfiguration](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/ServerConfiguration.html).\nThe webserver will stop when it receives a `CTRL-C` signal.\n\n# Customization\n\nAll intermediate objects required to create and start a `WebServer`\nare treated as CDI beans as well, with the end user's versions of\nthose beans (if any) being preferred over the built-in defaults.  So,\nfor example, if you were to supply your own `WebServer` producer\nmethod, that `WebServer` instance would be used instead.\n\nIf you do nothing, a default\n[`Config.Builder`](https://helidon.io/docs/latest/apidocs/io/helidon/config/Config.Builder.html)\nwill be created to build a\n[`Config`](https://helidon.io/docs/latest/apidocs/io/helidon/config/Config.html)\nobject.  The `Config` object so built will be used to create a\n[`ServerConfiguration.Builder`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/ServerConfiguration.Builder.html),\nwhich, in turn, will be used to build a\n[`ServerConfiguration`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/ServerConfiguration.html).\nThis general pattern applies all the way up to the\n[`WebServer`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/WebServer.html)\nitself (built by a\n[`WebServer.Builder`](https://helidon.io/docs/latest/apidocs/io/helidon/webserver/WebServer.Builder.html)).\n\nEach of these objects is treated as a CDI bean.  If the CDI bean in\nquestion does not exist, then a \"normal\" instance of the object in\nquestion is registered as a bean and instantiated appropriately by the\nCDI container.\n\nIn the case of such default instantiations, you can customize them if\nyou want.  For example, maybe you don't want to actually supply an\nalternate [`Config`]() implementation\u0026mdash;the default one is just\nfine\u0026mdash;but you _do_ want to slightly change how it's made.  To\nperform simple customization of this sort, you declare an observer\nmethod that receives the relevant `Builder` object as its observed\nparameter.  For example, somewhere in your CDI application, you can\nwrite:\n\n```\nprivate static final void customizeConfigBuilder(@Observes final Config.Builder configBuilder) {\n  builder.disableSystemPropertiesSource(); // or whatever\n}\n```\n\nThe `Builder` so customized will be used internally by this project to\nproduce `Config` objects (as CDI beans) that may be required by other\nHelidon objects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrobean%2Fmicrobean-helidon-webserver-cdi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrobean%2Fmicrobean-helidon-webserver-cdi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrobean%2Fmicrobean-helidon-webserver-cdi/lists"}