/demo-java-9-migration

A demo code base for a Java 9 migration

Primary LanguageJavaCreative Commons Zero v1.0 UniversalCC0-1.0

ServiceMonitor - Migration

An example application for my book The Java 9 Module System. The Service Monitor is an application that observes a hypothetical network of microservices by

  • contacting individual services
  • collecting and aggregating diagnostic data into statistics
  • persisting statistics
  • making statistics available via REST

It is split into a number of modules that focus on specific concerns. Each module has its own directory that contains the known folder structure, e.g. src/main/java.

It was developed as a Java 8 application and now needs to be made compatible with Java 9 and then be modularized.

Branches

Each of the branches contains a different version of the project:

Build and Execution

In the project's root folder:

  • to build: mvn clean install
  • to run: java -cp 'monitor/target/libs/*':'monitor/target/main-1.0-SNAPSHOT.jar' monitor.Main
  • to contact REST endpoints:
    • curl http://localhost:4567/stats/json
    • curl http://localhost:4567/stats/json64 | base64 -d
    • curl http://localhost:4567/stats/xml

Troubles

Migration

  • internal BASE64Encoder is gone ~> use Base64.getEncoder instead
  • JAXB API is not present ~> add java.xml.bind
  • Common annotations are not present ~> add java.xml.ws.annotations
  • split package: javax.annotation between java.xml.ws.annotations and jsr-305 ~> patch java.xml.ws.annotations
  • old version of Mockito causes warnings ~> update to newer version
  • application class loader is no longer a URLClassLoader

Modularization

  • unexpressed transitive dependencies:
    • monitor ~> monitor.statistics (for Statistics et al)
    • monitor.rest ~> jackson.core (for JsonProcessingException)