This commit is contained in:
2024-11-30 19:03:49 +08:00
commit 1e6763c160
3806 changed files with 737676 additions and 0 deletions

View File

@@ -0,0 +1,153 @@
/*
* 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.el;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import javax.el.ArrayELResolver;
import javax.el.BeanELResolver;
import javax.el.CompositeELResolver;
import javax.el.ELContext;
import javax.el.ELManager;
import javax.el.ELResolver;
import javax.el.ExpressionFactory;
import javax.el.FunctionMapper;
import javax.el.ListELResolver;
import javax.el.MapELResolver;
import javax.el.ResourceBundleELResolver;
import javax.el.StaticFieldELResolver;
import javax.el.ValueExpression;
import javax.el.VariableMapper;
import org.apache.jasper.Constants;
/**
* Implementation of ELContext
*
* @author Jacob Hookom
*/
public class ELContextImpl extends ELContext {
private static final FunctionMapper NullFunctionMapper = new FunctionMapper() {
@Override
public Method resolveFunction(String prefix, String localName) {
return null;
}
};
private static final class VariableMapperImpl extends VariableMapper {
private Map<String, ValueExpression> vars;
@Override
public ValueExpression resolveVariable(String variable) {
if (vars == null) {
return null;
}
return vars.get(variable);
}
@Override
public ValueExpression setVariable(String variable,
ValueExpression expression) {
if (vars == null) {
vars = new HashMap<>();
}
if (expression == null) {
return vars.remove(variable);
} else {
return vars.put(variable, expression);
}
}
}
private static final ELResolver DefaultResolver;
static {
if (Constants.IS_SECURITY_ENABLED) {
DefaultResolver = null;
} else {
DefaultResolver = new CompositeELResolver();
((CompositeELResolver) DefaultResolver).add(
ELManager.getExpressionFactory().getStreamELResolver());
((CompositeELResolver) DefaultResolver).add(new StaticFieldELResolver());
((CompositeELResolver) DefaultResolver).add(new MapELResolver());
((CompositeELResolver) DefaultResolver).add(new ResourceBundleELResolver());
((CompositeELResolver) DefaultResolver).add(new ListELResolver());
((CompositeELResolver) DefaultResolver).add(new ArrayELResolver());
((CompositeELResolver) DefaultResolver).add(new BeanELResolver());
}
}
private final ELResolver resolver;
private FunctionMapper functionMapper = NullFunctionMapper;
private VariableMapper variableMapper;
public ELContextImpl(ExpressionFactory factory) {
this(getDefaultResolver(factory));
}
public ELContextImpl(ELResolver resolver) {
this.resolver = resolver;
}
@Override
public ELResolver getELResolver() {
return this.resolver;
}
@Override
public FunctionMapper getFunctionMapper() {
return this.functionMapper;
}
@Override
public VariableMapper getVariableMapper() {
if (this.variableMapper == null) {
this.variableMapper = new VariableMapperImpl();
}
return this.variableMapper;
}
public void setFunctionMapper(FunctionMapper functionMapper) {
this.functionMapper = functionMapper;
}
public void setVariableMapper(VariableMapper variableMapper) {
this.variableMapper = variableMapper;
}
public static ELResolver getDefaultResolver(ExpressionFactory factory) {
if (Constants.IS_SECURITY_ENABLED) {
CompositeELResolver defaultResolver = new CompositeELResolver();
defaultResolver.add(factory.getStreamELResolver());
defaultResolver.add(new StaticFieldELResolver());
defaultResolver.add(new MapELResolver());
defaultResolver.add(new ResourceBundleELResolver());
defaultResolver.add(new ListELResolver());
defaultResolver.add(new ArrayELResolver());
defaultResolver.add(new BeanELResolver());
return defaultResolver;
} else {
return DefaultResolver;
}
}
}

View File

