Search in sources :

Example 1 with ImportedClassELResolver

use of org.wildfly.extension.undertow.ImportedClassELResolver in project wildfly by wildfly.

the class JspInitializationListener method contextInitialized.

@Override
public void contextInitialized(final ServletContextEvent sce) {
    // if the servlet version is 3.1 or higher, setup a ELResolver which allows usage of static fields java.lang.*
    final ServletContext servletContext = sce.getServletContext();
    final JspApplicationContext jspApplicationContext = JspFactory.getDefaultFactory().getJspApplicationContext(servletContext);
    if (servletContext.getEffectiveMajorVersion() >= 3 && servletContext.getEffectiveMinorVersion() >= 1) {
        jspApplicationContext.addELResolver(new ImportedClassELResolver());
    }
    // setup a wrapped JspApplicationContext if there are any EL expression factory wrappers for this servlet context
    final List<ExpressionFactoryWrapper> expressionFactoryWrappers = (List<ExpressionFactoryWrapper>) sce.getServletContext().getAttribute(CONTEXT_KEY);
    if (expressionFactoryWrappers != null && !expressionFactoryWrappers.isEmpty()) {
        final JspApplicationContextWrapper jspApplicationContextWrapper = new JspApplicationContextWrapper(JspApplicationContextImpl.getInstance(servletContext), expressionFactoryWrappers, sce.getServletContext());
        sce.getServletContext().setAttribute(JspApplicationContextImpl.class.getName(), jspApplicationContextWrapper);
    }
}
Also used : ImportedClassELResolver(org.wildfly.extension.undertow.ImportedClassELResolver) JspApplicationContext(javax.servlet.jsp.JspApplicationContext) JspApplicationContextImpl(org.apache.jasper.runtime.JspApplicationContextImpl) ExpressionFactoryWrapper(org.jboss.as.web.common.ExpressionFactoryWrapper) ServletContext(javax.servlet.ServletContext) List(java.util.List)

Aggregations

List (java.util.List)1 ServletContext (javax.servlet.ServletContext)1 JspApplicationContext (javax.servlet.jsp.JspApplicationContext)1 JspApplicationContextImpl (org.apache.jasper.runtime.JspApplicationContextImpl)1 ExpressionFactoryWrapper (org.jboss.as.web.common.ExpressionFactoryWrapper)1 ImportedClassELResolver (org.wildfly.extension.undertow.ImportedClassELResolver)1