ASF Bugzilla – Attachment 29707 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), 4.18 KB, created by
Sheldon Shao
on 2012-12-06 06:02:32 UTC
(
hide
)
Description:
ELInterpreterFactory
Filename:
MIME Type:
Creator:
Sheldon Shao
Created:
2012-12-06 06:02:32 UTC
Size:
4.18 KB
patch
obsolete
>/* > * Licensed to the Apache Software Foundation (ASF) under one or more > * contributor license agreements. See the NOTICE file distributed with > * this work for additional information regarding copyright ownership. > * The ASF licenses this file to You under the Apache License, Version 2.0 > * (the "License"); you may not use this file except in compliance with > * the License. You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ >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