From 7301eacc803673141c5664b85ba9d65e2ecd5057 Mon Sep 17 00:00:00 2001 From: Arjan Tijms Date: Fri, 8 Dec 2023 14:16:50 +0100 Subject: [PATCH 1/2] Initial support for Pages 4.0 M1 Signed-off-by: Arjan Tijms --- pom.xml | 10 +- .../wasp/runtime/ExpressionEvaluatorImpl.java | 181 ------------------ .../wasp/runtime/JspContextWrapper.java | 14 +- .../wasp/runtime/PageContextImpl.java | 18 +- .../wasp/runtime/VariableResolverImpl.java | 60 ------ 5 files changed, 7 insertions(+), 276 deletions(-) delete mode 100644 src/main/java/org/glassfish/wasp/runtime/ExpressionEvaluatorImpl.java delete mode 100644 src/main/java/org/glassfish/wasp/runtime/VariableResolverImpl.java diff --git a/pom.xml b/pom.xml index 7035362..2afe2df 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ org.eclipse.ee4j project - 1.0.8 + 1.0.9 org.glassfish.wasp wasp - 3.2.2-SNAPSHOT + 4.0.0-SNAPSHOT WaSP Eclipse compatible implementation of Jakarta Server Pages @@ -79,7 +79,7 @@ jakarta.servlet.jsp jakarta.servlet.jsp-api - 3.1.1 + 4.0.0-M1 provided @@ -91,13 +91,13 @@ jakarta.servlet jakarta.servlet-api - 6.0.0 + 6.1.0-M1 provided jakarta.el jakarta.el-api - 5.0.1 + 6.0.0-M1 provided diff --git a/src/main/java/org/glassfish/wasp/runtime/ExpressionEvaluatorImpl.java b/src/main/java/org/glassfish/wasp/runtime/ExpressionEvaluatorImpl.java deleted file mode 100644 index a70fca1..0000000 --- a/src/main/java/org/glassfish/wasp/runtime/ExpressionEvaluatorImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. - * Copyright 2004 The Apache Software Foundation - * - * Licensed 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.glassfish.wasp.runtime; - -import java.util.Iterator; - -import jakarta.el.ELContext; -import jakarta.el.ELResolver; -import jakarta.el.ExpressionFactory; -import jakarta.el.ValueExpression; -import jakarta.servlet.jsp.PageContext; -import jakarta.servlet.jsp.el.ELException; -import jakarta.servlet.jsp.el.Expression; -import jakarta.servlet.jsp.el.ExpressionEvaluator; -import jakarta.servlet.jsp.el.FunctionMapper; -import jakarta.servlet.jsp.el.VariableResolver; - -/** - *

- * This is the implementation of ExpreesioEvaluator using implementation of JSP2.1. - * - * @author Kin-man Chung - * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: kchung $ - */ - -public class ExpressionEvaluatorImpl extends ExpressionEvaluator { - private PageContext pageContext; - - // ------------------------------------- - /** - * Constructor - */ - public ExpressionEvaluatorImpl(PageContext pageContext) { - this.pageContext = pageContext; - } - - // ------------------------------------- - @Override - public Expression parseExpression(String expression, Class expectedType, FunctionMapper fMapper) throws ELException { - - ExpressionFactory fac = ExpressionFactory.newInstance(); - jakarta.el.ValueExpression expr; - ELContextImpl elContext = new ELContextImpl(null); - jakarta.el.FunctionMapper fm = new FunctionMapperWrapper(fMapper); - elContext.setFunctionMapper(fm); - try { - expr = fac.createValueExpression(elContext, expression, expectedType); - } catch (jakarta.el.ELException ex) { - throw new ELException(ex); - } - return new ExpressionImpl(expr, pageContext); - } - - @Override - public Object evaluate(String expression, Class expectedType, VariableResolver vResolver, FunctionMapper fMapper) throws ELException { - - ELContextImpl elContext; - if (vResolver instanceof VariableResolverImpl) { - elContext = (ELContextImpl) pageContext.getELContext(); - } else { - // The provided variable Resolver is a custom resolver, - // wrap it with a ELResolver - elContext = new ELContextImpl(new ELResolverWrapper(vResolver)); - } - - jakarta.el.FunctionMapper fm = new FunctionMapperWrapper(fMapper); - elContext.setFunctionMapper(fm); - ExpressionFactory fac = ExpressionFactory.newInstance(); - Object value; - try { - ValueExpression expr = fac.createValueExpression(elContext, expression, expectedType); - value = expr.getValue(elContext); - } catch (jakarta.el.ELException ex) { - throw new ELException(ex); - } - return value; - } - - static private class ExpressionImpl extends Expression { - - private ValueExpression valueExpr; - private PageContext pageContext; - - ExpressionImpl(ValueExpression valueExpr, PageContext pageContext) { - this.valueExpr = valueExpr; - this.pageContext = pageContext; - } - - @Override - public Object evaluate(VariableResolver vResolver) throws ELException { - - ELContext elContext; - if (vResolver instanceof VariableResolverImpl) { - elContext = pageContext.getELContext(); - } else { - // The provided variable Resolver is a custom resolver, - // wrap it with a ELResolver - elContext = new ELContextImpl(new ELResolverWrapper(vResolver)); - } - try { - return valueExpr.getValue(elContext); - } catch (jakarta.el.ELException ex) { - throw new ELException(ex); - } - } - } - - private static class FunctionMapperWrapper extends jakarta.el.FunctionMapper { - - private FunctionMapper mapper; - - FunctionMapperWrapper(FunctionMapper mapper) { - this.mapper = mapper; - } - - @Override - public java.lang.reflect.Method resolveFunction(String prefix, String localName) { - return mapper.resolveFunction(prefix, localName); - } - } - - private static class ELResolverWrapper extends ELResolver { - private VariableResolver vResolver; - - ELResolverWrapper(VariableResolver vResolver) { - this.vResolver = vResolver; - } - - @Override - public Object getValue(ELContext context, Object base, Object property) throws jakarta.el.ELException { - if (base == null) { - context.setPropertyResolved(true); - try { - return vResolver.resolveVariable(property.toString()); - } catch (ELException ex) { - throw new jakarta.el.ELException(ex); - } - } - return null; - } - - @Override - public Class getType(ELContext context, Object base, Object property) throws jakarta.el.ELException { - return null; - } - - @Override - public void setValue(ELContext context, Object base, Object property, Object value) throws jakarta.el.ELException { - } - - @Override - public boolean isReadOnly(ELContext context, Object base, Object property) throws jakarta.el.ELException { - return false; - } - - @Override - public Iterator getFeatureDescriptors(ELContext context, Object base) { - return null; - } - - @Override - public Class getCommonPropertyType(ELContext context, Object base) { - return null; - } - } -} diff --git a/src/main/java/org/glassfish/wasp/runtime/JspContextWrapper.java b/src/main/java/org/glassfish/wasp/runtime/JspContextWrapper.java index f134be2..9400b00 100644 --- a/src/main/java/org/glassfish/wasp/runtime/JspContextWrapper.java +++ b/src/main/java/org/glassfish/wasp/runtime/JspContextWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright 2004 The Apache Software Foundation * @@ -45,8 +45,6 @@ import jakarta.servlet.jsp.JspContext; import jakarta.servlet.jsp.JspWriter; import jakarta.servlet.jsp.PageContext; -import jakarta.servlet.jsp.el.ExpressionEvaluator; -import jakarta.servlet.jsp.el.VariableResolver; import jakarta.servlet.jsp.tagext.BodyContent; import jakarta.servlet.jsp.tagext.JspTag; @@ -329,11 +327,6 @@ public void include(String relativeUrlPath, boolean flush) throws ServletExcepti invokingJspCtxt.include(relativeUrlPath, flush); } - @Override - public VariableResolver getVariableResolver() { - return null; - } - @Override public BodyContent pushBody() { return invokingJspCtxt.pushBody(); @@ -349,11 +342,6 @@ public JspWriter popBody() { return invokingJspCtxt.popBody(); } - @Override - public ExpressionEvaluator getExpressionEvaluator() { - return invokingJspCtxt.getExpressionEvaluator(); - } - @Override public void handlePageException(Exception ex) throws IOException, ServletException { // Should never be called since handleException() called with a diff --git a/src/main/java/org/glassfish/wasp/runtime/PageContextImpl.java b/src/main/java/org/glassfish/wasp/runtime/PageContextImpl.java index 95d6d9d..2145f99 100644 --- a/src/main/java/org/glassfish/wasp/runtime/PageContextImpl.java +++ b/src/main/java/org/glassfish/wasp/runtime/PageContextImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright 2004 The Apache Software Foundation * @@ -64,12 +64,10 @@ import jakarta.servlet.jsp.JspFactory; import jakarta.servlet.jsp.JspWriter; import jakarta.servlet.jsp.PageContext; -import jakarta.servlet.jsp.el.ExpressionEvaluator; import jakarta.servlet.jsp.el.ImplicitObjectELResolver; import jakarta.servlet.jsp.el.ImportELResolver; import jakarta.servlet.jsp.el.NotFoundELResolver; import jakarta.servlet.jsp.el.ScopedAttributeELResolver; -import jakarta.servlet.jsp.el.VariableResolver; import jakarta.servlet.jsp.tagext.BodyContent; /** @@ -642,11 +640,6 @@ public void include(String relativeUrlPath, boolean flush) throws ServletExcepti JspRuntimeLibrary.include(request, response, relativeUrlPath, out, flush); } - @Override - public VariableResolver getVariableResolver() { - return new VariableResolverImpl(this); - } - private ELResolver getELResolver() { if (elResolver == null) { @@ -788,15 +781,6 @@ public JspWriter popBody() { return out; } - /** - * Provides programmatic access to the ExpressionEvaluator. The JSP Container must return a valid instance of an - * ExpressionEvaluator that can parse EL expressions. - */ - @Override - public ExpressionEvaluator getExpressionEvaluator() { - return new ExpressionEvaluatorImpl(this); - } - @Override public void handlePageException(Exception ex) throws IOException, ServletException { // Should never be called since handleException() called with a diff --git a/src/main/java/org/glassfish/wasp/runtime/VariableResolverImpl.java b/src/main/java/org/glassfish/wasp/runtime/VariableResolverImpl.java deleted file mode 100644 index c9ad315..0000000 --- a/src/main/java/org/glassfish/wasp/runtime/VariableResolverImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. - * Copyright 2004 The Apache Software Foundation - * - * Licensed 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.glassfish.wasp.runtime; - -import jakarta.el.ELContext; -import jakarta.el.ELResolver; -import jakarta.servlet.jsp.PageContext; -import jakarta.servlet.jsp.el.VariableResolver; - -/** - *

- * This is the implementation of VariableResolver in JSP 2.0, using ELResolver in JSP2.1. It looks up variable - * references in the PageContext, and also recognizes references to implicit objects. - * - * @author Kin-man Chung - * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: kchung $ - */ - -public class VariableResolverImpl implements VariableResolver { - private PageContext pageContext; - - // ------------------------------------- - /** - * Constructor - */ - public VariableResolverImpl(PageContext pageContext) { - this.pageContext = pageContext; - } - - // ------------------------------------- - /** - * Resolves the specified variable within the given context. Returns null if the variable is not found. - */ - @Override - public Object resolveVariable(String pName) throws jakarta.servlet.jsp.el.ELException { - - ELContext elContext = pageContext.getELContext(); - ELResolver elResolver = elContext.getELResolver(); - try { - return elResolver.getValue(elContext, null, pName); - } catch (jakarta.el.ELException ex) { - throw new jakarta.servlet.jsp.el.ELException(); - } - } -} From 329695ac1f0fa0e83ad8faaf29a013182a39b7ca Mon Sep 17 00:00:00 2001 From: Arjan Tijms Date: Fri, 8 Dec 2023 15:23:16 +0100 Subject: [PATCH 2/2] Updated JDK to 17 Also removed source 11 from javadoc, and the older options for doclint no. Signed-off-by: Arjan Tijms --- pom.xml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 2afe2df..1a53039 100644 --- a/pom.xml +++ b/pom.xml @@ -159,13 +159,13 @@ - + org.apache.maven.plugins maven-compiler-plugin 3.11.0 - 11 + 17 -Xlint:unchecked @@ -178,7 +178,7 @@ <_noimportjava>true - <_runee>JavaSE-11 + <_runee>JavaSE-17 org.glassfish.wasp org.glassfish.wasp.wasp org.glassfish.wasp.wasp @@ -321,16 +321,6 @@ jar - 11 - - -Xdoclint:none - - -Xdoclint:none - - -Xdoclint:none - - -Xdoclint:none - none false false