|
|||||
|
|||||
Expression Language Framework
Expression Languages in MarmaladeIntroductionMarmalade is not simply another scripting language to learn. If you know XML namespaces, and either the JSP expression language or OGNL expression language, you can use Marmalade. If you don't know either of these expression languages, you can implement your own flavor and use that. If you don't need dynamic expression evaluation, you don't have to include or use any expression language library - the default for marmalade-core is a dummy EL, which simply passes all data through unchanged. It's your choice. Choose Your ELThis is one way of choosing your expression language: <?xml version="1.0"?> <?marmalade-control:el ognl?> <someTag/> So is this: <?xml version="1.0"?> <someTag marmalade-control:el="ognl"/> Or this: MarmaladeTaglibResolver resolver = new MarmaladeTaglibResolver(MarmaladeTaglibResolver.DEFAULT_STRATEGY_CHAIN); ExpressionEvaluator el = new OgnlExpressionEvaluator(); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File scriptFile = new File("myscript.mmld"); RecordingReader reader = new RecordingReader(new FileReader(scriptFile)); DefaultParsingContext ctx = new DefaultParsingContext(); ctx.setTaglibResolver(resolver); ctx.setInputLocation(scriptFile.getAbsolutePath()); ctx.setInput(reader); ctx.setDefaultExpressionEvaluator(el); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ScriptBuilder prototype = new ScriptParser().parse(ctx); MarmaladeScript script = prototype.build(); DefaultContext ctx = new DefaultContext(); script.execute(ctx); I hope this begins to show the flexibility of Marmalade. Roll Your Own ELBuilding your own EL flavor is simple, once you get the expression language engine figured out. As you've no doubt noticed, I took the easy way out on the first two EL implementations. Commons-EL drives the JSP-like expression language, and OGNL drives the OGNL syntax (big surprise). Once you have an expression language engine like this, it's a simple two-step process:
|
|||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||