[taking to dev] On Jul 11, 2013, at 10:21 PM, John Huss (JIRA) <[email protected]> wrote:
> Support in ConverterFactory is for integration with Jersey where I am using > PropertyUtils.setProperty to convert from strings like "2013-05-01 > 00:00:00.000" to DateTimes, etc. I'm currently doing this beforehand and it > works fine, but moving it into ConverterFactory will help reduce duplication. > I swear I've got at least 4 instances of this conversion in various parts of > apps. It's not really something that has to be in Cayenne itself though; I'm > just looking to create options. Interesting, I just wrote an entire JAX-RS engine on top of Cayenne (closed source). With Joda date encoders coincidentally. The architecture is really simple. Request URL defines the root entity and related entities (actually it is more fine grained - it can define the result up to individual attributes if needed). This information is matched with Cayenne mapping, and at the select stage is used to build SelectQuery prefetches, and later when generating response - to build a hierarchical encoder tree. Root encoder and result list are placed in the response object, and it then handed to a special MessageBodyWriter that generates JSON. Encoders are external to Cayenne and are not using PropertyUtils. I have encoders for DataObjects (that access properties via 'readProperty'). And for "simple" properties, I have my own encoder map, that includes singleton Encoders for Joda classes. I wish we had a similar framework as open source. LOE creating it (once we nailed the URL protocol details) was not that big, just a couple of weeks. I guess the most tricky part is to provide a flexible user-facing (REST) protocol. My example was designed with Sencha/ExtJS in mind. Someone else may probably want a different flavor. Although the basic operations are going to be the same no matter what the client is. Anyways, just wanted to mention this… Maybe someone will like the idea, so that we can somehow start collaborating on it. Andrus
