Plugin JUEL
A recent addition to javax.el.ExpressionFactory have been the static methods newInstance() and newInstance(java.util.Properties).
With these methods, selection of a particular EL implementation is completely transparent to the application code. E.g., the first line of our Quickstart example could be rewritten as
ExpressionFactory factory = ExpressionFactory.newInstance();
Either of the new methods will determine a factory implementation class and create an instance of it. The first variant will use its default constructor. The latter will use a constructor taking a single java.util.Properties object as parameter. The lookup procedure uses the Service Provider API as detailed in the JAR specification.
The juel-spi-2.2.x.jar does the trick: if on your classpath, the lookup procedure will detect de.odysseus.el.ExpressionFactoryImpl as service provider class.
This way, JUEL can be used without code references to any of its implementation specific classes. Just javax.el.*...
Depending on your application's scenario, there may be several ways to register JUEL as default EL implementation.
- Place the JUEL JARs into directory JRE_HOME/lib/ext. This will make JUEL available globally for all applications running in that environment.
- You may simply drop juel-impl-2.2.x.jar and juel-spi-2.2.x.jar into your /WEB-INF/lib directory. This will result in using JUEL as EL implementation for that particular web application.
- Of course you can also add the jar files to your classpath manually.
Please refer to the section on Factory Configuration on how to configure an expression factory via property files.