methodMissing from Java with SimpleTemplateEngine

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

methodMissing from Java with SimpleTemplateEngine

Slide
I am using SimpleTemplateEngine to provide templating support in my Java application. I would like to be able to handle methodMissing within my Java class to dynamically look up functions that are provided by a plugin based token system. I am having trouble figuring out how I can handle methodMissing with the following code:

Map<String, Object> binding = new HashMap<String, Object>();
binding.put("someVar", someVar);

GroovyShell shell = createShell();
SimpleTemplateEngine st = new SimpleTemplateEngine(shell);

Writable w = t.createTemplate(inputStreamReader).make(binding);
StringWriter content = new StringWriter();
w.writeTo(content);

How can I setup methodMissing in this case? I've tried adding a subclass of Closure to the binding, but that doesn't seem to work.

Any help would be greatly appreciated!

Thanks,

Alex

--
Website: http://earl-of-code.com