couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darran White <darran.m.wh...@googlemail.com>
Subject Java Document Object Mapper api
Date Tue, 13 Apr 2010 07:18:38 GMT
Hi,
I`ve started writing an annotation based couchdb Document Object Mapper
called jBeanbag http://code.google.com/p/jbeanbag/.
The approach I`ve taken is to use 100% annotations so the users domain model
does not have to derive from the api. I`m also trying to make it CouchDB
focused rather
then JSON focused which a few of the other apis seem to be. The aim is to
enable easy mapping to and from CouchDB documents to Java classes and also
provide some infrastructure support
for example @Linked annotation could be above a field meaning the field
should be a linked document and handling conflicts by returning Java objects
of the different versions in an exception.
I`d also like to put in more annotations for other kinds of relationships
like bi-directional.
An example Java annotated class is at the bottom of this mail.

I`m using the ASM library http://asm.ow2.org/

to create a Meta model of the Java classes ,including all the CouchDB
configuration for that class, is then cached in ehcache and can be reused
for serializing to/from the JSON. The JSON parsing I`m using the the Jackson
JSON Streaming/Mapping apis.
ASM helps by making it easy to analyze the class structure in advance ,using
its visitor pattern, as well as giving access to Generics information.

So I`m looking to the community for any CouchDB patterns they keep repeating
in code which could be included in the framework as well as anyone else who
could be interested in contributing to the code base.

Going forward I`d also like to provide wrappers for Groovy to make it a bit
more ,well Groovier and Scala wrappers.

At the moment theres not a released version but I`m hoping to have a 0.01
version soon. But I have done most of the simple conversion to/from JSON for
primitives,arrays,maps,lists,
sets,Objects, Wrapper Objects e.g Integer class,enums and Dates. Currently
it`ll struggle with things like Arrays of Maps or Lists of Lists but that
should be fixed soon. I`m currently working on the HTTP client side of
things.

Thoughts,comments and especially help all appreciated.

regards

Darran

@Document(location="people")
public class Person{
 @Id
 private String id;

 @Revision
 private String revision

//Will be a list of embedded pet objects in the person document
//not really needed as embedded is the default
 @Embedded
 @NotNullable
 private List<Pet> pets;

//List will be parsed and written as linked documents to this class
 @Linked
 private List<Car> cars;

 private String name;//Will be written as name:<value> in document

 @Ignore
 private String dontWriteToDocument; //Won`t be written to the document

......

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message