|
From: Matt S. <mat...@ve...> - 2004-11-22 04:42:55
|
Hello, I'm developing a reflection and conversion library that is more = powerful and flexible than PropertyEditors and Commons BeanUtils. I = wanted to post a message letting Spring developers know because Rod = Johnson mentioned in his first book that there really wasn't a good = reflection library out there. Here's a (temporary) link until the SourceForge project is started: http://www.crystalcognition.com/sgarlatm/morph/ Here's some more information on the approach I've taken - In place of a registry that tries to 'pick' the right converter (e.g. = - PropertyEditorManager, ConvertUtils.register), I have the Converters = themselves say which objects they can and cannot convert. The user = assembles these converters (programmatically, or via an IoC framework) = in whatever order they like into a mega-converter, if you will, that = will function more similarly to the ConvertUtils.convert method in = BeanUtils. This 'mega-converter' conforms to the simple Converter = interface like every other, 'non-mega' converter. - In place of BeanUtils.copyProperties there is a Copier interface. It = is very similar to the Converter interface, but it's original intent was = different: to copy data from one location to another, where creating a = new object doesn't make sense. For example, let's say we want to store = information from a Map or an object graph as separate attributes in an = HTTP request. We can't just create a new HTTP request object... it = already exists! So we use a Copier. Basically, Converters are for the = simple stuff like primitives, Dates, etc and Copiers are for fancier = things like Object[] -> List. You can always take something that is = written with the Copier interface and expose it as a Converter but not = vice-versa (The net.sf.morph.converters.CopierConverter class exposes a = Copier as a Converter). - While working on Copiers, I realized I needed to be able to pull = information out of various different types of things: objects and maps = are simple examples, but I might also want to be able to pull info from = HTTP request parameters, etc. This is what Reflectors are for. They = help Copiers get the job done. A lot of these ideas are still being fleshed out. I would love to hear = any comments you may have. Thanks, Matt |