{"id":17826890,"url":"https://github.com/bmarwell/openliberty-content-negotiation-example","last_synced_at":"2026-01-21T10:37:09.946Z","repository":{"id":46008663,"uuid":"424277040","full_name":"bmarwell/openliberty-content-negotiation-example","owner":"bmarwell","description":"Try it out on the command line: `curl https://api.diceroll.bmarwell.de/`","archived":false,"fork":false,"pushed_at":"2025-12-21T04:59:20.000Z","size":376,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-22T21:58:54.539Z","etag":null,"topics":["dice","java","javaee","open-liberty","rest-api"],"latest_commit_sha":null,"homepage":"","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/bmarwell.png","metadata":{"files":{"readme":"README.adoc","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-03T15:22:55.000Z","updated_at":"2025-12-21T04:59:24.000Z","dependencies_parsed_at":"2023-10-23T13:30:38.754Z","dependency_job_id":"bfeef0c5-6cff-45b2-ba1a-ba41cfd8f897","html_url":"https://github.com/bmarwell/openliberty-content-negotiation-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bmarwell/openliberty-content-negotiation-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fopenliberty-content-negotiation-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fopenliberty-content-negotiation-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fopenliberty-content-negotiation-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fopenliberty-content-negotiation-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmarwell","download_url":"https://codeload.github.com/bmarwell/openliberty-content-negotiation-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fopenliberty-content-negotiation-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["dice","java","javaee","open-liberty","rest-api"],"created_at":"2024-10-27T18:55:26.711Z","updated_at":"2026-01-21T10:37:09.930Z","avatar_url":"https://github.com/bmarwell.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= OpenLiberty Content Negotiation Example\n:icons: font\n:toc: macro\n:toclevels: 4\n\nhttps://github.com/bmarwell/openliberty-content-negotiation-example/actions/workflows/maven.yaml[image:https://github.com/bmarwell/openliberty-content-negotiation-example/actions/workflows/maven.yaml/badge.svg[Maven\nCI]]\nhttps://opensource.org/licenses/Apache-2.0[image:https://img.shields.io/badge/License-Apache_2.0-blue.svg[License]]\nhttps://renovatebot.com[image:https://img.shields.io/badge/renovate-enabled-brightgreen.svg[Renovate]]\nlink:https://openliberty.io/[image:https://img.shields.io/badge/AppServer-Open%20Liberty-blue[AppServer]]\n\nThis is a port of link:https://github.com/diceroll-dev/dice-parser[Brian‘s Dice Parser] using link:https://github.com/oktadev/quarkus-content-negotiation-example[Quarkus with Content negotiation example] to link:https://openliberty.io/[OpenLiberty], using a lot more CDI (just for the fun).\n\nThis example runs only at Java 15, because IBM still has not published Java 16 or 17 images with OpenLiberty (as of 2021-11-04).\n\ntoc::[]\n\n== Differences from Brian‘s API\n\nJust for the fun of it, and because JSON is derived from JavaScript, I did set the config option `PropertyNamingStrategy.LOWER_CASE_WITH_UNDERSCORES`.\n\nThe output will have `under_scores` in field names instead of `lowerCamelCase` (as derived from Java getter methods).\n\nAs already mentioned, most classes were converted to interfaces and CDI beans.\n\n== Using the API\n\nThe calls are similar to Brian‘s API.\n\n=== Help API\n\n==== Curl user agent\n\n[source]\n----\n$ curl --url \"https://api.diceroll.bmarwell.de/\"\nWelcome to the Dice Parser!!\n\nRoll dice by making a request:\n    curl https://api.diceroll.bmarwell.de/roll?dice=2d6 -H \"Accept: text/plain\"\n\nOr get the result in JSON (the default):\n    curl https://api.diceroll.bmarwell.de/roll?dice=2d6 -H \"Accept: application/json\"\n----\n\n==== HTTPie user agent\n\n----\n$ curl  -H \"User-Agent: HTTPie/1.0.0\" --url \"https://api.diceroll.bmarwell.de/\"\nWelcome to the Dice Parser!!\n\nRoll dice by making a request:\n    http https://api.diceroll.bmarwell.de/roll dice==2d6 \"Accept: text/plain\"\n\nOr get the result in JSON:\n    http https://api.diceroll.bmarwell.de/roll dice==2d6 \"Accept: application/json\"\n----\n\n==== Generic User Agent (or none/unknown)\n\n----\n$ curl  -H \"User-Agent: \" --url \"https://api.diceroll.bmarwell.de/\"\nWelcome to the Dice Parser!!\n\nRoll dice by making a request:\n    GET https://api.diceroll.bmarwell.de/roll?dice=2d6\n    Accept: text/plain\n\nOr get the result in JSON:\n    GET https://api.diceroll.bmarwell.de/roll?dice=2d6\n    Accept: application/json\n----\n\n==== German Language\n\n----\n$ curl -H \"accept-language: de\" --url \"https://api.diceroll.bmarwell.de/\"\nWillkommen beim Würfelparser!!\n\nWürfeln Sie, indem Sie eine Anfrage stellen:\ncurl https://api.diceroll.bmarwell.de/roll?dice=2d6 -H \"Accept: text/plain\"\n\nOder rufen Sie das Ergebnis in JSON ab:\ncurl https://api.diceroll.bmarwell.de/roll?dice=2d6 -H \"Accept: application/json\"\n----\n\n=== Dice roll API\n\nSee link:https://github.com/diceroll-dev/dice-parser#supported-notation[Brian’s Docs] for all available options.\n\n==== Accept `text/plain` (or none specified):\n\n[source]\n----\n$ curl --url \"https://api.diceroll.bmarwell.de/roll?dice=2d6\"\n2d6 = 10\n--d6 = 6\n--d6 = 4\n----\n\n==== Accept `application/json`\n\n----\n$ curl -H \"accept: application/json\" --url \"https://api.diceroll.bmarwell.de/roll?dice=2d6\"\n\n{\n    \"expression\": {\n        \"number_of_dice\": 2,\n        \"number_of_faces\": 6\n    },\n    \"results\": [\n        {\n            \"expression\": {\n                \"number_of_dice\": 1,\n                \"number_of_faces\": 6\n            },\n            \"results\": [\n            ],\n            \"value\": 2\n        },\n        {\n            \"expression\": {\n                \"number_of_dice\": 1,\n                \"number_of_faces\": 6\n            },\n            \"results\": [\n            ],\n            \"value\": 2\n        }\n    ],\n    \"value\": 4\n}\n----\n\n== How to build\n\n=== Environment\n\nMake sure your java version is recent enough.\n\n[source,bash]\n----\nsdk env\n----\n\n=== Quick build with all checks\n\n[source,bash]\n----\n./mvnw verify\n----\n\n=== Build docker image\n\n[source,bash]\n----\n# needed for podman beforehand:\nexport DOCKER_HOST=\"unix://$XDG_RUNTIME_DIR/podman/podman.sock\"\nsystemctl enable --user --now podman.socket\nsystemctl enable --user --now podman.service\n# actual build\n./mvnw package -Pdockerize\n----\n\nImage will be built as `openlibertycontentrenegotiation/olcr-app-ol-docker:latest`\n\n=== Enable Open Liberty InstantOn\n\nThis feature is powered by Eclipse OpenJ9 and Linux CRIU.\n\nPrerequisites:\n\n* podman\n* podman-docker\n* set-up UNIX-host as can be seen above\n* jq -- as we enabled JSON logging\n\n[source,bash]\n----\n# remove old dangling image\ndocker rm olcr-checkpoint-container\n\n# build the InstantOn-Image\npodman run --name olcr-checkpoint-container --privileged --env WLP_CHECKPOINT=applications openlibertycontentrenegotiation/olcr-app-ol-docker:latest | grep -E '^{' | jq -s\n# now you should have a checkpointed container (check the logs)\n\n# to make it available, use:\npodman commit olcr-checkpoint-container oclr-instanton\n\n# this is now something you can start:\npodman run \\\n  --rm \\\n  --cap-add=CHECKPOINT_RESTORE \\\n  --cap-add=NET_ADMIN \\\n  --cap-add=SYS_PTRACE \\\n  --security-opt seccomp=unconfined \\\n  --security-opt systempaths=unconfined \\\n  --security-opt apparmor=unconfined \\\n  -p 9080:9080 \\\n  oclr-instanton\n----\n\n== What does this example show?\n\n=== OpenLiberty features\n\n* Resful WebServices 3.0, CDI 3.0, JSON-B(inding) 2.0 on OpenLiberty\n* Some OpenLiberty features, like\n** TLS1.3 over http/2\n** disabling CDI implicit bean archives\n** Preferred server compression\n** Modified cookie length\n** skipping META-INF processing\n** A bit of hardening (remove server header, disabled welcome page)\n** JSON logging for the docker container.\n** the easiness of using features\n\nAs well as\n\n* Using the `liberty-maven-plugin` for integration testing\n* Using link:https://github.com/eclipse/jkube/tree/master/kubernetes-maven-plugin[kubernetes-maven-plugin] for building Docker images\n* Using a shared class cache with OpenJ9 for insane startup times!\n* JVM options like:\n** Insanely low memory (64M to 128M max)\n** Less idle CPU by using https://www.eclipse.org/openj9/docs/xxidletuninggconidle/[`-XX:+IdleTuningGcOnIdle`].\n** Reduce startup time by delaying class verification until needed (https://www.eclipse.org/openj9/docs/xxclassrelationshipverifier/[`-XX:+ClassRelationshipVerifier`]).\n** Tune for virtualized environments (https://www.eclipse.org/openj9/docs/xtunevirtualized/[`-Xtune:virtualized`]).\n\n=== Startup time\n\nSome classes are pre-compiled using OpenJ9‘s AOT compiler.\nThe files are then saved to a shared class cache file.\nThis way, Java does not need to compile the files again on every startup.\n\n[source]\n----\n$ docker run -p 9080:9080 de.bmarwell.examples.openlibertycontentrenegotiation/olcr-app-ol-docker:1.0.0-SNAPSHOT\n\n[…]\n[2021-11-04T20:00:31.258+0000] 00000034 id=         com.ibm.ws.app.manager.AppMessageHelper                      A CWWKZ0001I: Application olcr-web-restv1-1.0.0-SNAPSHOT started in 0.526 seconds.\n----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmarwell%2Fopenliberty-content-negotiation-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmarwell%2Fopenliberty-content-negotiation-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmarwell%2Fopenliberty-content-negotiation-example/lists"}