@Override protected AttributeEvaluatorFactory createAttributeEvaluatorFactory(ApplicationContext context, LocaleResolver resolver) { AttributeEvaluator evaluator; if (tilesElPresent && JspFactory.getDefaultFactory() != null) { evaluator = new TilesElActivator().createEvaluator(); } else { evaluator = new DirectAttributeEvaluator(); } return new BasicAttributeEvaluatorFactory(evaluator); } }
public synchronized static void init(ServletContext servletContext) { JspApplicationContext jac = JspFactory.getDefaultFactory().getJspApplicationContext(servletContext); if (jspApplicationContext != jac) { jspApplicationContext = jac; jspApplicationContext.addELResolver(new ModelRecordElResolver()); } }
@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.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); } }
public AttributeEvaluator createEvaluator() { ELAttributeEvaluator evaluator = new ELAttributeEvaluator(); evaluator.setExpressionFactory( JspFactory.getDefaultFactory().getJspApplicationContext(servletContext).getExpressionFactory()); evaluator.setResolver(new CompositeELResolverImpl()); return evaluator; } }
@Override protected AttributeEvaluatorFactory createAttributeEvaluatorFactory(ApplicationContext context, LocaleResolver resolver) { AttributeEvaluator evaluator; if (tilesElPresent && JspFactory.getDefaultFactory() != null) { evaluator = new TilesElActivator().createEvaluator(); } else { evaluator = new DirectAttributeEvaluator(); } return new BasicAttributeEvaluatorFactory(evaluator); } }
@Override public ExpressionFactory wrap(ExpressionFactory expressionFactory, ServletContext servletContext) { BeanManager beanManager = getBeanManager(); if(beanManager == null) { //this should never happen return expressionFactory; } // get JspApplicationContext. JspApplicationContext jspAppContext = JspFactory.getDefaultFactory().getJspApplicationContext( servletContext); // register compositeELResolver with JSP jspAppContext.addELResolver(beanManager.getELResolver()); jspAppContext.addELContextListener(Reflections.<ELContextListener>newInstance("org.jboss.weld.module.web.el.WeldELContextListener", getClass().getClassLoader())); return beanManager.wrapExpressionFactory(expressionFactory); }
@Override public ELContext getELContext() { if (elContext == null) { JspApplicationContext jspctx = JspFactory.getDefaultFactory().getJspApplicationContext(getServletContext()); if (jspctx instanceof FreeMarkerJspApplicationContext) { elContext = ((FreeMarkerJspApplicationContext) jspctx).createNewELContext(this); elContext.putContext(JspContext.class, this); } else { throw new UnsupportedOperationException( "Can not create an ELContext using a foreign JspApplicationContext (of class " + ClassUtil.getShortClassNameOfObject(jspctx) + ").\n" + "Hint: The cause of this is often that you are trying to use JSTL tags/functions in FTL. " + "In that case, know that that's not really suppored, and you are supposed to use FTL " + "constrcuts instead, like #list instead of JSTL's forEach, etc."); } } return elContext; } }
public AttributeEvaluator createEvaluator() { ELAttributeEvaluator evaluator = new ELAttributeEvaluator(); evaluator.setExpressionFactory( JspFactory.getDefaultFactory().getJspApplicationContext(servletContext).getExpressionFactory()); evaluator.setResolver(new CompositeELResolverImpl()); return evaluator; } }
@Override public void destroy() { if (wrapper != null && wrapper == JspFactory.getDefaultFactory()) { JspFactory.setDefaultFactory(defaultFactory); } }
/** * Return the JSP's ExpressionFactory. * * @param pageContext the context for the JSP * @return the ExpressionFactory to use for EL expressions in that JSP */ public static ExpressionFactory getExpressionFactory(PageContext pageContext) { JspApplicationContext appContext = JspFactory.getDefaultFactory().getJspApplicationContext(pageContext.getServletContext()); return appContext.getExpressionFactory(); }
public void contextInitialized(ServletContextEvent event) { // APF-1379: Prevent NPE when using Tomcat Maven Plugin try { Class.forName("org.apache.jasper.compiler.JspRuntimeContext"); } catch (ClassNotFoundException cnfe) { // ignore } JspFactory.getDefaultFactory() .getJspApplicationContext(event.getServletContext()) .addELResolver(new EscapeXmlELResolver()); }
/** * Convert an object to an expected type according to the conversion * rules of the Expression Language. */ private Object convertToExpectedType( final Object value, Class expectedType ) { JspFactory jspFactory = JspFactory.getDefaultFactory(); JspApplicationContext jspAppContext = jspFactory.getJspApplicationContext(pageContext.getServletContext()); ExpressionFactory exprFactory = jspAppContext.getExpressionFactory(); return exprFactory.coerceToType(value, expectedType); }
/** * Convert an object to an expected type according to the conversion * rules of the Expression Language. */ private Object convertToExpectedType( final Object value, Class expectedType ) { JspFactory jspFactory = JspFactory.getDefaultFactory(); JspApplicationContext jspAppContext = jspFactory.getJspApplicationContext(pageContext.getServletContext()); ExpressionFactory exprFactory = jspAppContext.getExpressionFactory(); return exprFactory.coerceToType(value, expectedType); }
/** * Convert an object to an expected type according to the conversion * rules of the Expression Language. */ private Object convertToExpectedType( final Object value, Class expectedType ) { JspFactory jspFactory = JspFactory.getDefaultFactory(); JspApplicationContext jspAppContext = jspFactory.getJspApplicationContext(pageContext.getServletContext()); ExpressionFactory exprFactory = jspAppContext.getExpressionFactory(); return exprFactory.coerceToType(value, expectedType); }
/** Creates an ExpressionFactory using the JspApplicationContext. */ protected ExpressionFactory getExpressionFactory() { ServletContext ctx = StripesFilter.getConfiguration().getServletContext(); JspApplicationContext jspCtx = JspFactory.getDefaultFactory().getJspApplicationContext(ctx); return jspCtx.getExpressionFactory(); } }
@Override public ELContext getELContext() { if (elContext == null) { elContext = new ELContextWrapper(rootJspCtxt.getELContext(), jspTag, this); JspFactory factory = JspFactory.getDefaultFactory(); JspApplicationContext jspAppCtxt = factory.getJspApplicationContext(servletContext); if (jspAppCtxt instanceof JspApplicationContextImpl) { ((JspApplicationContextImpl) jspAppCtxt).fireListeners(elContext); } } return elContext; }
@Override public ELContext getELContext() { if (elContext == null) { elContext = new ELContextWrapper(rootJspCtxt.getELContext(), jspTag, this); JspFactory factory = JspFactory.getDefaultFactory(); JspApplicationContext jspAppCtxt = factory.getJspApplicationContext(servletContext); if (jspAppCtxt instanceof JspApplicationContextImpl) { ((JspApplicationContextImpl) jspAppCtxt).fireListeners(elContext); } } return elContext; }
ValidateVisitor(Compiler compiler) { this.pageInfo = compiler.getPageInfo(); this.err = compiler.getErrorDispatcher(); this.loader = compiler.getCompilationContext().getClassLoader(); // Get the cached EL expression factory for this context expressionFactory = JspFactory.getDefaultFactory().getJspApplicationContext( compiler.getCompilationContext().getServletContext()). getExpressionFactory(); }
ValidateVisitor(Compiler compiler) { this.pageInfo = compiler.getPageInfo(); this.err = compiler.getErrorDispatcher(); this.loader = compiler.getCompilationContext().getClassLoader(); // Get the cached EL expression factory for this context expressionFactory = JspFactory.getDefaultFactory().getJspApplicationContext( compiler.getCompilationContext().getServletContext()). getExpressionFactory(); }
ValidateVisitor(Compiler compiler) { this.pageInfo = compiler.getPageInfo(); this.err = compiler.getErrorDispatcher(); this.loader = compiler.getCompilationContext().getClassLoader(); // Get the cached EL expression factory for this context expressionFactory = JspFactory.getDefaultFactory().getJspApplicationContext( compiler.getCompilationContext().getServletContext()). getExpressionFactory(); }