Martin Desruisseaux wrote: > 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). > This is not true, it work if used as expected. Please lets try to fix > your use case. I agree - I found the code and was starting to debug it yesterday. What I found was that in FactoryCreator it was calling super (ie FactoryRegistry) and getting the default "no argument" constructor returned in all cases. The code that was calling this was set up to expect an exception - and only then would it hunt around for the correct constructor.
In my understanding there are three steps: 1- it needs the no argument constructor so that the FactorySPI system can return an Object (if the user explicitly specified an exact implementation it would be found and returned directly 2- It would then ask the object for its class 3- And then finally perform reflection on that class in order to look for a constructor that creates hints Step 1 seems broken; when I commented out step 1 I was able to confirm that step 2 and 3 work as expected. In short we are just looking at a bug; frankly this is very exciting since I was having the same kinds of trouble with the referening module (but since it is so complicated I was having a hard time isolating the problem and communicating with anyone about it). > * You must use the FactoryCreator subclass, not FactoryRegistry. check > * You *MUST* write a factory class with a constructor as below: Check, it took us a while to figure out that the no argument constructor was needed. The code that calls this constructor is a Sun class and cannot be "fixed" to look for Hints (ie doing this in a single step). We implemented the GeoTools Factory interface - it has the getImplementationHints method and was suited for our purpose. Do you really want us to extend the AbstractFactory? > Again, the hint you care about *MUST* be passed to the > AbstractFactory.hints map, otherwise it will not work. Put only the > hints you care about (do not use hints.putAll(userHints)). Understood; the hints we use (and only the hints we use) are available via the getImplementationHints() method on the 'Factory' interface. Jody ------------------------------------------------------------------------- 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