@@ -0,0 +1,88 @@
/*
* 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.el;
import java.util.Locale;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.FunctionMapper;
import javax.el.VariableMapper;
/**
* Simple ELContextWrapper for runtime evaluation of EL w/ dynamic FunctionMappers
*
* @author jhook
*/
public final class ELContextWrapper extends ELContext {
private final ELContext target;
private final FunctionMapper fnMapper;
public ELContextWrapper(ELContext target, FunctionMapper fnMapper) {
this.target = target;
this.fnMapper = fnMapper;
}
@Override
public ELResolver getELResolver() {
return this.target.getELResolver();
}
@Override
public FunctionMapper getFunctionMapper() {
if (this.fnMapper != null) return this.fnMapper;
return this.target.getFunctionMapper();
}
@Override
public VariableMapper getVariableMapper() {
return this.target.getVariableMapper();
}
@Override
public Object getContext(@SuppressWarnings("rawtypes") Class key) {
return this.target.getContext(key);
}
@Override
public Locale getLocale() {
return this.target.getLocale();
}
@Override
public boolean isPropertyResolved() {
return this.target.isPropertyResolved();
}
@Override
public void putContext(@SuppressWarnings("rawtypes") Class key,
Object contextObject) throws NullPointerException {
this.target.putContext(key, contextObject);
}
@Override
public void setLocale(Locale locale) {
this.target.setLocale(locale);
}
@Override
public void setPropertyResolved(boolean resolved) {
this.target.setPropertyResolved(resolved);
}
}

View File

