Home of: [Atelier "FUJIGURUMA"] >> [PageMixer hosted by SourceForge.net]

SEE "For Readers of English Version",
or Japanese version of this page

Statefull filter

This section explains the reason to design Filter as statefull object.

Class names

In this document, abbreviated class names are used. Complete names are shown below.

NotationFull name
Filter jp.ne.dti.lares.foozy.pagemixer.mixer.Filter
Consumer jp.ne.dti.lares.foozy.pagemixer.mixer.Consumer
ConsumerContext jp.ne.dti.lares.foozy.pagemixer.mixer.ConsumerContext

Ordinary design

It is natural to design class as stateless to share one instance among other threads, because thread-safeness based on stateless is good for performance (one based on exclusive-lock is very expensive).

If you want stateless objects to behave contextually, you must specify context information or container of it to them at method invocations.

Decision in PageMixer

Storing own context depend informations into ConsumerContext can make Filter stateless.

But the decision about invocation of "Consumer#consume" makes the number of times to invoke it so much, it becomes over 500 times per Filter on a page for example, that getting context depend information from ConsumerContext costs more than creating numbers of Filter even though getting once dees not cost so.

So Filter is designed as statefull in PageMixser framework.