I would like to discover all implementations of an interface during runtime in a Java app, and load those classes dynamically from JAR files that the user can add to a folder. It's a plug-in system, basically.
I found a few solutions for this:
Are there any other widely used solutions for this?
Update: There is no need for code separation, and OSGi seems to be far too complex for my simple needs right now. I also added "Simple" to the title of this question to clarify my intentions.
The service discovery framework provides a basis for developing plug-ins to discover services from any target environment. This means that, in addition to the target environments supported by the WSRR service discovery mechanism, you can discover services from your own custom target environments.
The service instance's registration is typically refreshed periodically using a heartbeat mechanism. Netflix OSS provides a great example of the client‑side discovery pattern. Netflix Eureka is a service registry. It provides a REST API for managing service‑instance registration and for querying available instances.
Zuul acts as the API gateway, providing a uniform, single point of entry into the set of microservices, while Eureka is essentially used as a “meta data” transport. Each client application instance (read microservice) registers its instance information (location, port, etc.)
It's bit on the heavy side, but you should consider Apache Felix or Eclipse Equinox, both are OSGi implementations which are very much alive and kicking, but possibly overkill for your needs. However, this is one of the very problems that OSGi is designed to solve.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With