Tutorial by Examples

The following example shows how to instantiate a class for logging via the ServiceLoader. Service package servicetest; import java.io.IOException; public interface Logger extends AutoCloseable { void log(String message) throws IOException; } Implementations of the service The...
The ServiceLoader is a simple and easy to use built-in mechanism for dynamic loading of interface implementations. With the service loader - providing means for instantation (but not the wiring) - a simple dependency injection mechanism can be built in Java SE. With the ServiceLoader interface and ...

Page 1 of 1