Andrea Aime a écrit :
> The whole thing uses the getServiceProviderByClass(Class)
> method, which returns the one and only factory instance
> registered for a certain factory class...


I can confirm that GeoTools FactoryRegistry requires a different class for each 
factory. Actually this is the way that the JDK service registry works - both 
javax.imageio.spi.ServiceRegistry and the new java.util.ServiceLoader 
introduced 
in Java 6. This is maybe in order to be consistent with the fact that factories 
are expected to be registered in the META-INF/services/ directory and are 
instantiated by invoking their no-argument constructor, with no way to pass 
parameters (if we forget about the hints which are a GeoTools-specific 
extension).

If there is many factories of the same class, then I guess that something 
distinguish those instances. Maybe a parameter given to the constructor, or 
something similar. What is distinguishing the various instances?

Once the aspect that distinguish the instances is identified, is there any way 
to create a class thats look like the following?

    public class AlgorithmFactory extends AbstractFactory {
        public Algorithm getAlgorithm(TheAspectThatDistinguish...) {
             return ...
        }
    }

and register only the above class as the factory? This is a bit similar to 
AuthorityFactory working.

     Martin

------------------------------------------------------------------------------
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to