{"id":19243469,"url":"https://github.com/bootique/bootique-jersey","last_synced_at":"2025-04-21T09:33:06.950Z","repository":{"id":38814908,"uuid":"47816910","full_name":"bootique/bootique-jersey","owner":"bootique","description":"Provides Jersey JAX-RS integration with Bootique.","archived":false,"fork":false,"pushed_at":"2025-04-19T13:22:57.000Z","size":1218,"stargazers_count":8,"open_issues_count":5,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-19T18:03:32.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://bootique.io","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/bootique.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,"zenodo":null}},"created_at":"2015-12-11T09:20:13.000Z","updated_at":"2025-04-19T13:23:00.000Z","dependencies_parsed_at":"2023-12-05T01:36:38.329Z","dependency_job_id":"6aa18053-335a-4de0-9c2c-b5f06da2011e","html_url":"https://github.com/bootique/bootique-jersey","commit_stats":null,"previous_names":["nhl/bootique-jersey"],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bootique%2Fbootique-jersey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bootique%2Fbootique-jersey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bootique%2Fbootique-jersey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bootique%2Fbootique-jersey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bootique","download_url":"https://codeload.github.com/bootique/bootique-jersey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250032325,"owners_count":21363820,"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":[],"created_at":"2024-11-09T17:18:07.063Z","updated_at":"2025-04-21T09:33:01.934Z","avatar_url":"https://github.com/bootique.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n  Licensed to ObjectStyle LLC under one\n  or more contributor license agreements.  See the NOTICE file\n  distributed with this work for additional information\n  regarding copyright ownership.  The ObjectStyle LLC licenses\n  this file to you under the Apache License, Version 2.0 (the\n  \"License\"); you may not use this file except in compliance\n  with the License.  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an\n  \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n  KIND, either express or implied.  See the License for the\n  specific language governing permissions and limitations\n  under the License.\n  --\u003e\n\n[![build test deploy](https://github.com/bootique/bootique-jersey/actions/workflows/maven.yml/badge.svg)](https://github.com/bootique/bootique-jersey/actions/workflows/maven.yml)\n[![Maven Central](https://img.shields.io/maven-central/v/io.bootique.jersey/bootique-jersey.svg?colorB=brightgreen)](https://search.maven.org/artifact/io.bootique.jersey/bootique-jersey/)\n\n# bootique-jersey\nProvides [Jersey](https://jersey.java.net/) JAX-RS server and client integration with [Bootique](http://bootique.io).\nThis provides the necessary API to create REST services and consume someone else's REST services.\n\n## Jersey Server\n\nIntegrates JAX-RS server as a servlet in Bootique. See usage example\n[bootique-rest-demo](https://github.com/bootique-examples/bootique-rest-demo). A few quick tips:\n\n\n_Jakarta vs JavaEE: Bootique 3.x supports both the legacy JavaEE and the newer Jakarta versions of Jersey. Each \nBootique Jersey module is shipped in two flavors (with and without `-jakarta` in the name). The examples below a based \non the newer Jakarta modules. But It is your choice which one to use. The API of both is identical (except for the \nimport package)._\n\nAdd Jersey server capabilities to your Bootique app:\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003eio.bootique.jersey\u003c/groupId\u003e\n\t\u003cartifactId\u003ebootique-jersey-jakarta\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\nPublish individual endpoints:\n```java\npublic void configure(Binder binder) {\n    JerseyModule.extend(binder)\n        .addResource(MyApi1.class)\n        .addResource(MyApi2.class);\n}\n```\n\nAdd JSON serialization capabilities:\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003eio.bootique.jersey\u003c/groupId\u003e\n\t\u003cartifactId\u003ebootique-jersey-jakarta-jackson\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\nExclude null properties from JSON responses:\n```java\npublic void configure(Binder binder) {\n    JerseyJacksonModule.extend(binder).skipNullProperties();\n}\n```\n\nEnable debug output of the application resources:\n\n```yaml\nlog:\n  loggers:\n    io.bootique.jersey:\n      level: debug # or \"trace\" for even more detailed output\n```\n\n## Jersey Client\n\nIntegrates JAX-RS-based HTTP client in Bootique with support for various types of\nserver authentication (BASIC, OAuth2, etc.). Allows to configure multiple\nclient runtime parameters, as well as define server URL endpoints.\nImplementation is built on top of Jersey and Grizzly connector.\n\n### Basic Client Usage\n\nAdd the client module to your Bootique app:\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003eio.bootique.jersey\u003c/groupId\u003e\n\t\u003cartifactId\u003ebootique-jersey-jakarta-client\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\nOr if you need clients with health checks and metrics:\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003eio.bootique.jersey\u003c/groupId\u003e\n\t\u003cartifactId\u003ebootique-jersey-jakarta-client-instrumented\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\nInject `HttpClientFactory` and create client instances:\n\n```java\n@Inject\nprivate HttpClientFactory clientFactory;\n\npublic void doSomething() {\n\n    Client client = clientFactory.newClient();\n    Response response = client\n        .target(\"https://example.org\")\n        .request()\n        .get();\n}\n```\n\nOptionally, configure client parameters:\n```yml\njerseyclient:\n  followRedirects: true\n  readTimeoutMs: 2000\n  connectTimeoutMs: 2000\n  asyncThreadPoolSize: 10\n```\n\n### URL Targets\n\nIn the example above we injected `HttpClientFactory` (that produced instances\nof JAX RS `Client`), and hardcoded the endpoint URL in Java. Instead you\ncan map multiple URLs in the ```.yml```, assigning each URL a symbolic\nname and optionally providing URL-specific runtime parameters:\n\n```yml\njerseyclient:\n  targets:\n    google:\n      url: \"https://google.com\"\n    bootique:\n      url: \"https://bootique.io\"\n      followRedirects: false\n```\nNow you can inject `HttpTargets` and acquire instances of `WebTarget`\nby name:\n```java\n@Inject\nprivate HttpTargets targets;\n\npublic void doSomething() {\n\n    Response response = targets.newTarget(\"bootique\").request().get();\n}\n```\nThis not only reduces the amount of code, but more importantly allows\nto manage your URLs (and their runtime parameters) via configuration.\nE.g. you might use a different URL between test and production environments\nwithout changing the code.\n\n### Using BASIC Authentication\n\nIf your server endpoint requires BASIC authentication, you can associate\nyour Clients and WebTargets with a named auth configuration. One or more\nnamed configurations are setup like this:\n\n```yml\njerseyclient:\n  auth:\n    myauth:\n      type: basic\n      username: myuser\n      password: mypassword\n```\nWhen creating a client in the Java code you can reference auth name (\"myauth\"):\n```java\n@Inject\nprivate HttpClientFactory clientFactory;\n\npublic void doSomething() {\n\n    Client client = clientFactory.newBuilder().auth(\"myauth\").build();\n    Response response = client\n        .target(\"https://example.org\")\n        .request()\n        .get();\n}\n```\nOr you can associate a target with it:\n```yml\njerseyclient:\n  ...\n  targets:\n    secret:\n      url: \"https://example.org\"\n      auth: myauth\n```\n\n### Using OAuth2 Authentication\n\nOAuth2 authentication is very similar to BASIC. In fact they are no different\non the Java end. In YAML the type should be \"oauth2\", and an extra \"tokenUrl\"\nproperty is required. Here is an example auth for a Twitter client:\n\n```yml\njerseyclient:\n  auth:\n    twitter:\n      type: oauth2\n      tokenUrl: https://api.twitter.com/oauth2/token\n      username: sdfjkdferefxfkdsf\n      password: Efcdsfdsflkurecdsfj\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbootique%2Fbootique-jersey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbootique%2Fbootique-jersey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbootique%2Fbootique-jersey/lists"}