|
Jaroslav, I can act as sponsor for this change. My understanding from looking at the code is that the change is as
follows. Today, you can supply an implementation of the SPI
com.example.Foo by putting a jar file in the classpath (etc) that
contains a file called META-INF/services/com.example.Foo which might
contain lines like: com.example.providers.Bar To instantiate this provider, ServiceLoader loads the class
com.example.providers.Bar and instantiates its public no-arg
constructor. The Bar class must be a subtype of com.example.Foo. With your proposed change, the above will still be possible, but
additionally the file can contain lines like: com.example.providers.Bar.baz() To instantiate this provider, ServiceLoader loads the class
com.example.providers.Bar and calls its public static method baz(). The
Bar class does not have to be a subtype of com.example.Foo but the
return type of baz() does. Can you say a bit more about the rationale here? I understand why
SPIs should be defined with abstract classes rather than interfaces,
but ServiceLoader already supports both classes and interfaces. I can
see why final classes might be of interest (so you can add new methods
without fearing a clash with an existing subclass method name), and I
guess you have in mind that such classes could have their behaviour
defined via constructor parameters, with each new version adding a new
constructor; but rather than guessing it would be nice to see an
example. Éamonn McManus · JMX Spec Lead · http://weblogs.java.net/blog/emcmanus
Jaroslav Tulach wrote: Thanks for the clarification, Mark. I've heard about some umbrella JSR for each release of the JDK before and I was hoping that my proposed change could be covered as part of it. Thanks for confirming that such aggregation is possible. |
- [PATCH] Enhance ServiceLoader to understan... Jaroslav Tulach
- Re: [PATCH] Enhance ServiceLoader to ... Jaroslav Tulach
- Re: [PATCH] Enhance ServiceLoader... David Holmes - Sun Microsystems
- Re: [PATCH] Enhance ServiceLo... Mark Reinhold
- Re: Maintenance Reviews w... Jaroslav Tulach
- Re: Maintenance Revi... Eamonn McManus
- Re: Maintenance ... Jaroslav Tulach
- Re: Maintenance ... Jaroslav Tulach
- Technical review was: [PATCH] Enhance... Jaroslav Tulach
- Re: Technical review was: [PATCH]... Alan Bateman
