It's easy. The user can just add a "fragment" module that only contains the META-INF/services declarations. For example, if the default ranking for Jetty is 1 and Tomcat is 2 and the user wants to use Jetty instead of Tomcat, he/she can just add a new declaration for Jetty using ranking 3.

Thanks,
Raymond
--------------------------------------------------
From: "ant elder" <[email protected]>
Sent: Tuesday, May 19, 2009 12:11 AM
To: <[email protected]>
Subject: Re: Supporting an optional ranking attribute for system services

On Tue, May 19, 2009 at 12:59 AM, Raymond Feng <[email protected]> wrote:
Hi,

In Tuscany, we can declare service implementations using the
META-INF/services/<SPI name> pattern. One of the use cases is to allow some
of the implementations to be replaced to fit the hosting environment. If
there are more than one services with the same name are available, we
randomly pick the "first" one. This makes the "replacement" not
straightforward.

To fix this problem, I added the support for the "ranking" attribute (FYI,
OSGi has the idea for services). The discovered system services will be
sorted based on the ranking (if not present, default to 0). For example, we can use it to control which embedded HTTP server (Tomcat or Jetty) is used.
The attribute can be potentially used to define the ordering of multiple
extensions for the same extension point.

Thanks,
Raymond

I guess it would fix the random choice but a ranking approach doesn't
really make this any more flexible does it? The problem is that users
can't easily change the ranking - if we set the Jetty servlet host to
have a higher ranking than the tomcat one then how do users who want
to use Tomcat do that?

How about instead changing to use a config file where you can say
explicitly which extensions to use? That would fix this and some other
issues that we have with the current approach.

...ant

Reply via email to