From: Matt B. <gud...@ya...> - 2007-01-11 20:27:35
|
IMO a basic implementation: look first for a single-arg constructor whose argument matches "parameter". Failing that, if "parameter" is an array, look for a multi-arg constructor whose arguments all match the elements of "parameter". After these approaches fail, I wouldn't do any more by default, but simply fall back to newInstance(). I've written code that does this stuff before, actually. The only thing about all this is it sounds pretty much like a Converter implementation; the line between Reflectors and Converters becomes blurry. :| -Matt --- Matt Sgarlata <Mat...@wh...> wrote: > That's certainly a possibility, but what algorithm > would be used to try > to guess which parameters go where? Would guesses > be based on the type > of the "parameters" object, or would be reflection > be used to try to > "extract" the parameters, etc. This could > potentially be very complex > and still not meet a user's requirements. How often > do we encounter > objects which do not have a no-arg constructor, > especially with Spring > having been around for so long? I know I myself > would probably never > use this feature. > > That said, if you want to spend some time working on > a solution, it's > your free time not mine :) > > Matt > > Matt Benson wrote: > > Thinking more on this, it seems more correct that > a > > basic implementation of newInstance(Object > parameters) > > would look for constructors matching the > parameters, > > and failing to find any would fall back to the > > no-parameter version. This would probably be MORE > > compatible with any existing > InstantiatingReflector > > implementation as well. > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get > the chance to share your > opinions on IT & business topics through brief > surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > morph-developer mailing list > mor...@li... > https://lists.sourceforge.net/lists/listinfo/morph-developer > ____________________________________________________________________________________ Cheap talk? Check out Yahoo! Messenger's low PC-to-Phone call rates. http://voice.yahoo.com |