FactoryBuilderSupport Help

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

FactoryBuilderSupport Help

Nikolai Dück
I'm really interested using Groovy for DSLs. I've read some articles and books (DSLs by Martin Fowler, Groovy for DSLs by Fergal Dearle, Design Guidelines for DSLs and some others).
Currently, I am trying to create a DSL and just want to generate code. Here's an example of a model written in the DSL:

Entity(Customer) {
    attribute firstName, type: Text
    attribute lastName, type: Text
    has Address

Entity(Address) {
    attribute city, type: Text

I'd like to make it more convenient and omit the attribute keyword.
Using BuilderSupport in groovy it was an easy task, just checking if the parent is an Entity and interpret every unknown child as an attribute.
A quick look at FactoryBuilderSupport I've found only examples using keywords, e.g. SwingBuilder.
Is there a way to register factories for children of a specific keyword or do you know a better approach?
For further workings on my DSL, I've got some other questions:
- is there an easy way to make libraries extending the DSL?
- How can I make use of the grouping feature in FactoryBuilderSupport? What is it for exactly for?  ->  public void registerFactory(String name, String groupName, Factory factory)
- Do you know guides which can help me get a deeper understanding of the FactoryBuilderSupport class, since it may have more useful features I could make use of? 
- By using Groovy for DSLs, you write internal DSLs. To reach the syntax you'd like to, sometimes you've got to use groovy in a tricky way. Do you know collections of some tricks?

For all those, who never heard about (Factory)BuilderSupport, here are some examples how to use BuilderSupport and FactoryBuilderSupport: http://javabeat.net/groovy-for-domain-specific-languages/

Thanks in advance