@@ -0,0 +1,127 @@
/*
* 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.el;
import java.util.Iterator;
import java.util.Objects;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.ExpressionFactory;
import javax.el.PropertyNotWritableException;
import javax.servlet.jsp.el.VariableResolver;
@Deprecated
public final class ELResolverImpl extends ELResolver {
private final VariableResolver variableResolver;
private final ELResolver elResolver;
public ELResolverImpl(VariableResolver variableResolver,
ExpressionFactory factory) {
this.variableResolver = variableResolver;
this.elResolver = ELContextImpl.getDefaultResolver(factory);
}
@Override
public Object getValue(ELContext context, Object base, Object property) {
Objects.requireNonNull(context);
if (base == null) {
context.setPropertyResolved(base, property);
if (property != null) {
try {
return this.variableResolver.resolveVariable(property
.toString());
} catch (javax.servlet.jsp.el.ELException e) {
throw new ELException(e.getMessage(), e.getCause());
}
}
}
if (!context.isPropertyResolved()) {
return elResolver.getValue(context, base, property);
}
return null;
}
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
Objects.requireNonNull(context);
if (base == null) {
context.setPropertyResolved(base, property);
if (property != null) {
try {
Object obj = this.variableResolver.resolveVariable(property
.toString());
return (obj != null) ? obj.getClass() : null;
} catch (javax.servlet.jsp.el.ELException e) {
throw new ELException(e.getMessage(), e.getCause());
}
}
}
if (!context.isPropertyResolved()) {
return elResolver.getType(context, base, property);
}
return null;
}
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
Objects.requireNonNull(context);
if (base == null) {
context.setPropertyResolved(base, property);
throw new PropertyNotWritableException(
"Legacy VariableResolver wrapped, not writable");
}
if (!context.isPropertyResolved()) {
elResolver.setValue(context, base, property, value);
}
}
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
Objects.requireNonNull(context);
if (base == null) {
context.setPropertyResolved(base, property);
return true;
}
return elResolver.isReadOnly(context, base, property);
}
@Override
public Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
return elResolver.getFeatureDescriptors(context, base);
}
@Override
public Class<?> getCommonPropertyType(ELContext context, Object base) {
if (base == null) {
return String.class;
}
return elResolver.getCommonPropertyType(context, base);
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.el;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.servlet.jsp.el.ELException;
import javax.servlet.jsp.el.ELParseException;
import javax.servlet.jsp.el.Expression;
import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.FunctionMapper;
import javax.servlet.jsp.el.VariableResolver;
@Deprecated
public final class ExpressionEvaluatorImpl extends ExpressionEvaluator {
private final ExpressionFactory factory;
public ExpressionEvaluatorImpl(ExpressionFactory factory) {
this.factory = factory;
}
@Override
public Expression parseExpression(String expression,
@SuppressWarnings("rawtypes") Class expectedType,
FunctionMapper fMapper) throws ELException {
try {
ELContextImpl ctx =
new ELContextImpl(ELContextImpl.getDefaultResolver(factory));
if (fMapper != null) {
ctx.setFunctionMapper(new FunctionMapperImpl(fMapper));
}
ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType);
return new ExpressionImpl(ve, factory);
} catch (javax.el.ELException e) {
throw new ELParseException(e.getMessage());
}
}
@Override
public Object evaluate(String expression,
@SuppressWarnings("rawtypes") Class expectedType,
VariableResolver vResolver, FunctionMapper fMapper)
throws ELException {
return this.parseExpression(expression, expectedType, fMapper).evaluate(vResolver);
}
}

View File

@@ -0,0 +1,44 @@
/*
* 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.el;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.servlet.jsp.el.ELException;
import javax.servlet.jsp.el.Expression;
import javax.servlet.jsp.el.VariableResolver;
@Deprecated
public final class ExpressionImpl extends Expression {
private final ValueExpression ve;
private final ExpressionFactory factory;
public ExpressionImpl(ValueExpression ve, ExpressionFactory factory) {
this.ve = ve;
this.factory = factory;
}
@Override
public Object evaluate(VariableResolver vResolver) throws ELException {
ELContext ctx =
new ELContextImpl(new ELResolverImpl(vResolver, factory));
return ve.getValue(ctx);
}
}

View File

@@ -0,0 +1,37 @@
/*
* 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.el;
import java.lang.reflect.Method;
import javax.servlet.jsp.el.FunctionMapper;
@Deprecated
public final class FunctionMapperImpl extends javax.el.FunctionMapper {
private final FunctionMapper fnMapper;
public FunctionMapperImpl(FunctionMapper fnMapper) {
this.fnMapper = fnMapper;
}
@Override
public Method resolveFunction(String prefix, String localName) {
return this.fnMapper.resolveFunction(prefix, localName);
}
}

View File

@@ -0,0 +1,175 @@
/*
* 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.el;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.el.ArrayELResolver;
import javax.el.BeanELResolver;
import javax.el.CompositeELResolver;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.ListELResolver;
import javax.el.MapELResolver;
import javax.el.PropertyNotFoundException;
import javax.el.ResourceBundleELResolver;
import javax.el.StaticFieldELResolver;
import javax.servlet.jsp.el.ImplicitObjectELResolver;
import javax.servlet.jsp.el.ScopedAttributeELResolver;
/**
* Jasper-specific CompositeELResolver that optimizes certain functions to avoid
* unnecessary resolver calls.
*/
public class JasperELResolver extends CompositeELResolver {
private static final int STANDARD_RESOLVERS_COUNT = 9;
private AtomicInteger resolversSize = new AtomicInteger(0);
private volatile ELResolver[] resolvers;
private final int appResolversSize;
public JasperELResolver(List<ELResolver> appResolvers,
ELResolver streamResolver) {
appResolversSize = appResolvers.size();
resolvers = new ELResolver[appResolversSize + STANDARD_RESOLVERS_COUNT];
add(new ImplicitObjectELResolver());
for (ELResolver appResolver : appResolvers) {
add(appResolver);
}
add(streamResolver);
add(new StaticFieldELResolver());
add(new MapELResolver());
add(new ResourceBundleELResolver());
add(new ListELResolver());
add(new ArrayELResolver());
add(new BeanELResolver());
add(new ScopedAttributeELResolver());
}
@Override
public synchronized void add(ELResolver elResolver) {
super.add(elResolver);
int size = resolversSize.get();
if (resolvers.length > size) {
resolvers[size] = elResolver;
} else {
ELResolver[] nr = new ELResolver[size + 1];
System.arraycopy(resolvers, 0, nr, 0, size);
nr[size] = elResolver;
resolvers = nr;
}
resolversSize.incrementAndGet();
}
@Override
public Object getValue(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
context.setPropertyResolved(false);
int start;
Object result = null;
if (base == null) {
// call implicit and app resolvers
int index = 1 /* implicit */ + appResolversSize;
for (int i = 0; i < index; i++) {
result = resolvers[i].getValue(context, base, property);
if (context.isPropertyResolved()) {
return result;
}
}
// skip stream, static and collection-based resolvers (map,
// resource, list, array) and bean
start = index + 7;
} else {
// skip implicit resolver only
start = 1;
}
int size = resolversSize.get();
for (int i = start; i < size; i++) {
result = resolvers[i].getValue(context, base, property);
if (context.isPropertyResolved()) {
return result;
}
}
return null;
}
@Override
public Object invoke(ELContext context, Object base, Object method,
Class<?>[] paramTypes, Object[] params) {
String targetMethod = coerceToString(method);
if (targetMethod.length() == 0) {
throw new ELException(new NoSuchMethodException());
}
context.setPropertyResolved(false);
Object result = null;
// skip implicit and call app resolvers, stream resolver and static
// resolver
int index = 1 /* implicit */ + appResolversSize +
2 /* stream + static */;
for (int i = 1; i < index; i++) {
result = resolvers[i].invoke(
context, base, targetMethod, paramTypes, params);
if (context.isPropertyResolved()) {
return result;
}
}
// skip collection (map, resource, list, and array) resolvers
index += 4;
// call bean and the rest of resolvers
int size = resolversSize.get();
for (int i = index; i < size; i++) {
result = resolvers[i].invoke(
context, base, targetMethod, paramTypes, params);
if (context.isPropertyResolved()) {
return result;
}
}
return null;
}
/*
* Copied from org.apache.el.lang.ELSupport#coerceToString(ELContext,Object)
*/
private static final String coerceToString(final Object obj) {
if (obj == null) {
return "";
} else if (obj instanceof String) {
return (String) obj;
} else if (obj instanceof Enum<?>) {
return ((Enum<?>) obj).name();
} else {
return obj.toString();
}
}
}

