I concur.
Near as I can tell the FactoryRegistry implements used by GeoTools seems
to have no ability to construct implementations on the CLASSPATH using
user supplied hints. In every case a no argument constructor is used
(that refers to the global hints).
What the FactoryRegistry implementation does do is check the global
hints that were used and uses them to store an instance for reuse.
I am going to try a Hack because I am sick of this not working.
- The obvious one is to patch FactoryRegistry to look for the correct
constructor - I tried and failed
- We could let it make an invalid Factory, then do reflection on the
instance returned and create a good one - sounds horrible
- Store the user supplied Hints in a ThreadLocal at the FactoryRegistry,
so we can go with the coding idiom everyone seems to be doing anyways:
> public PrimitiveFactoryImpl() {
> this( null );
> }
> public PrimitiveFactoryImpl( Hints hints ) {
> this.crs = (CoordinateReferenceSystem) hints.get( Hints.CRS );
> this.positionFactory =
> GeometryFactoryFinder.getPositionFactory(hints);
>
> hintsWeUsed.put(Hints.CRS, crs );
> hintsWeUsed.put(Hints.POSITION_FACTORY, positionFactory );
> }
> public Map getImplementationHints() {
> return Collections.unmodifiableMap( hintsWeUsed ); // so
> FactoryRegistry does not create duplicates
> }
The ThreadLocal Hints can be picked up when FactoryRegistry is called
with *null* hints. When called for the first time we can use the Global
Hints for the initial value. I may be able to synchronize the factory
finder and keep the solution there
Cheers,
Jody
Graham Davis wrote:
> I'm trying to create a factory finder for the unsupported geometry
> module with referencing->GeometryFactoryFinder.java that uses the
> factory service registry stuff in metadata.
>
> I can't seem to get it to use the Hints I've setup for finding and
> creating a factory. It only seems to find the factory if it has a
> constructor with no parameters, but that is useless because the factory
> needs a CRS and other things. Does anyone have any idea of how the
> Hints are suppose to be used or setup? I've tried creating a
> constructor that uses Hints to build the factory, but that isn't found.
> Only the blank constructor is. Does anyone know how Hints are meant to
> be used properly?
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel