[EMAIL PROTECTED] a écrit :
> I think there is a significant use case: when the user wants to set a
> library wide default and be done with it. The alternative is to provide
> setters for factories in every piece of code that needs them and
> have client code inject the factories everywhere.
> Think about people willing to use their own Feature implementation.
> Alternative 1 is to pass a factory to every call that can build a
> feature, altenative 2 is to set a library
> wide chooser. Alternative 1 is not so bad, just not very convenient...
I can elaborate on this example. Hints provides a way for users to configure
their application in a central place, without interfering with other
applications that use Geotools in the same JVM. A user can write the following
in some central place of his code:
Hints hints = new Hints(null);
hints.put(Hints.STYLE_FACTORY, ...);
hints.put(Hints.CRS_AUTHORITY_FACTORY, ...);
Any factory not enumerated in the hints map means "any implementation is okay",
so the user enumerates only the factory he care about. Note also that the user
can replace
hints.put(Hints.CRS_AUTHORITY_FACTORY, someFactory);
by
hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
which means "any factory with (longitude,latitude) axis order". It may be
backed
by epsg-wkt as well as epsg-hsql. I'm not aware of any way to get this
functionality with constructor or method injection.
Next, he should pass the 'hints' map either to FactoryFinder, or to the
constructor if he wants to instantiate a Geotools object directly. Example:
cof = FactoryFinder.getCoordinateOperationFactory(hints);
or
cof = new DefaultCoordinateOperationFactory(hints);
The constructor shall uses the specified hints for obtaining any dependencies.
For example:
public DefaultCoordinateOperationFactory(Hints hints) {
mtFactory = FactoryFinder.getMathTransformFactory(hints);
}
The DefaultMathTransformFactory can itself uses the hints for obtaining other
dependencies, etc. As you can see, the hints are cascaded at construction time.
So if the user creates a Hints map in some central place and pass those hints
to
a top-level Geotools class (for example some Canvas implementation in the GO-1
module), then the hints should be cascaded to all dependencies. Passing the
hints to every top-level Geotools class to be created (I believe there is few
of
them in a typical application) should cause the hints to be cascaded in every
aspect of the application. If an other user pass a different map of hints to
the
same top-level Geotools classes, this different set of hints is also cascaded
in
new object instances without interference with the first user.
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