View File

@@ -0,0 +1,28 @@
/*
* 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.el;
import javax.el.ELException;
public class JspELException extends ELException {
private static final long serialVersionUID = 1L;
public JspELException(String mark, ELException e) {
super(mark + " " + e.getMessage(), e.getCause());
}
}

View File

@@ -0,0 +1,122 @@
/*
* 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.el;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.MethodExpression;
import javax.el.MethodInfo;
import javax.el.MethodNotFoundException;
import javax.el.PropertyNotFoundException;
public final class JspMethodExpression extends MethodExpression implements
Externalizable {
private String mark;
private MethodExpression target;
public JspMethodExpression() {
super();
}
public JspMethodExpression(String mark, MethodExpression target) {
this.target = target;
this.mark = mark;
}
@Override
public MethodInfo getMethodInfo(ELContext context)
throws NullPointerException, PropertyNotFoundException,
MethodNotFoundException, ELException {
context.notifyBeforeEvaluation(getExpressionString());
try {
MethodInfo result = this.target.getMethodInfo(context);
context.notifyAfterEvaluation(getExpressionString());
return result;
} catch (MethodNotFoundException e) {
if (e instanceof JspMethodNotFoundException) throw e;
throw new JspMethodNotFoundException(this.mark, e);
} catch (PropertyNotFoundException e) {
if (e instanceof JspPropertyNotFoundException) throw e;
throw new JspPropertyNotFoundException(this.mark, e);
} catch (ELException e) {
if (e instanceof JspELException) throw e;
throw new JspELException(this.mark, e);
}
}
@Override
public Object invoke(ELContext context, Object[] params)
throws NullPointerException, PropertyNotFoundException,
MethodNotFoundException, ELException {
context.notifyBeforeEvaluation(getExpressionString());
try {
Object result = this.target.invoke(context, params);
context.notifyAfterEvaluation(getExpressionString());
return result;
} catch (MethodNotFoundException e) {
if (e instanceof JspMethodNotFoundException) throw e;
throw new JspMethodNotFoundException(this.mark, e);
} catch (PropertyNotFoundException e) {
if (e instanceof JspPropertyNotFoundException) throw e;
throw new JspPropertyNotFoundException(this.mark, e);
} catch (ELException e) {
if (e instanceof JspELException) throw e;
throw new JspELException(this.mark, e);
}
}
@Override
public boolean equals(Object obj) {
return this.target.equals(obj);
}
@Override
public int hashCode() {
return this.target.hashCode();
}
@Override
public String getExpressionString() {
return this.target.getExpressionString();
}
@Override
public boolean isLiteralText() {
return this.target.isLiteralText();
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(this.mark);
out.writeObject(this.target);
}
@Override
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
this.mark = in.readUTF();
this.target = (MethodExpression) in.readObject();
}
}

View File

@@ -0,0 +1,28 @@
/*
* 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.el;
import javax.el.MethodNotFoundException;
public class JspMethodNotFoundException extends MethodNotFoundException {
private static final long serialVersionUID = 1L;
public JspMethodNotFoundException(String mark, MethodNotFoundException e) {
super(mark + " " + e.getMessage(), e.getCause());
}
}

View File

@@ -0,0 +1,30 @@
/*
* 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.el;
import javax.el.PropertyNotFoundException;
public final class JspPropertyNotFoundException extends
PropertyNotFoundException {
private static final long serialVersionUID = 1L;
public JspPropertyNotFoundException(String mark, PropertyNotFoundException e) {
super(mark + " " + e.getMessage(), e.getCause());
}
}

View File

@@ -0,0 +1,29 @@
/*
* 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.el;
import javax.el.PropertyNotWritableException;
public class JspPropertyNotWritableException extends
PropertyNotWritableException {
private static final long serialVersionUID = 1L;
public JspPropertyNotWritableException(String mark, PropertyNotWritableException e) {
super(mark + " " + e.getMessage(), e.getCause());
}
}

View File

@@ -0,0 +1,159 @@
/*
* 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.el;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;
import javax.el.ValueExpression;
/**
* Wrapper for providing context to ValueExpressions
*
* @author Jacob Hookom
*/
public final class JspValueExpression extends ValueExpression implements
Externalizable {
private ValueExpression target;
private String mark;
public JspValueExpression() {
super();
}
public JspValueExpression(String mark, ValueExpression target) {
this.target = target;
this.mark = mark;
}
@Override
public Class<?> getExpectedType() {
return this.target.getExpectedType();
}
@Override
public Class<?> getType(ELContext context) throws NullPointerException,
PropertyNotFoundException, ELException {
context.notifyBeforeEvaluation(getExpressionString());
try {
Class<?> result = this.target.getType(context);
context.notifyAfterEvaluation(getExpressionString());
return result;
} catch (PropertyNotFoundException e) {
if (e instanceof JspPropertyNotFoundException) throw e;
throw new JspPropertyNotFoundException(this.mark, e);
} catch (ELException e) {
if (e instanceof JspELException) throw e;
throw new JspELException(this.mark, e);
}
}
@Override
public boolean isReadOnly(ELContext context) throws NullPointerException,
PropertyNotFoundException, ELException {
context.notifyBeforeEvaluation(getExpressionString());
try {
boolean result = this.target.isReadOnly(context);
context.notifyAfterEvaluation(getExpressionString());
return result;
} catch (PropertyNotFoundException e) {
if (e instanceof JspPropertyNotFoundException) throw e;
throw new JspPropertyNotFoundException(this.mark, e);
} catch (ELException e) {
if (e instanceof JspELException) throw e;
throw new JspELException(this.mark, e);
}
}
@Override
public void setValue(ELContext context, Object value)
throws NullPointerException, PropertyNotFoundException,
PropertyNotWritableException, ELException {
context.notifyBeforeEvaluation(getExpressionString());
try {
this.target.setValue(context, value);
context.notifyAfterEvaluation(getExpressionString());
} catch (PropertyNotWritableException e) {
if (e instanceof JspPropertyNotWritableException) throw e;
throw new JspPropertyNotWritableException(this.mark, e);
} catch (PropertyNotFoundException e) {
if (e instanceof JspPropertyNotFoundException) throw e;
throw new JspPropertyNotFoundException(this.mark, e);
} catch (ELException e) {
if (e instanceof JspELException) throw e;
throw new JspELException(this.mark, e);
}
}
@Override
public Object getValue(ELContext context) throws NullPointerException,
PropertyNotFoundException, ELException {
context.notifyBeforeEvaluation(getExpressionString());
try {
Object result = this.target.getValue(context);
context.notifyAfterEvaluation(getExpressionString());
return result;
} catch (PropertyNotFoundException e) {
if (e instanceof JspPropertyNotFoundException) throw e;
throw new JspPropertyNotFoundException(this.mark, e);
} catch (ELException e) {
if (e instanceof JspELException) throw e;
throw new JspELException(this.mark, e);
}
}
@Override
public boolean equals(Object obj) {
return this.target.equals(obj);
}
@Override
public int hashCode() {
return this.target.hashCode();
}
@Override
public String getExpressionString() {
return this.target.getExpressionString();
}
@Override
public boolean isLiteralText() {
return this.target.isLiteralText();
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(this.mark);
out.writeObject(this.target);
}
@Override
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
this.mark = in.readUTF();
this.target = (ValueExpression) in.readObject();
}
}

View File

@@ -0,0 +1,37 @@
/*
* 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.el;
import javax.el.ELContext;
import javax.servlet.jsp.el.ELException;
import javax.servlet.jsp.el.VariableResolver;
@Deprecated
public final class VariableResolverImpl implements VariableResolver {
private final ELContext ctx;
public VariableResolverImpl(ELContext ctx) {
this.ctx = ctx;
}
@Override
public Object resolveVariable(String pName) throws ELException {
return this.ctx.getELResolver().getValue(this.ctx, null, pName);
}
}