Simplified SPI

32 views
Skip to first unread message

Werner Keil

unread,
Apr 1, 2016, 4:43:02 PM4/1/16
to Units Users
Hi,

This isn't an April's Fool Day Joke feature, though it's announced on April 1st ;-)

While initial inspiration by JSR 354 for the Bootstrap class offered a nice start, we had a discussion among EG members whether or not to keep calling it Bootstrap. And by looking at possible alternatives in JSRs like CDI, JCache or JSON-P just to name a few, the discussion lead to replacing Bootstrap by simply merging it into ServiceProvider. Now an abstract base class. In Java SE 8 we could have added static methods to an interface, too, but the API must be compatible with Java ME 8 and at least Java 6 or 7 for SE/EE, too.

Instead of: 
SystemOfUnitsService service = Bootstrap.getService(SystemOfUnitsService.class);

You now call:
SystemOfUnitsService service = ServiceProvider.current().getSystemOfUnitsService();

The 0.9-SNAPSHOT release towards a Final Draft of JSR 363 contains those changes. As a result, the API JAR came down to slightl under 30 kB for the "Full Profile" (everything including SPI) while Code Coverage as a side-effect of it went up to nearly 95%, see https://github.com/unitsofmeasurement/unit-api

At least one service, QuantityFactoryService seems to have room for further improvement. It only provides a single element, QuantityFactoryService so it would sound logical to directly provide that from ServiceProvider instead. We'll discuss it in the EG. Please let us know, what you think here or in the other discussion forums like Gitter Chat on https://github.com/unitsofmeasurement/unit-api.

Kind Regards,
Werner
Reply all
Reply to author
Forward
0 new messages