Justin Deoliveira a écrit :
> I don't think that there should be a factory finder at all. Instead code
> that needs a StyleFactory or a FilterFactory should declare a setter or
> a constructor argument.
> 
> I think a "finder" should only be used when there are multiple
> implementations of a particular interface, and you need to iterate over
> them. Not for a class that just needs a single implementation. How does
> the finder know which one to use if there are multiple implementations
> around? This is a decision should be left up to the end user /
> application imho.

We do have mutliple implementations of a particular interface. For example we 
have 2 implementations of CRSAuthorityFactory: one that uses axis order as 
specified in the EPSG database, and an other one that force the (longitude, 
latitude) axis order. We also have multiple instances of 
CoordinateOperationFactory: one with strict datum shifts, and an other one with 
lenient datum shifts.

Factories are ordered according a "priority" number. Factories with highest 
priority are selected first. The priority numbers are hard-coded in every 
factory implementation. However this is nothing more than a *default* ordering. 
Users can change the ordering on a system-wide basis, or specify explicitly a 
specific factory on a case-by-case basis.

All FactoryFinder (the ones build on top of FactoryRegistry, not the old 
StyleFactoryFinder and FilterFactoryFinder) expects a Hints argument. If the 
Hints are null, then FactoryFinder returns a default factory using the 
above-cited priority ordering. If the Hints argument is non-null, then it is 
used in order to select explicitly a factory.

So how the user can specify a factory? Like this:

   Hints hints = new Hints(null);
   hints.put(Hints.STYLE_FACTORY,  myFactory2);
   hints.put(Hints.FILTER_FACTORY, myFactory1);
   ...etc...

   StyleFactory  sf = CommonFactoryFinder.getStyleFactory(hints);
   FilterFactory ff = CommonFactoryFinder.getFilterFactory(hints);

Lets examine the later case. If a Hints.FILTER_FACTORY entry exists in the hint 
map, it is used for selecting the factory. Otherwise a default factory is 
selected.

        Martin

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to