Adam Heath wrote:
Adrian Crum wrote:
Adam Heath wrote:
However, if there was a central factory, that used the ServiceRegistry
pattern, and framework/entity implemented that, getGenericDelegator
then called the ServiceRegistry implementation, logging a warning(from
perspective of caller) while doing so, and the base factory then
loaded the delegator thru ServiceRegistry, then existing code will
still work, you'd get a logged warning, and you'd support the new design.
Are you referring to this:

http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Service%20Provider

Yes, using javax.imageio.spi.ServiceRegistry; an example of it's use
is in CachedClassLoader.

java 1.6 has java.util.ServiceLoader, but it's a slightly different api.


So, the code:

GenericDelegator delegator = GenericDelegator.getGenericDelegator(String delegatorName);

would be replaced with something like:

DelegatorFactory factory = (DelegatorFactory) UtilObject.getServiceProviderByClass(DelegatorFactory.class); DelegatorInterface delegator = DelegatorFactory .getGenericDelegator(String delegatorName);

where the method

public static Object UtilObject.getServiceProviderByClass(Class providerClass);

would use javax.imageio.spi.ServiceRegistry to look up the provider class.

Is that correct?

-Adrian

Reply via email to