Skip to content

tinosteinort/myhashlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ServiceLoader Example

This is an example for an API extendable with Implementations from other JARs within the classpath.

To load implementations from an interface, the ServiceLoader mechanism is used.

See example: https://github.com/tinosteinort/myhashlib-usage-example

The example shows a simple case. There is an API Module in which the myhashlib API is defined. The API allows to get the name of all supported hashing algorithms and to get an implementation by a specific name.

// get available functions
Set<String> names = HashFunctions.getAvailableHashFunctions();
// get a function by name
HashFunction function = HashFunctions.getInstance("WeakHash");
// execute a function
String hashValue = function.execute("Data to hash");

The API project also delivers a implementation of a weak algorithm ("WeakHash"). To provide a new implementation, just add a new dependency. See myhashlib-sha for a full implementation of the API. Don't forget to look at this File, if you want to provide a new implementation.

About

Example for an API extenable with Implementations from other JARs within the classpath.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages