MAP | PageMixer Documents > Design note > Statefull filter |
This section explains the reason to design Filter
as statefull object.
In this document, abbreviated class names are used. Complete names are shown below.
Notation | Full 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 |
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.
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.
MAP | PageMixer Documents > Design note > Statefull filter |