nixxcode / jvm-brotli

Lightweight, cross-platform Java library for the Brotli compression format
72 stars 10 forks source link

Remove Manual Call to BrotliLoader.loadBrotli() #16

Closed nixxcode closed 5 years ago

nixxcode commented 5 years ago

At present, the developer must invoke BrotliLoader.loadBrotli() to load the appropriate native library. This should be done internally by the callable (public) Java methods.

To compensate for the removal of manual loading, a boolean method similar to Brotli.isAvailable() should be implemented to give the developer a way to test for Brotli availability.

UPDATE: The design choice on this issue has changed. Given jvm-brotli's platform dependent nature, the user should always be calling BrotliLoader.isBrotliAvailable() before attempting to "enable" the use of Brotli in their own application.

This means the native library loading can remain tied to this method. It is much simpler than forcing each and every object in the library to check for loaded status.

The difference from previous version, is that the new method returns a boolean, indicating if Brotli is available to use. When called for the first time in a JVM instance, it attempts to load the native lib. If it fails, it prints an exception explaining why. Regardless of failure or success, any further calls to this method will only return true or false, no further load attempts will be made beyond the first call.