| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Integrating Castor with other (open source) projectsApache Cocoon A scenario Sitemap configuration Component definition Usage within a pipeline Gotchas References Apache CocoonApache Cocoon is a web publishing framework built around the concepts of separation of concerns and component-based web development. As part of this framework, Cocoon provides a component, the CastorTransformer, that marshalls an object hierarchy (for which a mapping file or a class descriptor hierarchy exists) to XML and inserts it as a stream of SAX events into a Cocoon pipeline. Further information on the integration of Apche Cocoon and Castor can be found here. A scenarioLet's imagine the listed derivative department of an investment bank wants to display details of a derivative holding to the client. With the use of some 'magic', the information required to render this information is already stored in the (Http)Request object, where it is bound to an attribute with the name 'position'. The following code fragment (stored in a separate XML file named position.xml)
will instruct the CastorTransformer to look for an object (hierarchy) bound to a (Http)Request attribute with the name 'position', and marshall its current state to XML. Sitemap configurationComponent definitionAs with all components in Cocoon, before the CastorTransformer can be used, it needs to be defined, i.e. its existence needs to be communicated to Cocoon. This is generally achieved by adding the relevant entries to the <component> section of the sitemap. As with all transformers, the CastorTransformer definition
needs to go into the
This definition registers the CastorTransformer with Cocoon under the logical name 'castor', which will be used in pipeline declarations to specify that this very transformer shall be used. Usage within a pipelineTo use the CastorTransformer within a pipeline to insert the XML representation of an arbitrary object hierarchy into the pipeline, please specify a pipeline entry similar to the following pipeline definition:
This instructs Cocoon to
Gotchas
References
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||