inkycode / nexus

A tiny service framework for Java.
0 stars 0 forks source link

Multiple Service Providers #1

Closed inkycoder closed 8 years ago

inkycoder commented 8 years ago

Currently there is a known limitation where there is a one to one mapping of Services to Providers in the runtime framework.

Ideally you should be able to have multiple Providers for a given Service and the framework should pick the best one upon request based upon attributes (still undecided what attributes should be used).

This should be straight forward to do as the framework already outputs multiple Service Descriptors, e.g.

[ {
  "service" : "com.inkycode.nexus.services.ServiceOne",
  "provider" : "com.inkycode.nexus.services.impl.ServiceOneImpl"
}, {
  "service" : "com.inkycode.nexus.services.ServiceTwo",
  "provider" : "com.inkycode.nexus.services.impl.ServiceTwoImplOne"
}, {
  "service" : "com.inkycode.nexus.services.ServiceTwo",
  "provider" : "com.inkycode.nexus.services.impl.ServiceTwoImplTwo"
} ]

Current idea is to allow for a priority attribute on the Service annotation, allowing the frame work to rank based on this value when a Service is requested.

This issue will need to be resolved before factory services can be considered working.

inkycoder commented 8 years ago

This issue can now be resolved.

In the latest release (0.1.4) you can now annotate multiple service providers. There is a new service attribute called priority, this value is used during auto resolution of services via the framework.getService method.