{"id":17846458,"url":"https://github.com/technicalguru/jersey-client","last_synced_at":"2025-04-02T15:41:14.265Z","repository":{"id":65221424,"uuid":"586183115","full_name":"technicalguru/jersey-client","owner":"technicalguru","description":"A basic structure for building clients with jersey","archived":false,"fork":false,"pushed_at":"2024-07-19T06:40:24.000Z","size":101,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-08T06:30:55.996Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/technicalguru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-01-07T08:23:02.000Z","updated_at":"2024-07-19T06:40:27.000Z","dependencies_parsed_at":"2024-01-30T11:25:55.492Z","dependency_job_id":"e9d0ab6a-b0d5-4b79-8b3e-55b65288a7ac","html_url":"https://github.com/technicalguru/jersey-client","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalguru%2Fjersey-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalguru%2Fjersey-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalguru%2Fjersey-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalguru%2Fjersey-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technicalguru","download_url":"https://codeload.github.com/technicalguru/jersey-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246847052,"owners_count":20843438,"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-10-27T21:39:59.323Z","updated_at":"2025-04-02T15:41:14.248Z","avatar_url":"https://github.com/technicalguru.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jersey-client\nA basic structure for building clients with jersey.\n\n## Maven Coordinates\n\n```\n\u003cdependency\u003e\n\t\u003cgroupId\u003eeu.ralph-schuster\u003c/groupId\u003e\n\t\u003cartifactId\u003ejersey-client\u003c/artifactId\u003e\n\t\u003cversion\u003e2.1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\nYou shall subclass your main client for the specific API. Derive from ``JerseyClient``. Here is an example.\n\n```\npublic class MyApiClient extends JerseyClient {\n\n\tpublic MyApiClient(JerseyClientConfig config) {\n\t\tsuper(config);\n\t}\n\t\n}\n```\n\nIf you have to access ressources with sub-paths, it is advisable to to create separate clients\nas sub clients. Always derive from ``AbstractClient``.  e.g.\n\n```\npublic class MySubResourceClient extends AbstractClient {\n\n\tpublic MySubResourceClient(WebTarget target) {\n\t\tsuper(target.path(\"/sub-resource\"));\n\t}\n\t\n}\n```\n\nand provide access to it in the parent client:\n\n```\npublic class MyApiClient extends JerseyClient {\n\n\tpublic MySubResourceClient subResource() {\n\t\tget(MySubResourceClient.class)\n\t}\n\t\n}\n```\n\nYou can apply this structure to sub-clients too.\n\n## Configuration\nYou are free to subclass ``JerseyClientConfig`` to provide more configuration specific to your use case.\nOverride the ``configure()`` method to do your configuration:\n\n```\npublic class MyApiClient extends JerseyClient {\n\n\tpublic MyApiClient(MyDerivedConfig config) {\n\t\tsuper(config);\n\t}\n\n\t@Override\n\tprotected void configure(MyDerivedConfig config, ClientFilter clientFilter) {\n\t\tsuper.configure(config, clientFilter);\n\t\t\n\t\t// ... do your stuff here\n\t}\n\t\n}\n```\n \n## Request Examples\n\nHere are some examples how to implement methods in your clients:\n\n```\n\t/** Requesting a paged HATEOAS result list using GET method */\n\tpublic ResultList\u003cUser\u003e list(String search, String sort, Integer page, Integer pageSize) {\n\t\tGenericType\u003cHateOasPagedList\u003cUser\u003e\u003e typeRef = new GenericType\u003cHateOasPagedList\u003cUser\u003e\u003e() {};\n\t\tWebTarget target = getTarget(sort, page, pageSize);\n\t\tif (search != null) target = target.queryParam(\"search\", search);\n\t\treturn getResults(target.request().get(typeRef));\n\t}\n\n\t/** Requesting a single object using GET method */\n\tpublic User get(Long id) {\n\t\treturn getTarget().path(id.toString()).request().get(User.class);\n\t}\n\t\n\t/** Creating an object using POST method */\n\tpublic User create(User user) {\n\t\treturn getTarget().request().post(Entity.entity(user, MediaType.APPLICATION_JSON), User.class);\n\t}\n\t\n\t/** Saving an object using PUT method */\n\tpublic User save(User user) {\n\t\treturn getTarget().path(user.getId().toString()).request().put(Entity.entity(user, MediaType.APPLICATION_JSON), User.class);\n\t}\n\t\n\t/** Deleting an object using DELETE method */\n\tpublic User delete(long id) {\n\t\treturn getTarget().path(id.toString()).request().delete(User.class);\n\t}\n\n```\n\n## API Reference\n\nJavadoc API for latest stable version can be accessed [here](https://www.javadoc.io/doc/eu.ralph-schuster/jersey-client/latest//index.html).\n\n## Important Changes\n\n * v2.1 requires Java 21 now\n * v2 is using Jakarta libraries - however, v2.0.0 was a broken release in that respect.\n \n## Contribution\n\n * [Project Homepage](https://github.com/technicalguru/jersey-client)\n * [Issue Tracker](https://github.com/technicalguru/jersey-client/issues)\n  \n## License\n\nJersey Client is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU \nLesser General Public  License as published by the Free Software Foundation.\n\nJersey Client is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied \nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public \nLicense for more details.\n\nYou should have received a copy of the GNU Lesser General Public License along with Jersey Client.  If not, see \n\u003chttp://www.gnu.org/licenses/lgpl-3.0.html\u003e.\n\nSummary:\n 1. You are free to use all this code in any private or commercial project. \n 2. You must distribute license and author information along with your project.\n 3. You are not required to publish your own source code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnicalguru%2Fjersey-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnicalguru%2Fjersey-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnicalguru%2Fjersey-client/lists"}