New issue

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

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

Already on GitHub? Sign in to your account

[MAJOR FEAT] New event-based template processing engine #389

Closed
danielfernandez opened this Issue Sep 12, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@danielfernandez
Member

danielfernandez commented Sep 12, 2015

Thymeleaf 3.0 builds around a completely new template processing engine, codenamed aurora, developed with the aim of improving its execution performance and reducing its memory footprint, especially in scenarios that were heavily penalized until 2.1 like the generation of big amounts of output markup as a consequence of the execution of iterations on very large collections.

In order to achieve these goals, Thymeleaf 3.0 abandons most of its DOM-oriented processing mechanisms and turns into an event-based template processor that responds to template parser/cache events by processing the template markup or text and immediately producing its output, even before new events coming from input for the same template are processed. This results in streamlined processing, much more efficient than the Thymeleaf 2.1 processing architecture which required each of the phases --1. parsing, 2. processing, 3. output-- to be completely finished before the next phase could even start.

aurora-01

The central component of this new processing engine will be the org.thymeleaf.engine.ITemplateHandler interface, which will be implemented by every step in the processing chain and will define the model of available events on which the template processors will be applied.

The event model

The new event model in Thymeleaf 3.0 is defined by a series of interfaces at the org.thymeleaf.model package.

There are 11 interfaces modeling the basic template events, all extendig (at different depth levels) the ITemplateEvent interface:

Also, there are 3 interfaces that allow working on groups of events, a.k.a. models:

  • IModel which defines a sequence of events, either generated during parsing/processing or programmatically by any dialect's processors. IModels are the closest way of representing what Thymeleaf 2.1 would have treated as a template's DOM trees or subtrees, only IModels are not trees are such, but sequences of events.
  • IModelFactory which defines factory objects that allow the creation of new events or entire models during the execution of processors.
  • IModelVisitor which allows the definition of visitors that traverse entire models in order to perform any operations needed by processors, following to the visitor pattern.

Taking into consideration the existence of these IModels, we can now have a more accurate look at the architecture diagram:

aurora-02

From the diagram above we can see how Thymeleaf 3.0 allows the creation of processors (grouped in dialects as usual), executed in the template processing phase, that act both on specific events (single ITemplateEvent instances) or on complete gathered models (IModel instances containing sequences of ITemplateEvent events which output has being delayed in order to allow for processing first).

@danielfernandez

This comment has been minimized.

Show comment
Hide comment
@danielfernandez

danielfernandez Sep 12, 2015

Member

Already in 3.0.0-SNAPSHOT

Member

danielfernandez commented Sep 12, 2015

Already in 3.0.0-SNAPSHOT

@willdavidwarren

This comment has been minimized.

Show comment
Hide comment
@willdavidwarren

willdavidwarren Sep 15, 2015

This is amazing @danielfernandez - really looking forward to 3.0!

willdavidwarren commented Sep 15, 2015

This is amazing @danielfernandez - really looking forward to 3.0!

@fahimmm

This comment has been minimized.

Show comment
Hide comment
@fahimmm

fahimmm Mar 4, 2016

Are there any performance stats or comparisons between thymeleaf 2.x and 3.0?

fahimmm commented Mar 4, 2016

Are there any performance stats or comparisons between thymeleaf 2.x and 3.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment