An open API service indexing awesome lists of open source software.

https://github.com/panga/hammock-jpms

Hammock MicroProfile (CDI + JAXRS + JSON) HelloWorld using Java Module System (JPMS)
https://github.com/panga/hammock-jpms

hammock java jdk10 jpms

Last synced: 23 days ago
JSON representation

Hammock MicroProfile (CDI + JAXRS + JSON) HelloWorld using Java Module System (JPMS)

Awesome Lists containing this project

README

        

# Hammock JPMS

[Hammock MicroProfile](https://github.com/hammock-project/hammock) (CDI + JAX-RS + JSON) HelloWorld using Java Module System (JPMS).

The stack uses Weld 3 for CDI, RestEasy 3.5 for JAX-RS and Johnzon 1.1 for JSON

The total size of this example application is around `12mb` and the full Docker image is only `55mb`!

_Note: Tested with JDK 11-ea+23_

## How To

### Package and generate `target/modules` folder (weld profile)

`mvn clean package`

### Package and generate `docker image` (docker + weld profiles)

`mvn clean package -Pweld,docker`

### Package using with OpenWebBeans 2 for CDI (owb profile)

`mvn clean package -Powb`

### Run using the default JRE

`java --module-path target/modules --module hammock.jpms`

### Run using a minimal JRE (35mb)

1. Run jlink to create minimal JRE

```bash
jlink \
--add-modules java.logging,java.xml,java.naming,java.management,jdk.unsupported \
--verbose \
--strip-debug \
--compress 2 \
--no-header-files \
--no-man-pages \
--output target/jlink-image
```

2. Run minimal JRE with patch module for `java.beans`:

```bash
target/jlink-image/bin/java \
--patch-module java.base=target/patch/java.beans \
--add-exports java.base/java.beans=johnzon.mapper \
--add-exports java.base/java.beans=org.apache.logging.log4j.core \
--module-path target/modules \
--module hammock.jpms
```

_Note: https://github.com/panga/lite-beans was used to patch `java.beans` implementation required by some 3rd party dependencies and remove the requirement of adding `java.desktop` module into the minimal JRE._

### Run using the Docker image

`docker run --rm -it -p 8080:8080 hammock-jpms`

### Test the application

`curl http://localhost:8080/hello`