org.milyn.payload
Class JavaSource

java.lang.Object
  extended by org.milyn.payload.FilterSource
      extended by org.milyn.payload.JavaSource
All Implemented Interfaces:
Source

public class JavaSource
extends FilterSource

Java Filtration/Transformation Source.

Controlling Event Stream Generation

The Java Objects used to create this source can be used to generate a stream of SAX events, which can then be analysed by Smooks in the normal manner. Generation of the SAX event stream can also be turned off via the setEventStreamRequired(boolean) method, or by configuring the 'http://www.smooks.org/sax/features/generate-java-event-stream' feature on the reader in the Smoooks configuration as follows:
 <reader>
     <features>
         <setOff feature="http://www.smooks.org/sax/features/generate-java-event-stream" />
     </features>
 </reader>
 
Turning off event stream generation can make sense in many situations. In some use cases event stream generation may add no value and may just reduces performance e.g. where you simply wish to apply a template to the supplied Java Object(s).

Smooks must generate at least 1 event to which configured resources can be targeted (e.g. a templating resource). When event stream generation is turned off, Smooks simply generates what we call a "Null Source" document event. In XML, it could be represented as "<nullsource-document/>". So when event stream generation is turned off, simply target resources at "nullsource-document" or "#document".

Author:
tom.fennelly@gmail.com

Field Summary
static String FEATURE_GENERATE_EVENT_STREAM
           
 
Constructor Summary
JavaSource()
          Deprecated. Use any of the other constructors.
JavaSource(List<Object> sourceObjects)
          Construct a JavaSource from the supplied source object.
JavaSource(Object sourceObject)
          Construct a JavaSource from the supplied source object.
JavaSource(String objectName, Object sourceObject)
          Construct a JavaSource from the supplied source object.
 
Method Summary
 Map<String,Object> getBeans()
          Get the input bean map for the transform.
 List<Object> getSourceObjects()
          Get the source object list.
 boolean isEventStreamRequired()
          Is SAX event stream generation required for the processing of this JavaSource.
 void setBeans(Map<String,Object> beans)
          Set the input bean map for the transform.
 void setEventStreamRequired(boolean eventStreamRequired)
          Turn on/off SAX event stream generation for the processing of this JavaSource.
 
Methods inherited from class org.milyn.payload.FilterSource
getSource, getSystemId, setSource, setSystemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FEATURE_GENERATE_EVENT_STREAM

public static final String FEATURE_GENERATE_EVENT_STREAM
See Also:
Constant Field Values
Constructor Detail

JavaSource

public JavaSource()
Deprecated. Use any of the other constructors.

Default Contructor.


JavaSource

public JavaSource(Object sourceObject)
Construct a JavaSource from the supplied source object.

Parameters:
sourceObject - The source object.

JavaSource

public JavaSource(String objectName,
                  Object sourceObject)
Construct a JavaSource from the supplied source object.

Parameters:
objectName - The object name the sourceObject is known under
sourceObject - The source object.

JavaSource

public JavaSource(List<Object> sourceObjects)
Construct a JavaSource from the supplied source object.

Parameters:
sourceObjects - The source object list.
Method Detail

isEventStreamRequired

public boolean isEventStreamRequired()
Is SAX event stream generation required for the processing of this JavaSource.

Default is true.

Returns:
True if SAX event stream generation is required, otherwise false.

setEventStreamRequired

public void setEventStreamRequired(boolean eventStreamRequired)
Turn on/off SAX event stream generation for the processing of this JavaSource.

Parameters:
eventStreamRequired - True if SAX event stream generation is required, otherwise false.

getSourceObjects

public List<Object> getSourceObjects()
Get the source object list.

Returns:
The source object list.

getBeans

public Map<String,Object> getBeans()
Get the input bean map for the transform.

Returns:
The bean map.

setBeans

public void setBeans(Map<String,Object> beans)
Set the input bean map for the transform.

Parameters:
beans - The bean map.


Copyright © 2009. All Rights Reserved.