Let's start with a demo of how easy it is to create a new application and deploy it.
For this we are using Sculptor maven archetype for App Engine. Try it yourself:
mvn archetype:generate -DarchetypeGroupId=org.fornax.cartridges -DarchetypeArtifactId=fornax-cartridges-sculptor-archetype-appengine -DarchetypeVersion=1.7.0-SNAPSHOT -DarchetypeRepository=http://www.fornax-platform.org/archiva/repository/snapshots/
cdto the new directory
- Import the project in Eclipse
The archetype creates a sample of of a RESTful Spring 3.0 Controller and JSP pages for the CRUD operations.
The archetype also creates a simple sample model, from which Sculptor generates Entity, Repository and Service with the default CRUD operations; findById, findAll, save, and delete.
The model is defined in a textual DSL, with an intuitive syntax, from which Sculptor generates high quality Java code and configuration. It is not a one time shot. The application can be developed incrementally with an efficient round trip loop. The generator is part of the build process (maven).
Sculptor generates JPA mapping annotations for the domain objects defined in the design model. Relations are very limited in App Engine, since the datastore (BigTable) is not a relational database.
Owned and embedded associations are supported and mapped as ordinary JPA associations. They are specified with
BasicTypein the Sculptor model.
Unowned associations are handled with
idreferences and you must lookup the objects with
Services and Repositories are implemented as Spring components with @Autowired dependency injection. Spring AOP is used for error handling and transaction management.
Behavior is implemented with hand written code in subclass, separated from re-generated code in base class. In the above example the
sayHellomethod is typically implemented in the Service by first using the generated
findByKeymethod in the Repository. Note that the
nameattribute of the
Planetis marked as key.
Sculptor also provides support for JUnit testing with the local App Engine environment. I will cover that in another article some day soon.