Bodega SourceForge Project

BODEGA Distributed Objects


I. Overview


Bodega is a distributed objects database framework for AJAX, RIA, REST, SOA, and Web Services. A Bodega entity defines an object graph of nested entities. Bodega command objects are executable entities that take entity arguments and return entity results.


The Bodega framework provides an API for command objects and includes built-in transactional CRUD (create, read, update, delete) commands for persistent entities. The Bodega servlet front end marshals command entities that are sent on the wire in XML or JSON formats. Bodega commands are easy for the client to create and invoke. Server implementations are easy to write with a simple Java API that abstracts knowledge of the underlying ORM and application server environment.


Bodega makes no assumptions about front end client frameworks that use it.  Bodega provides a command server and persistence layer for AJAX, GWT, Tapestry, Dojo, and JSF, and Web Services while avoiding the configuration complexities of IoC frameworks and the impedance mismatch of embedded logic in template markup languages.



II. Architecture


Bodega Entities


A Bodega entity defines an object graph of nested entities. A Bodega entity contains only data members, references to other Entities, and collections of Entities. Bodega entities are abstract data objects that can be implemented as JavaScript client objects and Java server objects. Bodega entities are instantiated in JSON, XML, and database formats, as well as any other object representation that satisfies the definition of a Bodega entity. The data types of Entity members can be any type allowed by the environment that contains the entity. Persistent entities are SQL tuples. Java entities are Java object graphs. JSON entities are JSONObjects. XML entities are XML elements. The Bodega framework marshals transformations among these representations. For example, a person entity with nested children entities would look like this in JSON notation:


     { lastName:Smith, firstName:Mary, children:[ {…}, {…}] }


Bodega persistent entities are independent of any particular ORM or persistent object implementation. The current implementation is based on Hibernate and JDBC, but could as easily be based on JDO or TopLink. The particular ORM or persistent object implementation is transparent to Bodega clients and to the Bodega Java API.


Bodega Commands


Bodega commands are executable entities that return entity results. A Bodega client can send and consume deep entity graphs in a RESTful application. Or, a distributed object SOA application can execute fine grained command entities hosted in an application server.  The implementation of a command may use the Bodega API persistence facilities.


Bodega command entities are objects, in contrast to the procedural semantics of RPC calls or SOA services. However Bodega command entities are reductively simple distributed objects that perform a single operation, compared to multiple operations implemented by remote objects in RMI or distributed CORBA objects.


Here is the representation of a command entity (shown in JSON format):


     { commandName : { commandArgs… }}


The arguments are an inner entity member of the enclosing command entity. For example, the JSON format for the built-in GetEntity persistence command is an entity with a command name and a nested entity argument as follows:


     { GetEntity : { Entity:type, Id:nn }}


This command will retrieve an object graph with a root entity that has the given Id. The associated persistent entities linked to the root entity and the reachable object graph is also retrieved. For example:


     { GetEntity : { Entity:ShoppingCart, Id:98765 }}


Cyclic references in an entity returned by a command are terminated with descriptor entities. The depth of the returned object graph can be limited with a MetaCmd member included in the command. Another type of MetaCmd is an XPath expression to filter entities from the entity graph returned by the command.


A command entity implements the org.bodega.Commandable interface as follows:


    public interface Commandable


        public Entity execute(Entity parameters);


        // … more



The Bodega servlet base class invokes a Bodega CommandProcessor to create or find an instance of a command. A request invokes a command or multiple commands in the context of a transaction.  The servlet entry point is one way of invoking Bodega commands, but is not required.  The Bodega persistence layer is a 3-tier architecture that ties clients to the persistence engine. But Bodega commands can also implement the session façade pattern to participate in N-tier architectures.



III. Roadmap


The Hibernate layer is a problematic fit due to the complexity of Hibernate OR mapping features, very little of which are relevant to Bodega. The development roadmap is to replace the Hibernate layer with JPA (Java Persistence API).


Bodega SourceForge Project Logo