Skip to main content
This revision made August 03, 2011 23:11, by Kin-man Chung

API for Stand Alone EL

Introduction

This is the API for using EL stand-alone, outside of a web container. It provides a direct and simple interfaces to creating and evaluating EL expressions, while hiding low level details from the users. This API builds on the EL 2.2 API, and is therefore not independent from it.

ELProcessor is the main engine that EL users would be using most of the time. ELManager can be used to manage the environment/context for EL processing. StandardELContext provides the default implementation of an ELContext used here.

One design philosophy used here is to hide most of the implementation details from the users of this API. Things like ELContext, ELResolver, or even ValueExpression are not used.

The following example shows how the api can be used.

  // Get an instance of ELProcessor.  Container can inject one too.
  ELProcess el = ExpressionFactory.newInstance().newELProcessor();
  ELManager mgr = el.getELManager();
  mgr.addBeanNameResolver(new BeanNameResolver() {
    public Object getBean(String name) {
      if (name.equals("foo")
        return new Foo();
    }
  });
  // Evaluate an EL expression
  System.out.println("Name for foo is ",  el.getValue("#{foo.name}"));
  // Defines a el function  "sum" (org.acme.Foo.sum is a static method)
  el.defineFunction("x", "sum", org.acme.Foo", "sum");
  System.out.println("1 + 2 = ", el.getValue("#{x:sum(1,2)}"));
  // Defines a el variable
  el.setVariable("v", "#{foo.name}");
  System.out.println("name for foo is ", "#{v}");  // Same as the first example

ELProcessor.java

see

ELManager.java

see

BeanNameResolver.java

see

BeanNameELResolver.java

see

StandardELResolver.java

see

FunctionMapper.java

see

Difference compared to previous revision
<span>== API for Stand Alone EL== === Introduction === This is the API for using EL stand-alone, outside of a web container. It provides a direct and simple interfaces to creating and evaluating EL expressions, while hiding low level details from the users. This API builds on the EL 2.2 API, and is therefore not independent from it. ELProcessor is the main engine that EL users would be using most of the time. ELManager can be used to manage the environment/context for EL processing.<span style="text-decoration:underline;color:green"> StandardELContext provides the default implementation of an ELContext used here.</span>== API for Stand Alone EL== === Introduction === This is the API for using EL stand-alone, outside of a web container. It provides a direct and simple interfaces to creating and evaluating EL expressions, while hiding low level details from the users. This API builds on the EL 2.2 API, and is therefore not independent from it. ... ELProcessor is the main engine that EL users would be using most of the time. ELManager can be used to manage the environment/context for EL processing. One design philosophy used here is to hide most of the implementation details from the users of this API. Things like ELContext, ELResolver, or even ValueExpression are not used. <span style="text-decoration:line-through;color:red"> '''To be revisited'''</span> <span style="text-decoration:line-through;color:red">An instance of ELProcessor can be obtained from the ExpressionFactory. In it there is a default ELManager, which contains a default ELContext, which in term contains a default ELResolver, FunctionMapper, and VariableMapper. </span>The<span style="text-decoration:line-through;color:red">y</span> <span style="text-decoration:line-through;color:red">are mostly empty, except </span>fo<span style="text-decoration:line-through;color:red">r the defau</span>l<span style="text-decoration:line-through;color:red">t ELReso</span><span style="text-decoration:line-through;color:red">ver, which c</span>o<span style="text-decoration:line-through;color:red">ntain enough ELResolvers to handle beans properties, arrays etc. '''details to be defined.''' The follo</span> One design philosophy used here is to hide most of the implementation details from the users of this API. Things like ELContext, ELResolver, or even ValueExpression are not used. ... ELManager mgr = el.getELManager(); mgr.addBeanNameResolver(new BeanNameResolver() { public Object getBean(String name) { <span style="text-decoration:underline;color:green">if (name.equals("foo") </span>wing example shows how the api can be used. // Get an instance of ELProcessor. Container can inject one too. ELProcess el = ExpressionFactory.newInstance().newELProcessor(); ... ELManager mgr = el.getELManager(); mgr.addBeanNameResolver(new BeanNameResolver() { public Object getBean(String name) { return <span style="text-decoration:line-through;color:red">myBea</span>n<span style="text-decoration:line-through;color:red">s.g</span>e<span style="text-decoration:line-through;color:red">t</span>return ne<span style="text-decoration:underline;color:green">w Foo</span>(<span style="text-decoration:line-through;color:red">name</span>); } }); // Evaluate an EL expression <span style="text-decoration:line-through;color:red">Obj</span>(); } }); // Evaluate an EL expression <span style="text-decoration:underline;color:green">Syst</span>e<span style="text-decoration:line-through;color:red">c</span><span style="text-decoration:underline;color:green">m.ou</span>t<span style="text-decoration:line-through;color:red"> b</span><span style="text-decoration:underline;color:green">.println("N</span>a<span style="text-decoration:underline;color:green">me fo</span>ar <span style="text-decoration:line-through;color:red">=</span>r <span style="text-decoration:underline;color:green">foo</span> <span style="text-decoration:underline;color:green">is ", </span> el.getValue("#{foo.<span style="text-decoration:line-through;color:red">b</span>el.getValue("#{foo.<span style="text-decoration:underline;color:green">n</span>a<span style="text-decoration:line-through;color:red">r</span><span style="text-decoration:underline;color:green">me</span>}")<span style="text-decoration:underline;color:green">)</span>}"); <span style="text-decoration:line-through;color:red">===ELProcessor.java=== /* </span> <span style="text-decoration:line-through;color:red">*</span>; <span style="text-decoration:underline;color:green">// </span> Defines a<span style="text-decoration:line-through;color:red">n</span> <span style="text-decoration:line-through;color:red">API</span>Defines a <span style="text-decoration:underline;color:green">el</span> f<span style="text-decoration:underline;color:green">uncti</span> fo<span style="text-decoration:line-through;color:red">r</span>o<span style="text-decoration:underline;color:green">n</span> <span style="text-decoration:line-through;color:red">EL</span><span style="text-decoration:line-through;color:red">expre</span> <span style="text-decoration:underline;color:green">"</span>s<span style="text-decoration:line-through;color:red">sion</span><span style="text-decoration:underline;color:green">um"</span> <span style="text-decoration:line-through;color:red">pr</span><span style="text-decoration:underline;color:green">(</span>o<span style="text-decoration:line-through;color:red">cessin</span><span style="text-decoration:underline;color:green">r</span>g.<span style="text-decoration:line-through;color:red"> */ interf</span>g.ac<span style="text-decoration:underline;color:green">m</span>ace<span style="text-decoration:line-through;color:red"> ELPr</span>e<span style="text-decoration:underline;color:green">.F</span>o<span style="text-decoration:line-through;color:red">cess</span><span style="text-decoration:line-through;color:red">r { /* * Ret</span>oo<span style="text-decoration:underline;color:green">.s</span>u<span style="text-decoration:line-through;color:red">rn</span><span style="text-decoration:underline;color:green">m</span> <span style="text-decoration:line-through;color:red">the ELManager u</span><span style="text-decoration:underline;color:green">i</span>s<span style="text-decoration:line-through;color:red">ed</span> <span style="text-decoration:line-through;color:red">for EL processing. */ ELM</span>a<span style="text-decoration:line-through;color:red">nager</span> <span style="text-decoration:line-through;color:red">ge</span>s a <span style="text-decoration:underline;color:green">s</span>t<span style="text-decoration:line-through;color:red">ELM</span>a<span style="text-decoration:line-through;color:red">nager(); /* * Evalua</span>t<span style="text-decoration:line-through;color:red">e an EL express</span>i<span style="text-decoration:line-through;color:red">on,</span>tati<span style="text-decoration:underline;color:green">c</span> <span style="text-decoration:line-through;color:red">wi</span><span style="text-decoration:underline;color:green">me</span>tho<span style="text-decoration:line-through;color:red">ut coercion.</span><span style="text-decoration:underline;color:green">d)</span> <span style="text-decoration:line-through;color:red"> */ Obj</span>e<span style="text-decoration:line-through;color:red">ct getVa</span>l<span style="text-decoration:line-through;color:red">u</span> el<span style="text-decoration:underline;color:green">.d</span>e<span style="text-decoration:line-through;color:red">(Str</span><span style="text-decoration:underline;color:green">f</span>in<span style="text-decoration:line-through;color:red">g </span>e<span style="text-decoration:line-through;color:red">xpression); /* * Eval</span>ine<span style="text-decoration:underline;color:green">F</span>u<span style="text-decoration:line-through;color:red">ate a</span>n<span style="text-decoration:line-through;color:red"> EL express</span>un<span style="text-decoration:underline;color:green">ct</span>ion<span style="text-decoration:underline;color:green">("x"</span>ion, <span style="text-decoration:line-through;color:red">with</span>, <span style="text-decoration:underline;color:green">"sum",</span> <span style="text-decoration:line-through;color:red">c</span>o<span style="text-decoration:line-through;color:red">e</span>r<span style="text-decoration:line-through;color:red">cion</span> or<span style="text-decoration:underline;color:green">g</span>.<span style="text-decoration:line-through;color:red"> */ Obje</span><span style="text-decoration:underline;color:green">a</span>c<span style="text-decoration:line-through;color:red">t g</span><span style="text-decoration:underline;color:green">m</span>e<span style="text-decoration:line-through;color:red">tValue(String expressi</span><span style="text-decoration:underline;color:green">.F</span>o<span style="text-decoration:line-through;color:red">n</span><span style="text-decoration:underline;color:green">o"</span>, <span style="text-decoration:line-through;color:red">Cla</span><span style="text-decoration:underline;color:green">"</span>s<span style="text-decoration:line-through;color:red">s expectedType</span><span style="text-decoration:underline;color:green">um"</span>); <span style="text-decoration:line-through;color:red"> </span> <span style="text-decoration:line-through;color:red"> /* * </span>S<span style="text-decoration:line-through;color:red">e</span>); S<span style="text-decoration:underline;color:green">ys</span>t<span style="text-decoration:line-through;color:red"> a valu</span>e<span style="text-decoration:line-through;color:red"> t</span>te<span style="text-decoration:underline;color:green">m.</span>o<span style="text-decoration:line-through;color:red"> an EL ex</span><span style="text-decoration:underline;color:green">ut.</span>pr<span style="text-decoration:line-through;color:red">ess</span>i<span style="text-decoration:line-through;color:red">o</span>n<span style="text-decoration:line-through;color:red"> </span>t<span style="text-decoration:line-through;color:red">hat</span>print<span style="text-decoration:underline;color:green">ln("1</span> <span style="text-decoration:line-through;color:red">is</span><span style="text-decoration:underline;color:green">+</span><span style="text-decoration:line-through;color:red">a</span><span style="text-decoration:underline;color:green">2</span><span style="text-decoration:line-through;color:red">LHS </span><span style="text-decoration:underline;color:green">=</span><span style="text-decoration:underline;color:green">",</span> <span style="text-decoration:line-through;color:red"> */ void s</span> e<span style="text-decoration:underline;color:green">l.ge</span>etValue(<span style="text-decoration:line-through;color:red">String e</span>tValue(<span style="text-decoration:underline;color:green">"#{</span>x<span style="text-decoration:line-through;color:red">pre</span><span style="text-decoration:underline;color:green">:</span>s<span style="text-decoration:line-through;color:red">sion, Object val</span>u<span style="text-decoration:line-through;color:red">e</span>su<span style="text-decoration:underline;color:green">m(1,2</span>)<span style="text-decoration:underline;color:green">}"))</span>); <span style="text-decoration:line-through;color:red"> </span>/<span style="text-decoration:line-through;color:red">* </span>; /<span style="text-decoration:underline;color:green">/</span> <span style="text-decoration:line-through;color:red"> * </span> Define<span style="text-decoration:underline;color:green">s</span>Define a <span style="text-decoration:line-through;color:red">EL</span> a <span style="text-decoration:underline;color:green">el</span> variable <span style="text-decoration:line-through;color:red"> */ void d</span>e<span style="text-decoration:line-through;color:red">fin</span> variable e<span style="text-decoration:underline;color:green">l.s</span>e<span style="text-decoration:underline;color:green">t</span>eVariable(<span style="text-decoration:line-through;color:red">String </span>Variable(<span style="text-decoration:underline;color:green">"</span>v<span style="text-decoration:line-through;color:red">ar</span><span style="text-decoration:underline;color:green">"</span>, <span style="text-decoration:line-through;color:red">String expression); /* * De</span><span style="text-decoration:underline;color:green">"#{</span>f<span style="text-decoration:line-through;color:red">ine a EL functi</span>fo<span style="text-decoration:underline;color:green">o.</span>on<span style="text-decoration:line-through;color:red"> * @p</span>a<span style="text-decoration:line-through;color:red">ra</span>m<span style="text-decoration:line-through;color:red"> pr</span>e<span style="text-decoration:line-through;color:red">fix</span>name<span style="text-decoration:underline;color:green">}"); </span> <span style="text-decoration:line-through;color:red">The</span><span style="text-decoration:line-through;color:red">prefix of </span> <span style="text-decoration:underline;color:green">Sys</span>t<span style="text-decoration:line-through;color:red">h</span>e<span style="text-decoration:line-through;color:red"> f</span>te<span style="text-decoration:underline;color:green">m.o</span>u<span style="text-decoration:line-through;color:red">nc</span>t<span style="text-decoration:line-through;color:red">ion, or "" if </span>ut<span style="text-decoration:underline;color:green">.</span>pr<span style="text-decoration:line-through;color:red">ef</span>i<span style="text-decoration:line-through;color:red">x </span>n<span style="text-decoration:line-through;color:red">o</span>t<span style="text-decoration:line-through;color:red"> used. * @param </span>l<span style="text-decoration:line-through;color:red">ocalName The short </span>println<span style="text-decoration:underline;color:green">("n</span>name <span style="text-decoration:line-through;color:red">o</span>f<span style="text-decoration:line-through;color:red"> the functi</span>o<span style="text-decoration:line-through;color:red">n. * @pa</span>r<span style="text-decoration:line-through;color:red">am</span> f<span style="text-decoration:line-through;color:red">uncti</span>o<span style="text-decoration:line-through;color:red">n</span>ame for fo<span style="text-decoration:underline;color:green">o</span> <span style="text-decoration:line-through;color:red">The stat</span>i<span style="text-decoration:line-through;color:red">c</span> i<span style="text-decoration:underline;color:green">s</span> <span style="text-decoration:line-through;color:red">fucntion</span><span style="text-decoration:underline;color:green">",</span><span style="text-decoration:line-through;color:red">e.g </span>"<span style="text-decoration:line-through;color:red">org.acme.App.meth</span> "<span style="text-decoration:underline;color:green">#{v}</span>"<span style="text-decoration:line-through;color:red"> </span><span style="text-decoration:underline;color:green">);</span> <span style="text-decoration:underline;color:green">//</span> <span style="text-decoration:line-through;color:red"> * TODO: need p</span> <span style="text-decoration:underline;color:green">S</span>a<span style="text-decoration:line-through;color:red">ra</span>me<span style="text-decoration:line-through;color:red">ter</span>ame<span style="text-decoration:underline;color:green"> a</span>s t<span style="text-decoration:line-through;color:red">yp</span><span style="text-decoration:underline;color:green">h</span>e<span style="text-decoration:line-through;color:red">s? </span> <span style="text-decoration:line-through;color:red"> */ void de</span>fi<span style="text-decoration:line-through;color:red">neFunction(St</span>r<span style="text-decoration:line-through;color:red">ing</span>e fir<span style="text-decoration:underline;color:green">st</span> <span style="text-decoration:line-through;color:red">pr</span>e<span style="text-decoration:line-through;color:red">fi</span>x<span style="text-decoration:line-through;color:red">, String loc</span>a<span style="text-decoration:line-through;color:red">lNa</span> exam<span style="text-decoration:underline;color:green">pl</span>me<span style="text-decoration:line-through;color:red">, String function);</span> <span style="text-decoration:line-through;color:red">}</span><span style="text-decoration:line-through;color:red"> </span>===EL<span style="text-decoration:line-through;color:red">Manag</span>e ===EL<span style="text-decoration:underline;color:green">Proc</span>e<span style="text-decoration:underline;color:green">sso</span>er.java=== <span style="text-decoration:line-through;color:red"> </span>r.java=== <span style="text-decoration:underline;color:green">[http:</span>/<span style="text-decoration:line-through;color:red">* * M</span><span style="text-decoration:underline;color:green">/j</span>a<span style="text-decoration:line-through;color:red">nages EL parsing and e</span>va<span style="text-decoration:line-through;color:red">luatio</span>ava<span style="text-decoration:underline;color:green">.</span>n<span style="text-decoration:line-through;color:red"> </span>e<span style="text-decoration:line-through;color:red">nvi</span>ne<span style="text-decoration:underline;color:green">t/p</span>ro<span style="text-decoration:line-through;color:red">nm</span><span style="text-decoration:underline;color:green">j</span>e<span style="text-decoration:line-through;color:red">n</span><span style="text-decoration:underline;color:green">c</span>t<span style="text-decoration:line-through;color:red">. Th</span><span style="text-decoration:underline;color:green">s/</span>e<span style="text-decoration:line-through;color:red"> ELManager maintain</span><span style="text-decoration:underline;color:green">l-</span>s<span style="text-decoration:line-through;color:red"> an * instanc</span><span style="text-decoration:underline;color:green">p</span>e<span style="text-decoration:line-through;color:red"> of ELContext, whi</span>c<span style="text-decoration:line-through;color:red">h i</span>ec<span style="text-decoration:underline;color:green">/</span>s<span style="text-decoration:line-through;color:red"> used f</span>o<span style="text-decoration:line-through;color:red">r parsing and eval</span>u<span style="text-decoration:line-through;color:red">ating EL * exp</span>sour<span style="text-decoration:underline;color:green">c</span>es<span style="text-decoration:underline;color:green">/</span>ress<span style="text-decoration:line-through;color:red">i</span>o<span style="text-decoration:line-through;color:red">ns. It also contains a </span>so<span style="text-decoration:underline;color:green">u</span>r<span style="text-decoration:line-through;color:red">eferen</span>ce<span style="text-decoration:line-through;color:red"> t</span>rce<span style="text-decoration:underline;color:green">-c</span>o<span style="text-decoration:line-through;color:red"> an Expr</span><span style="text-decoration:underline;color:green">d</span>e<span style="text-decoration:line-through;color:red">ssi</span><span style="text-decoration:underline;color:green">/c</span>on<span style="text-decoration:line-through;color:red">Fac</span>t<span style="text-decoration:line-through;color:red">ory, th</span>e<span style="text-decoration:line-through;color:red"> * EL e</span>n<span style="text-decoration:line-through;color:red">gine. Bo</span>t<span style="text-decoration:line-through;color:red">h of </span>ontent<span style="text-decoration:underline;color:green">/</span>t<span style="text-decoration:line-through;color:red">hese i</span><span style="text-decoration:underline;color:green">ru</span>n<span style="text-decoration:line-through;color:red">st</span><span style="text-decoration:underline;color:green">k/</span>a<span style="text-decoration:line-through;color:red">nce</span><span style="text-decoration:underline;color:green">pi/</span>s<span style="text-decoration:line-through;color:red"> </span><span style="text-decoration:underline;color:green">r</span>c<span style="text-decoration:underline;color:green">/m</span>a<span style="text-decoration:underline;color:green">i</span>can<span style="text-decoration:line-through;color:red"> be repl</span>n<span style="text-decoration:underline;color:green">/j</span>a<span style="text-decoration:line-through;color:red">ced. * * When E</span><span style="text-decoration:underline;color:green">va/java</span>x<span style="text-decoration:line-through;color:red">pr</span><span style="text-decoration:underline;color:green">/</span>e<span style="text-decoration:line-through;color:red">ssion.new</span><span style="text-decoration:underline;color:green">l/</span>ELProcessor<span style="text-decoration:line-through;color:red"> is in</span><span style="text-decoration:underline;color:green">.ja</span>v<span style="text-decoration:line-through;color:red">oked, the st</span>a<span style="text-decoration:line-through;color:red">nda</span>va<span style="text-decoration:underline;color:green">?</span>r<span style="text-decoration:line-through;color:red">d ELManag</span>e<span style="text-decoration:line-through;color:red">r</span>re<span style="text-decoration:underline;color:green">v=3</span> <span style="text-decoration:line-through;color:red">i</span>s<span style="text-decoration:line-through;color:red"> * instantiat</span>e<span style="text-decoration:line-through;color:red">d. Th</span><span style="text-decoration:line-through;color:red"> </span> see<span style="text-decoration:underline;color:green">] ===</span>ELManager<span style="text-decoration:line-through;color:red"> cont</span><span style="text-decoration:underline;color:green">.j</span>a<span style="text-decoration:line-through;color:red">ins </span><span style="text-decoration:underline;color:green">v</span><span style="text-decoration:line-through;color:red"> standard ELContext. See ELContext</span><span style="text-decoration:underline;color:green">===</span> <span style="text-decoration:line-through;color:red"> * for a description of t</span><span style="text-decoration:underline;color:green">[</span>h<span style="text-decoration:line-through;color:red">e s</span>t<span style="text-decoration:line-through;color:red">andard ELCon</span><span style="text-decoration:line-through;color:red">ext. *</span>htt<span style="text-decoration:underline;color:green">p:</span>/<span style="text-decoration:line-through;color:red"> interf</span><span style="text-decoration:underline;color:green">/j</span>a<span style="text-decoration:line-through;color:red">ce ELM</span><span style="text-decoration:underline;color:green">v</span><span style="text-decoration:underline;color:green">.</span>an<span style="text-decoration:line-through;color:red">ag</span>e<span style="text-decoration:line-through;color:red">r { /* * Re</span>t<span style="text-decoration:line-through;color:red">urn the Ex</span>net<span style="text-decoration:underline;color:green">/</span>pr<span style="text-decoration:line-through;color:red">essi</span>o<span style="text-decoration:line-through;color:red">nFa</span>pro<span style="text-decoration:underline;color:green">je</span>ct<span style="text-decoration:line-through;color:red">ory in</span>s<span style="text-decoration:line-through;color:red">tanc</span>cts<span style="text-decoration:underline;color:green">/</span>e<span style="text-decoration:line-through;color:red"> used for EL eva</span>l<span style="text-decoration:line-through;color:red">uation</span>el<span style="text-decoration:underline;color:green">-</span>s<span style="text-decoration:line-through;color:red"> */ Ex</span>p<span style="text-decoration:line-through;color:red">r</span>spe<span style="text-decoration:underline;color:green">c/</span>es<span style="text-decoration:line-through;color:red">si</span>o<span style="text-decoration:line-through;color:red">nFacto</span>so<span style="text-decoration:underline;color:green">u</span>r<span style="text-decoration:line-through;color:red">y g</span><span style="text-decoration:underline;color:green">c</span>e<span style="text-decoration:line-through;color:red">tExpre</span>es<span style="text-decoration:underline;color:green">/</span>ss<span style="text-decoration:line-through;color:red">i</span>o<span style="text-decoration:line-through;color:red">nFacto</span>so<span style="text-decoration:underline;color:green">u</span>r<span style="text-decoration:line-through;color:red">y(); /* * S</span><span style="text-decoration:underline;color:green">c</span>e<span style="text-decoration:line-through;color:red">t the ExpressionFa</span><span style="text-decoration:underline;color:green">-</span>c<span style="text-decoration:line-through;color:red">t</span>o<span style="text-decoration:line-through;color:red">ry use</span>d<span style="text-decoration:line-through;color:red"> for EL </span>e<span style="text-decoration:line-through;color:red">valuati</span>code<span style="text-decoration:underline;color:green">/c</span>on<span style="text-decoration:line-through;color:red">s. * @re</span>t<span style="text-decoration:line-through;color:red">urn Th</span>e<span style="text-decoration:line-through;color:red"> previous Expressio</span>n<span style="text-decoration:line-through;color:red">Fac</span>t<span style="text-decoration:line-through;color:red">o</span>ontent<span style="text-decoration:underline;color:green">/t</span>r<span style="text-decoration:line-through;color:red">y, n</span>u<span style="text-decoration:line-through;color:red">ll if </span>n<span style="text-decoration:line-through;color:red">one *</span>run<span style="text-decoration:underline;color:green">k</span>/<span style="text-decoration:line-through;color:red"> Ex</span><span style="text-decoration:underline;color:green">a</span>p<span style="text-decoration:line-through;color:red">ress</span>i<span style="text-decoration:line-through;color:red">onFactory </span>pi<span style="text-decoration:underline;color:green">/</span>s<span style="text-decoration:line-through;color:red">etExp</span>r<span style="text-decoration:line-through;color:red">essionFa</span>c<span style="text-decoration:line-through;color:red">tory(Express</span>src<span style="text-decoration:underline;color:green">/ma</span>i<span style="text-decoration:line-through;color:red">o</span>n<span style="text-decoration:line-through;color:red">F</span>in<span style="text-decoration:underline;color:green">/j</span>a<span style="text-decoration:line-through;color:red">ctory f</span><span style="text-decoration:underline;color:green">v</span><span style="text-decoration:line-through;color:red">ctory); </span>/<span style="text-decoration:line-through;color:red">* * Return the ELConte</span>a/<span style="text-decoration:underline;color:green">java</span>x<span style="text-decoration:line-through;color:red">t used. *</span>/<span style="text-decoration:line-through;color:red"> ELCont</span>e<span style="text-decoration:line-through;color:red">xt getELContext(); </span>x/e<span style="text-decoration:underline;color:green">l</span>/<span style="text-decoration:line-through;color:red">* * Set the </span>EL<span style="text-decoration:line-through;color:red">Context used for p</span>/EL<span style="text-decoration:underline;color:green">M</span>a<span style="text-decoration:line-through;color:red">rsi</span>n<span style="text-decoration:line-through;color:red">g </span>a<span style="text-decoration:line-through;color:red">nd evaluatin</span>g<span style="text-decoration:line-through;color:red"> EL </span>e<span style="text-decoration:line-through;color:red">xp</span>r<span style="text-decoration:line-through;color:red">essions</span>.<span style="text-decoration:line-through;color:red"> * @</span>anager.<span style="text-decoration:underline;color:green">java?</span>re<span style="text-decoration:line-through;color:red">turn The pre</span>v<span style="text-decoration:line-through;color:red">ious</span>rev<span style="text-decoration:underline;color:green">=3</span> <span style="text-decoration:line-through;color:red">ELContext, null if none. */ ELContext </span>se<span style="text-decoration:line-through;color:red">tELCont</span>e<span style="text-decoration:line-through;color:red">xt(ELContext context);</span> see<span style="text-decoration:underline;color:green">]</span> <span style="text-decoration:line-through;color:red"> /* * Register bean name lookup * Implicitly adds a </span><span style="text-decoration:underline;color:green">===</span>BeanName<span style="text-decoration:line-through;color:red">EL</span>Resolver<span style="text-decoration:line-through;color:red"> to the list of ELResol</span>BeanNameResolver<span style="text-decoration:underline;color:green">.ja</span>v<span style="text-decoration:line-through;color:red">ers</span><span style="text-decoration:underline;color:green">a===</span> <span style="text-decoration:line-through;color:red"> *</span><span style="text-decoration:underline;color:green">[http:</span>/<span style="text-decoration:line-through;color:red"> void </span><span style="text-decoration:underline;color:green">/j</span>a<span style="text-decoration:line-through;color:red">ddBeanNameResol</span>v<span style="text-decoration:line-through;color:red">er(Be</span>ava<span style="text-decoration:underline;color:green">.</span>an<span style="text-decoration:line-through;color:red">Nam</span>e<span style="text-decoration:line-through;color:red">Resolver bnr); </span>ne<span style="text-decoration:underline;color:green">t</span>/<span style="text-decoration:line-through;color:red">* * Add use</span><span style="text-decoration:underline;color:green">p</span>r<span style="text-decoration:line-through;color:red"> defined ELRes</span>o<span style="text-decoration:line-through;color:red">lv</span>ro<span style="text-decoration:underline;color:green">j</span>e<span style="text-decoration:line-through;color:red">r to the </span>c<span style="text-decoration:line-through;color:red">urrec</span>t<span style="text-decoration:line-through;color:red"> li</span>s<span style="text-decoration:line-through;color:red">t of ELR</span>ects<span style="text-decoration:underline;color:green">/</span>e<span style="text-decoration:line-through;color:red">so</span>l<span style="text-decoration:line-through;color:red">ver</span>el<span style="text-decoration:underline;color:green">-</span>s<span style="text-decoration:line-through;color:red"> * Can be called multi</span>p<span style="text-decoration:line-through;color:red">l</span>e<span style="text-decoration:line-through;color:red"> times with additive effe</span>c<span style="text-decoration:line-through;color:red">t. *</span>/<span style="text-decoration:line-through;color:red"> void addELRe</span>so<span style="text-decoration:line-through;color:red">lve</span>spec/so<span style="text-decoration:underline;color:green">u</span>r<span style="text-decoration:line-through;color:red">(ELR</span><span style="text-decoration:underline;color:green">c</span>es<span style="text-decoration:line-through;color:red">olver elr); </span>/<span style="text-decoration:line-through;color:red">* * Set the ELRe</span>so<span style="text-decoration:line-through;color:red">lve</span>es/so<span style="text-decoration:underline;color:green">u</span>r<span style="text-decoration:line-through;color:red"> in th</span><span style="text-decoration:underline;color:green">c</span>e<span style="text-decoration:line-through;color:red"> ELC</span><span style="text-decoration:underline;color:green">-c</span>o<span style="text-decoration:line-through;color:red">ntext, to be use</span>d<span style="text-decoration:line-through;color:red"> for EL </span>e<span style="text-decoration:line-through;color:red">xpressi</span>ode<span style="text-decoration:underline;color:green">/c</span>on<span style="text-decoration:line-through;color:red"> * proc</span><span style="text-decoration:underline;color:green">t</span>e<span style="text-decoration:line-through;color:red">ssi</span>n<span style="text-decoration:line-through;color:red">g. No</span>t<span style="text-decoration:line-through;color:red">e </span>ent<span style="text-decoration:underline;color:green">/</span>t<span style="text-decoration:line-through;color:red">hat the ELResolve</span>r<span style="text-decoration:line-through;color:red">s added i</span>tr<span style="text-decoration:underline;color:green">u</span>n<span style="text-decoration:line-through;color:red"> </span><span style="text-decoration:underline;color:green">k/a</span>p<span style="text-decoration:line-through;color:red">rev</span>i<span style="text-decoration:line-through;color:red">ou</span>pi<span style="text-decoration:underline;color:green">/</span>s<span style="text-decoration:line-through;color:red"> </span><span style="text-decoration:underline;color:green">r</span>c<span style="text-decoration:underline;color:green">/m</span>ca<span style="text-decoration:line-through;color:red">lls to * </span>a<span style="text-decoration:underline;color:green">in/j</span><span style="text-decoration:line-through;color:red">ddELResol</span>v<span style="text-decoration:line-through;color:red">er </span>a<span style="text-decoration:line-through;color:red">nd </span>ava<span style="text-decoration:underline;color:green">/j</span>a<span style="text-decoration:line-through;color:red">dd</span><span style="text-decoration:underline;color:green">vax/el/</span>BeanNameResolver<span style="text-decoration:line-through;color:red"> </span><span style="text-decoration:underline;color:green">.j</span>a<span style="text-decoration:line-through;color:red">re associated with the pre</span>v<span style="text-decoration:line-through;color:red">ious * ELContext, </span>a<span style="text-decoration:line-through;color:red">nd will not be automatically added to the new ELResolve</span>ava<span style="text-decoration:underline;color:green">?</span>r<span style="text-decoration:line-through;color:red">. * @r</span>e<span style="text-decoration:line-through;color:red">turn The pre</span>v<span style="text-decoration:line-through;color:red">ious</span>rev<span style="text-decoration:underline;color:green">=3</span> <span style="text-decoration:line-through;color:red">ELRe</span>s<span style="text-decoration:line-through;color:red">olv</span>e<span style="text-decoration:line-through;color:red">r or null if th</span><span style="text-decoration:line-through;color:red">re is none.</span> see<span style="text-decoration:underline;color:green">]</span> <span style="text-decoration:line-through;color:red"> */</span><span style="text-decoration:line-through;color:red"> ELResolver setELResolver(ELResolver elr); } </span> ===BeanName<span style="text-decoration:underline;color:green">EL</span>===BeanNameResolver.java=== <span style="text-decoration:line-through;color:red"> /* * An abs</span>Resolver.java=== <span style="text-decoration:underline;color:green">[h</span>t<span style="text-decoration:line-through;color:red">rac</span><span style="text-decoration:line-through;color:red"> cl</span>tt<span style="text-decoration:underline;color:green">p://j</span>a<span style="text-decoration:line-through;color:red">ss th</span><span style="text-decoration:underline;color:green">v</span><span style="text-decoration:line-through;color:red">t ca</span><span style="text-decoration:underline;color:green">.</span>n<span style="text-decoration:line-through;color:red"> b</span>e<span style="text-decoration:line-through;color:red"> ex</span>t<span style="text-decoration:line-through;color:red">ended to </span>net<span style="text-decoration:underline;color:green">/p</span>r<span style="text-decoration:line-through;color:red">eturn a bean </span>o<span style="text-decoration:line-through;color:red">b</span>ject<span style="text-decoration:line-through;color:red"> given it</span>s<span style="text-decoration:line-through;color:red"> nam</span>rojects<span style="text-decoration:underline;color:green">/</span>e<span style="text-decoration:line-through;color:red"> * or to set a va</span>l<span style="text-decoration:line-through;color:red">ue to an exi</span>el<span style="text-decoration:underline;color:green">-</span>s<span style="text-decoration:line-through;color:red">ting b</span><span style="text-decoration:underline;color:green">p</span>e<span style="text-decoration:line-through;color:red">an. *</span><span style="text-decoration:underline;color:green">c</span>/<span style="text-decoration:line-through;color:red"> ab</span>s<span style="text-decoration:line-through;color:red">t</span>/s<span style="text-decoration:underline;color:green">ou</span>r<span style="text-decoration:line-through;color:red">a</span>c<span style="text-decoration:line-through;color:red">t class B</span>e<span style="text-decoration:line-through;color:red">anNameRe</span>s<span style="text-decoration:line-through;color:red">olver { </span>/<span style="text-decoration:line-through;color:red">* * Ret</span>rces/<span style="text-decoration:underline;color:green">so</span>ur<span style="text-decoration:line-through;color:red">n th</span><span style="text-decoration:underline;color:green">c</span>e<span style="text-decoration:line-through;color:red"> bean kn</span><span style="text-decoration:underline;color:green">-c</span>o<span style="text-decoration:line-through;color:red">wn by its nam</span><span style="text-decoration:underline;color:green">d</span>e<span style="text-decoration:line-through;color:red"> *</span>/<span style="text-decoration:line-through;color:red"> Stri</span>e/<span style="text-decoration:underline;color:green">co</span>n<span style="text-decoration:line-through;color:red">g ge</span>t<span style="text-decoration:line-through;color:red">B</span>e<span style="text-decoration:line-through;color:red">a</span>n<span style="text-decoration:line-through;color:red">(S</span>t<span style="text-decoration:line-through;color:red">ring beanName) { re</span>ntent<span style="text-decoration:underline;color:green">/</span>t<span style="text-decoration:line-through;color:red">u</span>r<span style="text-decoration:line-through;color:red">n n</span>u<span style="text-decoration:line-through;color:red">ll; } </span>tru<span style="text-decoration:underline;color:green">nk</span>/<span style="text-decoration:line-through;color:red">* * Set </span>a<span style="text-decoration:line-through;color:red"> value to an ex</span>/a<span style="text-decoration:underline;color:green">p</span>i<span style="text-decoration:underline;color:green">/</span>is<span style="text-decoration:line-through;color:red">ting be</span>s<span style="text-decoration:underline;color:green">rc/m</span>a<span style="text-decoration:line-through;color:red">n of the g</span>i<span style="text-decoration:line-through;color:red">ve</span>n<span style="text-decoration:line-through;color:red"> name. *</span>/<span style="text-decoration:line-through;color:red"> </span>ain/<span style="text-decoration:underline;color:green">ja</span>v<span style="text-decoration:line-through;color:red">oid setBe</span>a<span style="text-decoration:line-through;color:red">nValue(String beanName, Ob</span>va<span style="text-decoration:underline;color:green">/</span>j<span style="text-decoration:line-through;color:red">ect </span><span style="text-decoration:underline;color:green">a</span>va<span style="text-decoration:line-through;color:red">lue) throws PropertyNotWritableE</span>x<span style="text-decoration:line-through;color:red">c</span>vax<span style="text-decoration:underline;color:green">/</span>e<span style="text-decoration:line-through;color:red">ption { throw new PropertyNotWritab</span>l<span style="text-decoration:line-through;color:red">eException(); } } ===</span>el<span style="text-decoration:underline;color:green">/</span>BeanNameELResolver.java<span style="text-decoration:line-through;color:red">=== /* * An ELResolve</span><span style="text-decoration:underline;color:green">?</span>r<span style="text-decoration:line-through;color:red"> that h</span>e<span style="text-decoration:line-through;color:red">lp to resol</span>v<span style="text-decoration:line-through;color:red">e</span>rev<span style="text-decoration:underline;color:green">=3</span> <span style="text-decoration:line-through;color:red">u</span>se<span style="text-decoration:line-through;color:red">r or contain</span>e<span style="text-decoration:line-through;color:red">r managed beans.</span> see<span style="text-decoration:underline;color:green">]</span> <span style="text-decoration:line-through;color:red"> */</span><span style="text-decoration:line-through;color:red">public cl</span> <span style="text-decoration:underline;color:green">===St</span>a<span style="text-decoration:line-through;color:red">ss Bea</span>n<span style="text-decoration:line-through;color:red">N</span>an<span style="text-decoration:underline;color:green">d</span>a<span style="text-decoration:line-through;color:red">meELResolve</span>r<span style="text-decoration:line-through;color:red"> exten</span>d<span style="text-decoration:line-through;color:red">s </span>ELResolver<span style="text-decoration:line-through;color:red"> { priv</span>ardELResolver<span style="text-decoration:underline;color:green">.j</span>a<span style="text-decoration:line-through;color:red">te BeanNameResol</span>v<span style="text-decoration:line-through;color:red">er be</span>a<span style="text-decoration:line-through;color:red">nNameResolver;</span>ava<span style="text-decoration:underline;color:green">===</span> <span style="text-decoration:line-through;color:red"> </span><span style="text-decoration:underline;color:green">[htt</span>p<span style="text-decoration:line-through;color:red">ublic Be</span><span style="text-decoration:underline;color:green">://j</span>a<span style="text-decoration:line-through;color:red">nNameELResol</span>v<span style="text-decoration:line-through;color:red">er(Be</span>ava<span style="text-decoration:underline;color:green">.</span>an<span style="text-decoration:line-through;color:red">Nam</span>e<span style="text-decoration:line-through;color:red">Resolve</span>ne<span style="text-decoration:underline;color:green">t/p</span>r<span style="text-decoration:line-through;color:red"> beanNameRes</span>o<span style="text-decoration:line-through;color:red">lv</span>ro<span style="text-decoration:underline;color:green">j</span>e<span style="text-decoration:line-through;color:red">r) { </span><span style="text-decoration:underline;color:green">c</span>t<span style="text-decoration:line-through;color:red">hi</span>s<span style="text-decoration:line-through;color:red">.b</span>ts<span style="text-decoration:underline;color:green">/</span>e<span style="text-decoration:line-through;color:red">anNam</span><span style="text-decoration:underline;color:green">l-sp</span><span style="text-decoration:line-through;color:red">Re</span><span style="text-decoration:underline;color:green">c/</span>so<span style="text-decoration:line-through;color:red">lve</span><span style="text-decoration:underline;color:green">u</span>r<span style="text-decoration:line-through;color:red"> = b</span><span style="text-decoration:underline;color:green">c</span>e<span style="text-decoration:line-through;color:red">anNameRe</span>es<span style="text-decoration:underline;color:green">/s</span>so<span style="text-decoration:line-through;color:red">lver; } @Override p</span>u<span style="text-decoration:line-through;color:red">bli</span>ou<span style="text-decoration:underline;color:green">r</span>c<span style="text-decoration:line-through;color:red"> Obj</span>ce<span style="text-decoration:underline;color:green">-</span>ec<span style="text-decoration:line-through;color:red">t getValue(ELC</span>o<span style="text-decoration:line-through;color:red">nt</span>co<span style="text-decoration:underline;color:green">d</span>e<span style="text-decoration:line-through;color:red">xt </span><span style="text-decoration:underline;color:green">/</span>conte<span style="text-decoration:line-through;color:red">xt, Object base, Object property) { if (co</span>nt<span style="text-decoration:line-through;color:red">ex</span>content<span style="text-decoration:underline;color:green">/</span>t<span style="text-decoration:line-through;color:red"> == null) { th</span>r<span style="text-decoration:line-through;color:red">ow new N</span>u<span style="text-decoration:line-through;color:red">llPoi</span>n<span style="text-decoration:line-through;color:red">terException(); } if (b</span>trun<span style="text-decoration:underline;color:green">k/</span>a<span style="text-decoration:line-through;color:red">se == null && </span>p<span style="text-decoration:line-through;color:red">roperty </span>i<span style="text-decoration:line-through;color:red">n</span>api<span style="text-decoration:underline;color:green">/</span>s<span style="text-decoration:line-through;color:red">tanceof St</span>sr<span style="text-decoration:underline;color:green">c/ma</span>rin<span style="text-decoration:line-through;color:red">g) { Ob</span>in<span style="text-decoration:underline;color:green">/</span>j<span style="text-decoration:line-through;color:red">ect be</span>a<span style="text-decoration:line-through;color:red">n = be</span>ja<span style="text-decoration:underline;color:green">v</span>a<span style="text-decoration:line-through;color:red">nN</span><span style="text-decoration:underline;color:green">/j</span><span style="text-decoration:line-through;color:red">meResol</span>v<span style="text-decoration:line-through;color:red">er.getBe</span>a<span style="text-decoration:line-through;color:red">n((String) property); if (bean != null) { conte</span>x<span style="text-decoration:line-through;color:red">t.s</span>avax<span style="text-decoration:underline;color:green">/</span>e<span style="text-decoration:line-through;color:red">tPropertyReso</span>l<span style="text-decoration:line-through;color:red">ved(</span>el<span style="text-decoration:underline;color:green">/S</span>t<span style="text-decoration:line-through;color:red">rue); return be</span>an<span style="text-decoration:line-through;color:red">; } } return null; } @Overri</span>d<span style="text-decoration:line-through;color:red">e public void setV</span>a<span style="text-decoration:line-through;color:red">lue(</span>tanda<span style="text-decoration:underline;color:green">rd</span>ELContext<span style="text-decoration:line-through;color:red"> context, Ob</span><span style="text-decoration:underline;color:green">.</span>j<span style="text-decoration:line-through;color:red">ect b</span>a<span style="text-decoration:line-through;color:red">se, Object p</span>ja<span style="text-decoration:underline;color:green">va?</span>r<span style="text-decoration:line-through;color:red">op</span>e<span style="text-decoration:line-through;color:red">rty, </span>re<span style="text-decoration:underline;color:green">v=3</span> <span style="text-decoration:line-through;color:red"> Obj</span><span style="text-decoration:underline;color:green">s</span>e<span style="text-decoration:line-through;color:red">ct valu</span><span style="text-decoration:line-through;color:red">) {</span>ee<span style="text-decoration:underline;color:green">]</span> <span style="text-decoration:line-through;color:red"> if (context </span><span style="text-decoration:underline;color:green"> </span>==<span style="text-decoration:line-through;color:red"> n</span><span style="text-decoration:underline;color:green">=F</span>u<span style="text-decoration:line-through;color:red">ll) { throw </span>n<span style="text-decoration:line-through;color:red">ew NullPointerEx</span>c<span style="text-decoration:line-through;color:red">ep</span>tion<span style="text-decoration:line-through;color:red">(); } if (b</span>unction<span style="text-decoration:underline;color:green">M</span>a<span style="text-decoration:line-through;color:red">se == null && </span>p<span style="text-decoration:line-through;color:red">ro</span>per<span style="text-decoration:line-through;color:red">ty inst</span>apper<span style="text-decoration:underline;color:green">.j</span>a<span style="text-decoration:line-through;color:red">nceof String) {</span><span style="text-decoration:underline;color:green">va===</span> <span style="text-decoration:line-through;color:red"> Objec</span><span style="text-decoration:underline;color:green">[h</span>t<span style="text-decoration:line-through;color:red"> be</span><span style="text-decoration:underline;color:green">tp://j</span>a<span style="text-decoration:line-through;color:red">n = be</span><span style="text-decoration:underline;color:green">v</span><span style="text-decoration:underline;color:green">.</span>an<span style="text-decoration:line-through;color:red">Nam</span>e<span style="text-decoration:line-through;color:red">Resolver.ge</span>t<span style="text-decoration:line-through;color:red">Bean((String) </span>net<span style="text-decoration:underline;color:green">/</span>pro<span style="text-decoration:line-through;color:red">p</span><span style="text-decoration:underline;color:green">j</span>e<span style="text-decoration:line-through;color:red">rty); if (bean != null) { </span>c<span style="text-decoration:line-through;color:red">on</span>t<span style="text-decoration:line-through;color:red">ext.</span>ects<span style="text-decoration:underline;color:green">/</span>se<span style="text-decoration:line-through;color:red">tPro</span>e<span style="text-decoration:underline;color:green">l-s</span>pe<span style="text-decoration:line-through;color:red">rtyRe</span><span style="text-decoration:underline;color:green">c/</span>so<span style="text-decoration:line-through;color:red">lved(tr</span>sou<span style="text-decoration:underline;color:green">rc</span>ue<span style="text-decoration:line-through;color:red">); beanNameRe</span>es<span style="text-decoration:underline;color:green">/s</span>so<span style="text-decoration:line-through;color:red">lve</span>o<span style="text-decoration:underline;color:green">u</span>r<span style="text-decoration:line-through;color:red">.s</span><span style="text-decoration:underline;color:green">c</span>e<span style="text-decoration:line-through;color:red">tB</span><span style="text-decoration:underline;color:green">-cod</span><span style="text-decoration:line-through;color:red">a</span><span style="text-decoration:underline;color:green">/co</span>n<span style="text-decoration:line-through;color:red">Value((S</span>t<span style="text-decoration:line-through;color:red">ring) prop</span>e<span style="text-decoration:line-through;color:red">r</span>nte<span style="text-decoration:underline;color:green">n</span>t<span style="text-decoration:line-through;color:red">y, value); } } } } ===Exp</span><span style="text-decoration:underline;color:green">/t</span>r<span style="text-decoration:line-through;color:red">essio</span><span style="text-decoration:underline;color:green">u</span>n<span style="text-decoration:line-through;color:red">F</span><span style="text-decoration:underline;color:green">k/</span>a<span style="text-decoration:line-through;color:red">ctory.java=== </span>p<span style="text-decoration:line-through;color:red">ubl</span>i<span style="text-decoration:line-through;color:red">c ab</span>api<span style="text-decoration:underline;color:green">/</span>s<span style="text-decoration:line-through;color:red">t</span>r<span style="text-decoration:line-through;color:red">a</span>c<span style="text-decoration:line-through;color:red">t cl</span>src<span style="text-decoration:underline;color:green">/m</span>a<span style="text-decoration:line-through;color:red">ss Express</span>i<span style="text-decoration:line-through;color:red">o</span>n<span style="text-decoration:line-through;color:red">F</span>ain<span style="text-decoration:underline;color:green">/j</span>a<span style="text-decoration:line-through;color:red">ctory { ... </span><span style="text-decoration:underline;color:green">va</span>/<span style="text-decoration:line-through;color:red">* * Get </span><span style="text-decoration:underline;color:green">j</span>a<span style="text-decoration:line-through;color:red"> new inst</span><span style="text-decoration:underline;color:green">v</span><span style="text-decoration:line-through;color:red">nc</span><span style="text-decoration:underline;color:green">x/</span>e<span style="text-decoration:line-through;color:red"> of an imp</span>l<span style="text-decoration:line-through;color:red">eme</span>el<span style="text-decoration:underline;color:green">/Fu</span>n<span style="text-decoration:underline;color:green">c</span>nt<span style="text-decoration:line-through;color:red">at</span>ion<span style="text-decoration:line-through;color:red"> of ELProc</span>tion<span style="text-decoration:underline;color:green">Mapp</span>e<span style="text-decoration:line-through;color:red">sso</span>r<span style="text-decoration:line-through;color:red"> */ public </span>er<span style="text-decoration:underline;color:green">.j</span>a<span style="text-decoration:line-through;color:red">bstr</span><span style="text-decoration:underline;color:green">v</span><span style="text-decoration:line-through;color:red">ct ELP</span><span style="text-decoration:underline;color:green">?</span>r<span style="text-decoration:line-through;color:red">oc</span>e<span style="text-decoration:line-through;color:red">ssor</span>re<span style="text-decoration:underline;color:green">v=3</span> <span style="text-decoration:line-through;color:red">n</span><span style="text-decoration:underline;color:green">s</span>e<span style="text-decoration:line-through;color:red">wELProc</span><span style="text-decoration:line-through;color:red">ssor(); } </span>ee<span style="text-decoration:underline;color:green">]</span> <span>
 
 
Close
loading
Please Confirm
Close