[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-user
Subject:    Re: [groovy-user] Should i use dynamic proxies or metclasses for an embedded application ?
From:       "Guillaume Laforge" <glaforge () gmail ! com>
Date:       2007-01-30 10:08:16
Message-ID: 197b18fc0701300208n19546e9cg682696b3d58077c () mail ! gmail ! com
[Download RAW message or body]

When you use GroovyShell or GroovyClassLoader, you can pass a
CompilerConfiguration instance to their constructors.
On the CompilerConfiguration, you can specify the base script class
used (which has to extend the Groovy script class).
You can put those common / global methods there.

Another trick is to pass closures in the binding of the script.
If you pass a closure called c, you'll be able to call c() inside the script.


On 1/29/07, Colin Canfield <colin.canfield@gmail.com> wrote:
> Morning all,
>   I have an application where I have an embedded groovy scripting engine.
> The users for the scripts will typically not be overly computer savy so I'm
> trying to keep the syntax simple. The script has to a have a set of
> properties that describe how it interacts with the overall application (if
> more than one instance can be run in parallel, events that should trigger
> the script etc.).
>
>    I know I can make this work by using a script with is a Class implenting
> a certain interface, this works, but the syntax is more complex than I'd
> like. I'd much rather use the implicit class created by the script loader,
> iterate through the methods and see if the properties have been specified or
> if I should use default values.
>
>    I'm fairly certain (I think) I could do this with a dynamic proxy, but
> I'm wondering if the groovy meta class information also has the information
> I need to see if parameters have been specified or not ?
>
> Thanks, Colin
>
>
>
>
>


-- 
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic