ASF Bugzilla – Attachment 29705 Details for
Bug 54239
Extensible EL Interpreter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
ELInterpreterFactory
ELInterpreterFactory.java (text/plain), 3.38 KB, created by
Sheldon Shao
on 2012-12-06 05:10:14 UTC
(
hide
)
Description:
ELInterpreterFactory
Filename:
MIME Type:
Creator:
Sheldon Shao
Created:
2012-12-06 05:10:14 UTC
Size:
3.38 KB
patch
obsolete
>package org.apache.jasper.compiler; > >import javax.servlet.ServletContext; > >import org.apache.jasper.JspCompilationContext; > >/** > * ELInterpreter Factory > * > * Supports how to get a right ELInterpreter from ServletContext. > * > * 1. It supports get ELInterpreter instance from ServletContext, so that Web Application can provide its own ELInterpreter. > * 2. Customized ELInterpreter can be passed-in by setting "org.apache.jasper.compiler.ELInterpreter=xxx" in ServletContext's initialization parameters. > * 3. If there is no any ELInterpreter, the DefaultELInterpreter will be used > * > * @author Sheldon Shao (XShao@ebay.com) > */ >public class ELInterpreterFactory { > > private ELInterpreterFactory() { > } > > public static final String EL_INTERPRETER_CLASS_NAME = ELInterpreter.class.getName(); > > /** > * Default Instance > */ > private static final ELInterpreter DEFAULT_INSTANCE = new DefaultELInterpreter(); > > public static class DefaultELInterpreter implements ELInterpreter { > > /** > * Produces a String representing a call to the EL interpreter. > * > * @param context JspCompilationContext > * @param expression > * a String containing zero or more "${}" expressions > * @param expectedType > * the expected type of the interpreted result > * @param fnmapvar > * Variable pointing to a function map. > * @param XmlEscape > * True if the result should do XML escaping > * @return a String representing a call to the EL interpreter. > */ > @Override > public String interpreterCall(JspCompilationContext context, > boolean isTagFile, String expression, > Class<?> expectedType, String fnmapvar, boolean xmlEscape) { > return JspUtil.interpreterCall(isTagFile, expression, expectedType, fnmapvar, xmlEscape); > } > } > > /** > * Retrieve ELInterpreter implementation from ServletContext > * > * @param context ServletContext > */ > public static ELInterpreter getELInterpreter(ServletContext context) throws Exception { > ELInterpreter interpreter = null; > //Check ELInterpreter in > Object conf = context.getAttribute(EL_INTERPRETER_CLASS_NAME); > if (conf == null) { > String className = context.getInitParameter(EL_INTERPRETER_CLASS_NAME); > if (className != null) { > interpreter = toInterpreter(context, className); > } > else { > interpreter = DEFAULT_INSTANCE; > } > } > else if (conf instanceof ELInterpreter) { > interpreter = (ELInterpreter)conf; > return interpreter; > } > else if (conf instanceof String) { > interpreter = toInterpreter(context, (String)conf); > } > context.setAttribute(EL_INTERPRETER_CLASS_NAME, interpreter); > return interpreter; > } > > /** > * Create ELInterpreter by given class name > * > * @param context ServletContext > * @param className Class Name > * @return > */ > private static ELInterpreter toInterpreter(ServletContext context, String className) throws Exception { > return (ELInterpreter)context.getClassLoader().loadClass(className).newInstance(); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 54239
:
29684
|
29685
|
29686
|
29693
|
29694
|
29695
|
29696
|
29704
|
29705
|
29706
|
29707
|
29708