XML data service

From: Cris Daniluk (cris.danilu..mail.com)
Date: Wed Dec 14 2005 - 19:59:05 EST

  • Next message: Cris Daniluk: "XMLEncoder behavior"

    I've prepared a simple implementation of a generic data service for
    Cayenne, based on the one I wrote for a proprietary application (see
    http://www.objectstyle.org/cayenne/lists/cayenne-devel/2005/11/0038.html).
    Before I put it on the Wiki, I wanted to get some comment on it here.

    Basically what I've done is created a GenericDataService which is a
    simple facade to the Cayenne query API. It takes a class or stored
    query name, expression, ordering, etc and returns the XML-encoded
    result. It also supports mapping files. I then created
    AbstractDataService implementations in Struts, WebWork, and as a plain
    servlet. To use it, you just implement whichever one matches your
    framework and extend getObjectMap(), mapping literals to your
    DataObjects. Then, a query like this:

    http://.../dataService?objectType=painting

    or...

    http://.../dataService.do?objectType=painting

    or...

    http://.../dataService.action?objectType=painting

    would return an XML data set of all artists, in no particular order.
    You could add sorting:

    http://.../dataService.action?objectType=painting&ordering=+paintingTitle

    or a filter:

    http://.../dataService.action?objectType=painting&expression=toArtist.artistName="Altdorfer,
    Albrecht"

    Everything has been tested at a high level, but not exhaustively. An
    example implementation for each abstract service is provided. I didn't
    include the libs since there's nearly 10mb, but basically there are no
    dependencies but Cayenne - and Struts or Webwork if you use that.

    I think it works and is fairly secure (at least, as secure as the
    developer is). I also included a simple app that uses jsXml and Dojo
    to browse paintings and lookup artists, all on a single "static" html
    page. I thought a simple example might be helpful to connect the dots.

    Cris





    This archive was generated by hypermail 2.0.0 : Wed Dec 14 2005 - 19:59:07 EST