Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Java service discovery framework

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:

  • Use SPI -- this is not very flexible: I'd like something that maybe works with annotations, or just looks for an interface that is extended, without having to add external text files, too.
  • Use Commons Discovery -- looks like a dead end, as the last release is 0.4 from back in 2005
  • Use Java Simple Plugin Framework. 5 minutes and it works. No XML. -- this looks like very immature.

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.

like image 234
Lóránt Pintér Avatar asked Jul 13 '10 08:07

Lóránt Pintér


People also ask

What is service discovery framework?

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.

Is Eureka a client side service discovery?

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.

What is difference between ZUUL and Eureka?

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.)


1 Answers

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.

like image 125
skaffman Avatar answered Sep 22 '22 14:09

skaffman