Sculptor is an Open Source tool that applies the concepts from Domain-Driven Design and Domain Specific Languages. You express your design intent in a textual specification, from which Sculptor generates high quality Java code and configuration. Sculptor takes care of the technical details, the tedious repetitive work, and let you focus on delivering more business value – and have more fun. The DSL and the code generation drives the development and is not a one time shot. It is an iterative process, which can be combined with Test Driven Development and evolutionary design. Sculptor is useful when developing typical enterprise or web applications that benefit from a rich and persistent domain model. The target implementation is based on well known frameworks, such as Hibernate and Spring. There is often a need for a user interface with classical CRUD functionality. Sculptor helps you with that, by generating a CRUD GUI with sophisticated management of associations. The functionality of the front end is customized with another textual DSL with linking to the business tier model. The target implementation of the CRUD GUI comes in two flavors:
  • web application based on Spring Webflow and JSF
  • rich client based on Eclipse Rich Client Platform and Spring
Let me illustrate Sculptor in practice using the DDD Sample, and the cargo domain described in Eric Evans' book. We need a service to book a cargo from one location to another. This is expressed in Sculptor DSL: Service BookingService { @TrackingId bookNewCargo(@UnLocode origin, @UnLocode destination); } BasicType TrackingId { String identifier key; } BasicType UnLocode { String unlocode key } Sculptor takes this model as input and generates an EJB service and a separate implementation, in which you manually add the the logic for the service. Spring dependency injection and AOP for things like error handling is also generated. When thinking about the implementation we identify the need for a few more things, a persistent Location object and a way to find it. Service BookingService { inject @CargoRepository @TrackingId bookNewCargo(@UnLocode origin, @UnLocode destination) throws LocationNotFoundException; protected findLocation => LocationRepository.find; } Entity Location { not optimisticLocking scaffold - @UnLocode unLocode key String name not changeable Repository LocationRepository { @Location find(@UnLocode unLocode) throws LocationNotFoundException; protected findByKeys; } } The result of the booking should be a saved Cargo Entity. Entity Cargo { - @TrackingId trackingId key - @Location origin required - @Location destination required Repository CargoRepository { save; TrackingId nextTrackingId; } } We generate again and a few seconds later we have two persistent objects with Hibernate mapping and Repositories. We complete the booking service by adding the hand written java code: public TrackingId bookNewCargo(ServiceContext ctx, UnLocode originCode, UnLocode destinationCode) throws LocationNotFoundException { TrackingId trackingId = getCargoRepository().nextTrackingId(); Location origin = findLocation(ctx, originCode); Location destination = findLocation(ctx, destinationCode); Cargo cargo = new Cargo(trackingId, origin, destination); getCargoRepository().save(cargo); return cargo.getTrackingId(); } We need a CRUD GUI for administration of the locations also. Therefore we add the scaffold keyword to the Location Entity to get the ordinary CRUD operations. In this simple case we don't need to customize it by specifying things in the GUI DSL. - Done! You will find a lot more samples and explanations in the Sculptor wiki.