Jumpi v1.2.0

org.jumpi.spi.component
Interface Transformer

All Superinterfaces:
Component, Configurable, Manageable
All Known Implementing Classes:
AbstractTransformer

public interface Transformer
extends Component

The Transformer interface is implemented by instances which perform data transformation, ( formatting or conversion etc). The following are examples of Transformers, as well as their respective reverse functions.

A Transformer modifies the provided Envelope's context stack. The caller is reponsible for setting up the Envelope's context stack for the formatter. A formatter takes its required data from the Envelope via Envelope.popContext() and places its resulting modified data back with Envelope.pushContext(java.lang.Object). There is no requirement that any data taken is put back in the context. A Transformers responsibility is simply conversion or formatting of data.

The caller is responsible for managing synchronization. If a Transformer is single threaded ( not safe for multi-threaded access ), then the caller must make sure that only one thread is calling format at once. This synchronization cannot be solved at the Transformer itself, particularly if shared data is accessed via the context stack. Consider a caller placing a singleton shared buffer onto the context stack such that the formatter can place the results of conversion into it. If multiple formatters work simultaneously, then the output data would be corrupted in the buffer. Therefore synchronization must be managed by the caller.

Formatters are both Jump Components. A complex Transformer may itself use other Transformers which are child Components.


Method Summary
 void transform(Envelope env)
          Perform transformation of data on an Envelope's context stack.
 
Methods inherited from interface org.jumpi.spi.Configurable
configure, getName
 
Methods inherited from interface org.jumpi.spi.Manageable
manage
 

Method Detail

transform

public void transform(Envelope env)
               throws java.lang.Exception
Perform transformation of data on an Envelope's context stack. Use Envelope.popContext() to retrieve input data, and push results back to the context via Envelope.pushContext(). Synchronization is a responsibility of the caller.

Parameters:
env - the Envelope to format context data from.
Throws:
java.lang.Exception - when transformation is not successful.

Jumpi v1.2.0

Copyright 2003, Peter Jonathan Klauser.