> The purpose of service locators in my experience is to decouple > services so that they are explicitly not required at compile time. It > depends whether you want arbitrary sets of services, or just a single > place to define specific singleton/global services as to whether you > would find it useful to specify services in a compiled java file or in > a configuration file. ServiceLoader is not designed to be a > configuration framework to define specific services, but it is great > if you want to use any and all services that are available. >
sure, that is indeed the way we _already use_ the ServiceLoader to dynamically load Any23 CLI plugins, but I was referring to the fact that the ServiceLoader is not typesafe as you asserted, since wrong bindings between service definition and implementations can be detected at runtime only. There's no way ATM javac checks services type defined in META-INF/services. > From what I can tell, in Any23 we want to load up any and all services > that are available at runtime and the user will specify which one they > want to use with an identifier or MIME-Type, so ServiceLoader fits > that purpose in my view. +1 I like the idea > > In the api patch I tried to reduce the confusion, particularly > removing the use of Class.getConstructor in WriterRegistry and > replacing it with a factory. There are two FIXME notes in the patch > where I would like to remove hardcoded factories and format > identifiers. > good! I will try to have a look tomorrow, didn't find enough spare time today :( best, -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/
