I've implemented Martin's suggestions (in positionfactory, since that is 
the most basic factory and I'm trying to test with that now to make sure 
the factory finder stuff works as it should).  It still can't find my 
factory.

I've commited my recent changes, you can see them in:

- org.geotools.geometry.iso.PositionFactoryImpl
- I'm running a test here:  
org.geotools.geometry.iso.primitive.PrimitiveGeometryBuilderTest.java 
(rename the text case to remove the "x" so it runs.. I added the x so it 
wouldn't run and cause build errors for others when I committed it).

Is there still something I'm missing Martin?  I can't seem to figure out 
why it won't find my factory.

Graham.


Jody Garnett wrote:

> Martin Desruisseaux wrote:
>
>> Jody Garnett a écrit :
>>
>>> In every case we were either directly returning the object provided 
>>> by the no argument constructor, or we were producing a 
>>> FactoryNotFoundException - at which point the later code would not 
>>> work either (as it needs the no argument constructor to work so it 
>>> gets an object back in order to get a Class to perform reflection on).
>>
>> This is true - a no-argument constructor must exists and the factory 
>> must be registered in the META-INF/services/ directory in order to 
>> work. The no-argument constructor should provides default hints for 
>> the most common (or most "strict") cases.
>>
>> It will not prevent the GeometryFactory(Hints) constructor to be 
>> invoked later, because FactoryRegistry should detect that the 
>> GeometryFactory created with the no-arg constructor don't have 
>> 'Factory.getImplementationHints()' matching user's request.
>
> So that is what is supposed to throw the FactoryNotFoundException 
> exception? I hate seeing exceptions used for flow of control? 
> Seriously is that what is expected to happen? Or am I reading the code 
> wrong?
>
>> > and we have begun adding the Hints constructors to 
>> PrimitiveFactoryImpl in the unsupported gometry module.
>>
>> I see a problem in PrimitiveFactoryImpl. The no-argument constructor 
>> do not put anything in the hintsWeUsed map. Consequently, 
>> ReferencingFactory believes that PrimitiveFactoryImpl do not care 
>> about any hints, so the PrimitiveFactoryImpl instance is always 
>> suitable no matter what are user hints.
>>
>> Suggested fix:
>>
>> * Rename "hintsWeUsed" by "hintsWeCareAbout" or something like that;
>>   this is not the same thing.
>
> I see, so we need to indicate what assumptions were made by default; 
> so the FactoryRegistry can detect that we ignored the user provided 
> hints?
>
>> The important point is that the PrimitiveFactoryImpl() constructor 
>> must put, directly or indirectly, some Hints.CRS and Hints.WHATEVER 
>> keys in the "hintsWeCareAbout" map, no matter if the value are null 
>> or anything else.
>
> So I am still missing the step where this inconsistency is discovered? 
> Can you confirm that we *must* expect a FactoryNotFoundException to be 
> thrown at the start of FactoryCreator.getServiceProvider (where it 
> calls super?).
>
> Jody



-- 
Graham Davis
Refractions Research Inc.
[EMAIL PROTECTED]


-------------------------------------------------------------------------
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

Reply via email to