UI-Component Sets

Home » Wiki » MyFaces Core » MyFaces Core User Guide » Configuration of special features

ELResolver ordering

As with MyFaces core 2.0.2 (or 1.2.10) it is possible to change the predefined order or ELResolvers.

Standard order defined in the JSF 2.0 spec

  1. faces.ImplicitObjectELResolverForFaces
  2. faces.CompositeComponentAttributesELResolver
  3. el.CompositeELResolver (ELResolvers from faces-config and Application.addELResolver())
  4. faces.ManagedBeanELResolver
  5. faces.ResourceELResolver
  6. el.ResourceBundleELResolver
  7. faces.ResourceBundleELResolver
  8. el.MapELResolver
  9. el.ListELResolver
  10. el.ArrayELResolver
  11. el.BeanELResolver
  12. faces.ScopedAttributeELResolver

This order works great in every case, but is not always the fastest one, e.g. if you are using CDI, because the CDI-ELResolver will be called many times for the most trivial ELExpressions, because he is installed via the faces-config and thus comes pretty early.

Changing the order

To change this predefined order you can provide a java.util.Comparator<ELResolver> implementation which will be applied to the List of ELResolvers mentioned above.

To install the comparator you simply have to set a web.xml config parameter:

<context-param>
    <param-name>org.apache.myfaces.EL_RESOLVER_COMPARATOR</param-name>
    <param-value>com.acme.el.MyELResolverComparator</param-value>
</context-param>

Default implementations shipping with MyFaces core

MyFaces core already provides three implementations of java.util.Comparator<ELResolver>.

  • org.apache.myfaces.el.unified.OpenWebBeansELResolverComparator - optimized for Apache OpenWebBeans
  • org.apache.myfaces.el.unified.CustomFirstELResolverComparator - puts your custom ELResolvers to the first place
  • org.apache.myfaces.el.unified.CustomLastELResolverComparator - puts your custom ELResolvers to the last place

Optimizing Apache MyFaces + OpenWebBeans

To optimize the marriage of MyFaces and OpenWebBeans, you simply have to set the following config parameter:

<context-param>
    <param-name>org.apache.myfaces.EL_RESOLVER_COMPARATOR</param-name>
    <param-value>org.apache.myfaces.el.unified.OpenWebBeansELResolverComparator</param-value>
</context-param>

This moves the WebBeansELResolver almost to the last place in the ELResolver chain, thus improving the overall performance of ELExpression evaluations.


Links

Related issue in the JIRA: MYFACES-2873