This is a karaf application that demonstrates using Jersey to provide a REST API in karaf, and demonstrates how OSGi services can be injected into Jersey resources created by the Jersey framework. https://steinar.bang.priv.no/2018/08/03/use-jersey-to-provide-rest-apis-from-karaf-applications/
Steinar Bang dbb81c1d7a Replace java 11 with java 17 in github actions CI build | 5 meses atrás | |
---|---|---|
.github | 5 meses atrás | |
jacoco-coverage-report | 3 anos atrás | |
jerseyinkaraf.servicedef | 5 meses atrás | |
jerseyinkaraf.services | 5 meses atrás | |
jerseyinkaraf.webapi | 5 meses atrás | |
jerseyinkaraf.webcontext | 5 meses atrás | |
jerseyinkaraf.webgui | 5 meses atrás | |
src | 6 anos atrás | |
.editorconfig | 6 anos atrás | |
.gitignore | 6 anos atrás | |
LICENSE | 6 anos atrás | |
README.org | 5 meses atrás | |
pom.xml | 5 meses atrás |
This is a small apache karaf demo application that demonstrates how to use Jersey in Apache Karaf, and how to inject OSGi services into Jersey resources.
The application is a counter where you can click a button and see a value be incremented. The click of the button goes through a REST call and the returned value is displayed.
To avoid introducing confusing extra dependencies the demo is extremely primitive.
The focus is on using jersey in the HTTP web whiteboard.
That means there is no database stuff, just a counter value kept in memory (I have a "backend" to illustrate how an OSGi service can be injected into a jersey resource serving an HTTP path).
The "frontend" is just two javascript functions called from static HTML read from a classpath resource in the webgui servlet (again: to illustrate how a frontend calls a backend without introducing confusing details).
The sampleapp application implements a similar counter application, but with database, react frontend, users and login, and i18n support.
file:https://github.com/steinarb/jersey-demo/actions/workflows/jersey-demo-maven-ci-build.yml/badge.svg file:https://coveralls.io/repos/github/steinarb/jersey-demo/badge.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=alert_status#.svg file:https://maven-badges.herokuapp.com/maven-central/no.priv.bang.demos.jerseyinkaraf/jersey-demo/badge.svg
file:https://sonarcloud.io/images/project_badges/sonarcloud-white.svg
file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=sqale_index#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=coverage#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=ncloc#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=code_smells#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=sqale_rating#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=security_rating#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=bugs#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=vulnerabilities#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=duplicated_lines_density#.svg file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_jersey-demo&metric=reliability_rating#.svg
This will cause repeated clicks on the "Increment" button to result in 405 responses, because the webgui servlet now intercepts the requests, but that servlet doesn't support the POST requests used to increment the counter.
Reinstalling the webapi feature will cause the count to start again from 0.
This is a demo project and therefore have no releases.
To preserve a version of the demo project still running on karaf 4.2.x and using OSGi 6, the branch release/1.1.0 has been created for the karaf 4.2.x version.
branch | snapshot version | karaf version supported |
---|---|---|
release/1.1.0 | 1.1.0-SNAPSHOT | >=4.2.11 |
master | 2.0.0-SNAPSHOT | >=4.3.2 |
This software project is licensed under Apache License v. 2.
See the LICENSE file for details.