Hi Martin:

The problem I found was with the FactoryCreator.getServiceProvider 
method - it starts out ...
> public Object getServiceProvider(final Class     category,
>                                      final Filter    filter,
>                                      final Hints     hints,
>                                      final Hints.Key key)
>             throws FactoryRegistryException
>     {
>         final FactoryNotFoundException notFound;
>         try {
>             return super.getServiceProvider(category, filter, hints, key);
>         } catch (FactoryNotFoundException exception) {
>             // Will be rethrown later in case of failure to create the 
> factory.
>             notFound = exception;
>         }
My problem is with line 113 (ie return super.getServiceProvider( ... ); )

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

To "fix" this problem I was experimenting with something like this:
>         final FactoryNotFoundException notFound;
>         Factory found;
>         try {
>             found = (Factory) super.getServiceProvider(category, 
> filter, hints, key);
>         } catch (FactoryNotFoundException exception) {
>             // Will be rethrown later in case of failure to create the 
> factory.
>             notFound = exception;
>         }
..
> if( found != null ){
>             return found;
>         }
>         else if( notFound != null ){
>             throw notFound;
>         }
>         else {
>             throw new FactoryNotFoundException("Could not locate 
> instance of "+category)
>         }
Using this kind of code I was able to get both:
- the no argument constructor to be called (required so an 
implementation would be found)
- the hints constructor to be called

Debugging this is where I left off Friday,
Jody

> Jody Garnett a écrit :
>> 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).
> * You must use the FactoryCreator subclass, not FactoryRegistry.


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