I'd like to see some refactoring to support generating HiveDoc from
the parsed Descriptor objects (however that would work!).  Once that
is in place, I'd personally be much more open to various scripting
approaches to building the  Registry.


On Mon, 11 Oct 2004 12:58:03 +0200, Knut Wannheden
<[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I know there are people out there who would prefer writing HiveMind
> module descriptors using a scripting language instead of XML files.
> I've spent a few hours now on trying to get a Groovy script
> (http://groovy.codehaus.org/) to define a HiveMind module.
> 
> As a test I wrote this Groovy script which yields an equivalent to the
> HiveMind calculator example module:
> 
> import org.apache.hivemind.examples.*;
> import org.apache.hivemind.examples.impl.*;
> 
> class ExamplesModule {
> 
>         createModule(builder) {
>                 services = [
>                         'Adder':[Adder.class, AdderImpl.class],
>                         'Subtracter':[Subtracter.class, SubtracterImpl.class],
>                         'Multiplier':[Multiplier.class, MultiplerImpl.class],
>                         'Divider':[Divider.class, DividerImpl.class]
>                 ]
> 
>                 builder.module(id:'examples', version:'1.0.0') {
>                         services.keySet().each { id |
>                                 builder.servicePoint(id:id, 
> interface:services.get(id)[0].name) {
>                                         
> createInstance(class:services.get(id)[1].name)
>                                         
> interceptor(serviceId:'hivemind.LoggingInterceptor')
>                                 }
>                         }
>                         servicePoint(id:'Calculator', 
> interface:Calculator.class.name) {
>                                 invokeFactory {
>                                         
> construct(class:CalculatorImpl.class.name)
>                                 }
>                                 
> interceptor(serviceId:'hivemind.LoggingInterceptor')
>                         }
>                 }
>         }
> }
> 
> IMHO this script is still fairly readable. Whether the code block
> defining the Adder, Subtracter, Multiplier, and Divider services
> really contributes to the readability is probably a matter of taste.
> 
> There are still a few ugly hacks in the implementation (as getting the
> line numbers by throwing and catching an exception), but it does work.
> 
> What do you all think about this? Is this something we could add to
> the HiveMind lib?
> 
> --knut
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to