Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Configure SpringEL compiler #95

Closed
danielfernandez opened this issue Nov 25, 2015 · 3 comments
Closed

Configure SpringEL compiler #95

danielfernandez opened this issue Nov 25, 2015 · 3 comments

Comments

@danielfernandez
Copy link
Member

Spring will include compilation of expressions based on MapAccessor in version 4.2.4 (see https://jira.spring.io/browse/SPR-13638 ), so it seems like a good idea to add some way to enable the SpelCompiler for SpringEL expressions if Spring version is >= 4.2. First preliminary results show a 35% performance increase in some thymeleaf benchmarks thanks to the use of this expression compiler.

See http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html#expressions-spel-compilation

The SpelCompiler appeared in 4.1, but it's not until 4.2 that the same expressions can be used safely for different types of data without exceptions being issued, so it is 4.2 the version of Spring we should be aiming for. Also, it might be sensible to keep the compiler disabled by default for now (though this will depend on some additional testing), and have its activation depend on some kind of configuration property in SpringStandardDialect.

@danielfernandez
Copy link
Member Author

This has been implemented as a flag at both the SpringStandardDialect and the SpringTemplateEngine classes.

The SpringEL compiler will be disabled by default, but it will be easy to enable just by setting this flag:

final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setEnableSpringELCompiler(true);

Internally, enabling this flag will set the SpelCompilerMode to IMMEDIATE.

@danielfernandez
Copy link
Member Author

Already in 3.0.0-SNAPSHOT

@danielfernandez
Copy link
Member Author

Also note that, in order for most Thymeleaf expressions to be able to properly benefit from the SpEL compiler, version 4.2.4 (at least) of the Spring Framework is required.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant