As a Smooks application developer, I want a general way to define
multiple pipelines (i.e., segregated visitor chains) in a given
execution and direct their output to different streams, including the
execution output stream. For example, we could have pipeline
A processing fragment
X and streams the output to the filesystem. We could then have pipeline
B that also processes fragment
X but streams the output to a network socket. Both pipelines
A and
B are working on separate copies of fragment
X. Transformations to fragment
X will only be visible to the pipeline which made the transformations. In other words, pipeline
B transformations are visible to pipeline B visitors but invisible to pipeline A whereas pipeline
A
transformations are visible to pipeline A visitors but invisible to pipeline B. Furthermore, visitors
outside the pipelines won't see either of the pipeline transformations.
The
above behaviour is already supported to a certain extent in the
Template cartridge. The FreeMarker visitor can either:
- Direct its
output to a stream distinct from the execution output stream
- Bind
the output to a Java bean, or
- Write the output to the execution
output stream.
I'm proposing that we generalise and extend this
behaviour to all the visitors. This can be done without needing to
create new primitives. Smooks itself is a pipeline so all we require is the
ability run instances of Smooks within a Smooks execution in order to
mimic pipelines. The idea of nesting Smooks is not a new one because
there is an
existing implementation
of it in Smooks 1.7.1. However, I suspect it's still a prototype since it
isn't at all documented and has several constraints like being limited
to run only a single instance of
NestedExecutionVisitor in a Smooks execution.
From
an XML API perspective, the nested Smooks visitor configuration should
be composed of two parts: (a) the action applied on the output (e.g.,
directing the output to a stream different than the execution output
stream ), and (b) the visitor chain which is essentially the smooks-resource-list of the nested Smooks:
<smooks-resource-list xmlns="https://www.smooks.org/xsd/smooks-2.0.xsd"
xmlns:core="https://www.smooks.org/xsd/smooks/smooks-core-1.6.xsd">
...
...
<core:smooks filterSourceOn="a">
<core:action>
<core:outputTo outputStreamResource="MyStream"/>
</core:action>
<core:visit>
<smooks-resource-list>
<resource-config selector="a">
<resource>org.smooks.visitors.smooks.BarVisitor</resource>
</resource-config>
<resource-config selector="c">
<resource>org.smooks.visitors.smooks.QuxVisitor</resource>
</resource-config>
<resource-config selector="d">
<resource>org.smooks.visitors.smooks.QuuzVisitor</resource>
</resource-config>
</smooks-resource-list>
</core:visit>
</core:smooks>
...
...
</smooks-resource-list>
I welcome any thoughts on ways to improve this.
Claude