[smooks-dev] [65] trunk/core/src/main/java/org/milyn/smooks/mule: - Wrote some Javadoc

View: New views
1 Messages — Rating Filter:   Alert me  

[smooks-dev] [65] trunk/core/src/main/java/org/milyn/smooks/mule: - Wrote some Javadoc

by mzeijen :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
[65] trunk/core/src/main/java/org/milyn/smooks/mule: - Wrote some Javadoc

Diff

Modified: trunk/core/src/main/java/org/milyn/smooks/mule/MuleDispatcher.java (64 => 65)

--- trunk/core/src/main/java/org/milyn/smooks/mule/MuleDispatcher.java	2008-07-24 09:23:13 UTC (rev 64)
+++ trunk/core/src/main/java/org/milyn/smooks/mule/MuleDispatcher.java	2008-07-24 15:00:14 UTC (rev 65)
@@ -48,9 +48,81 @@
 import org.w3c.dom.NodeList;
 
 /**
+ * The MuleDispatcher is a Smooks Resource visitor to dispatch message
+ * parts to endpoints in Mule.
+ * <p/>
+ * <h3>Usage:</h3>
+ * A MuleDispatcher is defined as follows:
+ * <pre>
+ * &lt;resource-config selector="order"&gt;
+ *     &lt;resource&gt;org.milyn.smooks.mule.MuleDispatcher&lt;/resource&gt;
+ *     &lt;param name="endpointName"&gt;order&lt;/param&gt;
+ *     &lt;param name="beanId"&gt;order&lt;/param&gt;
+ * &lt;/resource-config&gt;
+ * </pre>
  *
+ * <b>Required parameters:</b>
+ * &lt;property name="endpointName" value="someEndpoint" /&gt;
+ *
+ * <b>Optional parameters:</b>
+ * &lt;param name="beanId"&gt;someBeanId&lt;/param&gt;
+ * &lt;param name="resultBeanId"&gt;someBeanIdToBindTheResultTo&lt;/param&gt;
+ * &lt;param name="messagePropertiesBeanId"&gt;someBeanIdToGetTheMessagePropertiesFrom&lt;/param&gt;
+ * &lt;param name="messageProperties" &gt;
+ *     &lt;property name="somePropertyName" value="somePropertyValue" type="someType" /&gt;
+ * &lt;/param&gt;
+ * </pre>
+ *
+ * <h3>Description of configuration parameters</h3>
+ * <ul>
+ * <li><i>endpointName</i> - The name of the endpoint which will be used when routing the message. If no endpoint can be found under that name then an exception is thrown.
+ * <li><i>beanId</i> - The bean id of the bean which will be used as the message payload.
+ * <li><i>resultBeanId</i> - If the endpoint returns a result then the payload of that result is bounded to the resultBeanId.
+ * 							 When the resultBeanId isn't set then the result is discarded. If the resultBeanId is set then the
+ * 							 endpoint is forced to distpatch synchronous.
+ * <li><i>messagePropertiesBeanId</i> - Properties that will be set on the message before dispatching.
+ * 										The MuleDispatcher messageProperties attribute section explains how to set the message properties
+ * <li><i>messageProperties</i> - if true, non serializable attributes from the Smooks ExecutionContext will no be included. Default is true.
+ * </ul>
+ *
+ * <h3>MuleDispatcher messageProperties attribute</h3>
+ * Message properties are defined as folows:
+ * <pre>
+ * &lt;resource-config selector="order"&gt;
+ *     &lt;resource&gt;org.milyn.smooks.mule.MuleDispatcher&lt;/resource&gt;
+ *     &lt;param name="endpointName"&gt;testEndpoint&lt;/param&gt;
+ *     &lt;param name="beanId"&gt;test&lt;/param&gt;
+ *     &lt;param name="messageProperties"&gt;
+ *         &lt;property name="prop1" value="prop1Value" /&gt;
+ *         &lt;property name="prop2"&gt;prop2Value&lt;/property&gt;
+ *         &lt;property name="intProp" value="10" type="Integer" /&gt;
+ *         &lt;property name="dateProp" value="2008-07-11 12:30:56" type="DateTime" /&gt;
+ *     &lt;/param&gt;
+ * &lt;/resource-config&gt;
+ *
+ * &lt;resource-config selector="decoder:DateTime"&gt;
+ *    &lt;resource&gt;org.milyn.javabean.decoders.DateDecoder&lt;/resource&gt;
+ *    &lt;param name="format"&gt;yyyy-MM-dd HH:mm:ss&lt;/param&gt;
+ * &lt;/resource-config&gt;
+ * </pre>
+ *
+ * The following points explain the four properties:
+ * <ol>
+ * <li>The first property uses a attribute to set the value.
+ * <li>The second property uses the property element content to set the value.
+ * <li>The third property uses the type attribute to define a Integer type. This will convert the value into an Integer. This uses the standard DataDecoder feature from Smooks.
+ * <li>The fourth property uses the type attribute to define a custom configured Date type. This will convert the value into a Date. The configuration is set in the resource-config with the "decoder:DateTime" selector. This uses the standard DataDecoder feature from Smooks.
+ * </ol>
+ *
+ * <h3>Description of property attributes</h3>
+ * <ul>
+ * <li><i>name</i> - The message property name (required)
+ * <li><i>value</i> - 	 The value of the property. The property element content can also be set. If both are set then the value attribute is used.
+ * <li><i>type</i> - The type of the property value. This uses the standard DataDecoder feature from Smooks. DataDecoders can be configured using
+ * 					 a "decoder:decoderName" resource-config selector. The decoderName must be set as type then. (Default: String)
+ * </ul>
+ *
  * @author <a href="mailto:maurice@...">Maurice Zeijen</a>
- *
  */
 @VisitBeforeIf(condition = "parameters.containsKey('executeBefore') && parameters.executeBefore.value == 'true'")
 @VisitAfterIf(condition = "!parameters.containsKey('executeBefore') || parameters.executeBefore.value != 'true'")
@@ -58,6 +130,16 @@
 @VisitAfterReport(summary = "Dispatch to endpoint '${resource.parameters.endpointName}'.", detailTemplate = "reporting/MuleDispatcher.html")
 public class MuleDispatcher implements DOMElementVisitor, SAXVisitBefore, SAXVisitAfter {
 
+	private static final String MESSAGE_PROPERTIES_PARAMETER_TYPE = "type";
+
+	private static final String MESSAGE_PROPERTIES_PARAMETER_VALUE = "value";
+
+	private static final String MESSAGE_PROPERTIES_ATTRIBUTE_NAME = "name";
+
+	private static final String MESSAGE_PROPERTIES_NODE_NAME = "property";
+
+	private static final String PARAMETER_MESSAGE_PROPERTIES = "messageProperties";
+
 	private static final Logger log = LoggerFactory.getLogger(MuleDispatcher.class);
 
 	@ConfigParam(use=Use.REQUIRED)
@@ -77,24 +159,40 @@
 	@Config
     private SmooksResourceConfiguration config;
 
-
+	/**
+	 * {@inheritDoc}
+	 */
 	public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException {
 		dispatch(executionContext);
 	}
 
+	/**
+	 * {@inheritDoc}
+	 */
 	public void visitBefore(SAXElement element,	ExecutionContext executionContext) throws SmooksException,	IOException {
 
 		dispatch(executionContext);
 	}
 
+	/**
+	 * {@inheritDoc}
+	 */
 	public void visitAfter(Element element, ExecutionContext executionContext)	throws SmooksException {
 		dispatch(executionContext);
 	}
 
+	/**
+	 * {@inheritDoc}
+	 */
 	public void visitAfter(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException {
 		dispatch(executionContext);
 	}
 
+	/**
+	 * Dispatches a message to an endpoint
+	 *
+	 * @param executionContext
+	 */
 	private void dispatch(ExecutionContext executionContext) {
 		Object payload = null;
 		if(beanId != null) {
@@ -131,6 +229,13 @@
 		}
 	}
 
+	/**
+	 * Creates the message properties map from the static message properties and the possible
+	 * properties from the Map found under the messageProperties bean Id.
+	 *
+	 * @param executionContext
+	 * @return
+	 */
 	@SuppressWarnings("unchecked")
 	private Map<String, Object> createMessagePropertiesMap(ExecutionContext executionContext) {
 
@@ -151,30 +256,38 @@
 
 	}
 
+	/**
+	 * Processes the static message properties.
+	 * Because these are static it is only done the first time. From that point on
+	 * a cached result is used.
+	 *
+	 * @param executionContext
+	 * @return
+	 */
 	private HashMap<String, Object> getStaticMessageProperties(ExecutionContext executionContext) {
 
 		if(staticMessageProperties == null) {
 			HashMap<String, Object> lMessageProperties = new HashMap<String, Object>();
 
-			Parameter messagePropertiesParam = config.getParameter("messageProperties");
+			Parameter messagePropertiesParam = config.getParameter(PARAMETER_MESSAGE_PROPERTIES);
 
 	        if (messagePropertiesParam != null) {
 	            Element messagePropertiesParamElement = messagePropertiesParam.getXml();
 
 	            if(messagePropertiesParamElement != null) {
-	                NodeList properties = messagePropertiesParamElement.getElementsByTagName("property");
+	                NodeList properties = messagePropertiesParamElement.getElementsByTagName(MESSAGE_PROPERTIES_NODE_NAME);
 
                     for (int i = 0; properties != null && i < properties.getLength(); i++) {
                     	Element node = (Element)properties.item(i);
 
-                    	String name = DomUtils.getAttributeValue(node, "name");
+                    	String name = DomUtils.getAttributeValue(node, MESSAGE_PROPERTIES_ATTRIBUTE_NAME);
 
                     	if(StringUtils.isBlank(name)) {
                     		throw new SmooksConfigurationException("The 'name' attribute isn't a defined or empty for the message property: " + node);
                     	}
                     	name = name.trim();
 
-                    	String rawValue = DomUtils.getAttributeValue(node, "value");
+                    	String rawValue = DomUtils.getAttributeValue(node, MESSAGE_PROPERTIES_PARAMETER_VALUE);
                     	if(rawValue == null) {
                     		rawValue = DomUtils.getAllText(node, true);
                     		if(StringUtils.isBlank(rawValue)) {
@@ -188,7 +301,7 @@
 
                     		DataDecoder dataDecoder = null;
 
-                        	String type = DomUtils.getAttributeValue(node, "type");
+                        	String type = DomUtils.getAttributeValue(node, MESSAGE_PROPERTIES_PARAMETER_TYPE);
                         	if(type != null) {
                         		type = type.trim();
 
@@ -214,6 +327,14 @@
 		return staticMessageProperties;
 	}
 
+	/**
+	 * Retrieves the decoder of a certain type.
+	 *
+	 * @param executionContext
+	 * @param type
+	 * @return
+	 * @throws DataDecodeException
+	 */
 	private DataDecoder getDecoder(ExecutionContext executionContext, String type) throws DataDecodeException {
 		@SuppressWarnings("unchecked")
 		List<DataDecoder> decoders = executionContext.getDeliveryConfig().getObjects("decoder:" + type);

Modified: trunk/mule1/core/src/main/java/org/milyn/smooks/mule/NamedOutboundEndpointMuleDispatcher.java (64 => 65)

--- trunk/mule1/core/src/main/java/org/milyn/smooks/mule/NamedOutboundEndpointMuleDispatcher.java	2008-07-24 09:23:13 UTC (rev 64)
+++ trunk/mule1/core/src/main/java/org/milyn/smooks/mule/NamedOutboundEndpointMuleDispatcher.java	2008-07-24 15:00:14 UTC (rev 65)
@@ -29,6 +29,8 @@
 import org.mule.umo.routing.CouldNotRouteOutboundMessageException;
 
 /**
+ * This is the Mule 2.x implementation of the NamedEndpointMuleDispatcher. It
+ * is used by the Smook {@link MuleDispatcher} to actually dispatch a message.
  *
  * @author <a href="mailto:maurice@...">Maurice Zeijen</a>
  */

Modified: trunk/mule1/core/src/main/java/org/milyn/smooks/mule/Router.java (64 => 65)

--- trunk/mule1/core/src/main/java/org/milyn/smooks/mule/Router.java	2008-07-24 09:23:13 UTC (rev 64)
+++ trunk/mule1/core/src/main/java/org/milyn/smooks/mule/Router.java	2008-07-24 15:00:14 UTC (rev 65)
@@ -16,7 +16,7 @@
 
 package org.milyn.smooks.mule;
 
-import static org.mule.config.i18n.MessageFactory.*;
+import static org.mule.config.i18n.MessageFactory.createStaticMessage;
 
 import java.io.IOException;
 import java.util.HashMap;
@@ -39,8 +39,79 @@
 import org.xml.sax.SAXException;
 
 /**
+ * The Router intended to be used with the Mule ESB.
+ * <p/>
+ * <h3>Usage:</h3>
+ * Declare the router in the Mule configuration file:
+ * <pre>
+ * &lt;outbound-router&gt;
+ *      &lt;router className="org.milyn.smooks.mule.Router"&gt;
+ *      	&lt;endpoint name="order" address="jms://order.queue"/&gt;
+ *      	&lt;endpoint name="order-important" address="jms://order.important.queue"/&gt;
+ *       	&lt;properties&gt;
+ *       		&lt;property name="configFile" value="/router-smooks-config.xml" /&gt;
+ *       	&lt;/properties&gt;
+ *      &lt;/router&gt;
+ * &lt;/outbound-router&gt;
  *
+ * <b>Required properties:</b>
+ * &lt;property name="configFile" value="smooks-config.xml" /&gt;
+ *
+ * <b>Optional properties:</b>
+ * &lt;property name="resultType" value="STRING" /&gt;
+ * &lt;property name="reportPath" value="/tmp/smooks-report.html" /&gt;
+ * &lt;property name="executionContextAsMessageProperty" value="false" /&gt;
+ * &lt;property name="executionContextMessagePropertyKey" value="SmooksExecutionContext" /&gt;
+ * &lt;property name="excludeNonSerializables" value="false" /&gt;
+ * </pre>
+ *
+ * <h3>Description of configuration properties</h3>
+ * <ul>
+ * <li><i>configFile</i> - the Smooks configuration file. Can be a path on the file system or on the classpath.
+ * <li><i>reportPath</i> - specifies the path and file name for generating a Smooks Execution Report.  This is a development tool.
+ * <li><i>executionContextAsMessageProperty</i> - If set to "true" then the attributes map of the Smooks execution context is added to the message
+ * 												  properties of every message that gets created by this router. The property key is defined with
+ * 												  the executionContextMessagePropertyKey property. Default is "false"
+ * <li><i>executionContextMessagePropertyKey</i> - The property key under which the execution context is put. Default is "SmooksExecutionContext"
+ * <li><i>excludeNonSerializables</i> - if true, non serializable attributes from the Smooks ExecutionContext will no be included. Default is true.
+ * </ul>
+ *
+ * <h3>Defining Endpoints</h3>
+ * As normal with Mule router you must at least define one endpoint to route the messages to. For this router it is
+ * also required that you define the name of the router. That name is used as reference within the Smooks configuration
+ * so that it knows which endpoint to use.
+ *
+ * <h3>Using the Smooks MuleDispatcher</h3>
+ * Within the Smooks Router the {@link org.milyn.smooks.mule.MuleDispatcher} resource is used to actually route the message parts
+ * to one of the defined endpoints (using the endpoint name). The following example demonstrates how to configure a MuleDispatcher:
+ *
+ * <pre>
+ * &lt;resource-config selector="order"&gt;
+ * 	&lt;resource&gt;org.milyn.smooks.mule.MuleDispatcher&lt;/resource&gt;
+ * 	&lt;param name="endpointName"&gt;orderEndpoint&lt;/param&gt;
+ * 	&lt;param name="beanId"&gt;orderBean&lt;/param&gt;
+ * &lt;/resource-config&gt;
+ * </pre>
+ *
+ * In this example Smooks calls the {@link MuleDispatcher} when it is in the visit after phase of the "order" element. The {@link MuleDispatcher}
+ * creates a new Mule message and it will use the object found under the beanId "orderBean" in the Smooks BeanMap as it's payload. It
+ * then dispatches that message to the endpoint with the name "orderEndpoint".
+ * <p/>
+ * More information on the configuration options of the {@link MuleDispatcher} can be found in the javadoc of the {@link MuleDispatcher} itself.
+ *
+ * <h3>Accessing Smooks ExecutionContext attributes</h3>
+ * When the {@link MuleDispatcher} dispatches a message and if the "executionContextAsMessageProperty" property
+ * is set to <code>true</code> then the MuleDispatcher will make the attributes that have been set in the
+ * ExecutionContext at that moment available for other actions in the Mule ESB by setting the attributes map as a property of the message.
+ * The attributes can be accessed by using the key defined under the property "executionContextMessagePropertyKey". Default
+ * "SmooksExecutionContext" is used, which is set under the constant {@link #MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT}.
+ * An example of accessing the attributes map is:
+ * <pre>
+ * umoEventContext.getMessage().get( SmooksTransformer.MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT );
+ * </pre>
+ *
  * @author <a href="mailto:maurice@...">Maurice Zeijen</a>
+ *
  */
 public class Router extends FilteringOutboundRouter {
 

Modified: trunk/mule1/core/src/main/java/org/milyn/smooks/mule/Transformer.java (64 => 65)

--- trunk/mule1/core/src/main/java/org/milyn/smooks/mule/Transformer.java	2008-07-24 09:23:13 UTC (rev 64)
+++ trunk/mule1/core/src/main/java/org/milyn/smooks/mule/Transformer.java	2008-07-24 15:00:14 UTC (rev 65)
@@ -37,58 +37,87 @@
 import org.xml.sax.SAXException;
 
 /**
- * SmooksTransformer intended to be used with the Mule ESB.
+ * The Transformer intended to be used with the Mule ESB.
  * <p/>
  * <h3>Usage:</h3>
  * <pre>
- * Declare the tranformer in the Mule configuration file:
+ * Declare the transformer in the Mule configuration file:
  * &lt;transformers&gt;
- *      &lt;transformer name="SmooksTransformer" className="org.milyn.smooks.mule.Transformer"/&gt;
+ *      &lt;transformer name="SmooksTransformer" className="org.milyn.smooks.mule.Transformer"&gt;
+ *      	&lt;properties&gt;
+ *      		&lt;property name="configFile" value="smooks-config.xml"/&gt;
+ *      	&lt;/properties&gt;
+ *      &lt;/transformer&gt;
  * &lt;/transformers&gt;
  *
- * Configure the transformer with a router:
+ * Configure the router with a transformer:
  * &lt;inbound-router&gt;
  *     &lt;endpoint address="stream://System.in"  transformers="SmooksTransformer"/&gt;
  * &lt;/inbound-router&gt;
  *
+ * Required properties:
+ * &lt;property name="configFile" value="smooks-config.xml" /&gt;
+ *
  * Optional properties:
- * &lt;property name="smooksConfig" value="smooks-config.xml" /&gt;
  * &lt;property name="resultType" value="STRING" /&gt;
+ * &lt;property name="javaResultBeanId" value="orderBean" /&gt;
+ * &lt;property name="resultClass" value="javax.xml.transform.dom.DOMResult" /&gt;
+ * &lt;property name="resultFactoryClass" value="your.package.SomeResultFactory" /&gt;
+ * &lt;property name="reportPath" value="/tmp/smooks-report.html" /&gt;
+ * &lt;property name="executionContextAsMessageProperty" value="false" /&gt;
+ * &lt;property name="executionContextMessagePropertyKey" value="SmooksExecutionContext" /&gt;
  * &lt;property name="excludeNonSerializables" value="false" /&gt;
- * &lt;property name="reportPath" value="/tmp/smooks-report.html" /&gt;
- * &lt;property name="javaResultBeanId" value="orderBean" /&gt;
  * </pre>
  *
  * <h3>Description of configuration properties</h3>
  * <ul>
- * <li><i>smooksConfig</i> - the Smooks configuration file. Can be a path on the file system or on the classpath.
+ * <li><i>configFile</i> - the Smooks configuration file. Can be a path on the file system or on the classpath.
  * <li><i>resultType</i> - type of result expected from Smooks ("STRING", "BYTES", "JAVA", "RESULT", "NORESULT"). Default is "STRING".
- * <li><i>excludeNonSerializables</i> - if true, non serializable attributes from the Smooks ExecutionContext will no be included. Default is true.
- * <li><i>reportPath</i> - specifies the path and file name for generating a Smooks Execution Report.  This is a development tool.
  * <li><i>javaResultBeanId</i> - specifies the Smooks bean context beanId to be mapped as the result when the resultType is "JAVA".  If not specified,
  *                               the whole bean context bean Map is mapped as the result.
- * <li><i>resultClass</i> - specifies the Class to construct the {@link Result} Object from
- * <li><i>resultFactoryClass</i> - specifies the Factory class which will create the {@link Result} Object to be used as the result Source.
+ * <li><i>resultClass</i> - When the resultType is set to "RESULT" then this attribute defines the Result Class which will be used.
+ * 							The class must implement the {@link javax.xml.transform.Result} interface and must have an argumentless constructor.
+ * <li><i>resultFactoryClass</i> - When the resultType is set to "RESULT" then this attribute defines the ResultFactory	Class which will be used
+ * 								   to create the	Result Class. The class must implement the	{@link org.milyn.smooks.mule.ResultFactory} interface and
+ * 								   must have an argumentless constructor.
+ * <li><i>reportPath</i> - specifies the path and file name for generating a Smooks Execution Report.  This is a development tool.
+ * <li><i>executionContextAsMessageProperty</i> - If set to "true" then the attributes map of the Smooks execution context is added to the message properties.
+ * 												  The property key is defined with the executionContextMessagePropertyKey property. Default is "false"
+ * <li><i>executionContextMessagePropertyKey</i> - The property key under which the execution context is put. Default is "SmooksExecutionContext"
+ * <li><i>excludeNonSerializables</i> - if true, non serializable attributes from the Smooks ExecutionContext will no be included. Default is true.
  * </ul>
  *
  * <h3>Accessing Smooks ExecutionContext attributes</h3>
- * After Smooks has performed the filtering the transform method will make the attributes that have been set in the
- * the ExecutionContext available for other actions in the Mule ESB.
- * The attributes (Map) can be accessed by using the {@link #MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT} key like this:
+ * After Smooks finished filtering they payload and if the "executionContextAsMessageProperty" property is set to <code>true</code>
+ * then the transform method will make the attributes that have been set in the the ExecutionContext available for
+ * other actions in the Mule ESB by setting the attributes map as a property of the message.
+ * The attributes can be accessed by using the key defined under the property "executionContextMessagePropertyKey". Default
+ * "SmooksExecutionContext" is used, which is set under the constant {@link #MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT}.
+ * An example of accessing the attributes map is:
  * <pre>
- * umoEventContext.getMessage().get( SmooksTransformer.EXECUTION_CONTEXT_ATTR_MAP_KEY );
- * </pre>
+ * umoEventContext.getMessage().get( SmooksTransformer.MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT );
+ * </pre>
+ *
  * <h3>Specifying the Source and Result Types</h3>
  * From the object payload data type, this Transformer is able to automatically determine the type of
  * {@link javax.xml.transform.Source} to use (via the Smooks {@link PayloadProcessor}).  The
  * {@link javax.xml.transform.Result} type to be used can be specified via the "resultType"
- * property, as outlined above.
+ * property, as outlined above. If the result is required but shouldn't be a String, Bytes or Java then it
+ * is also possible to set the "resultClass" property or the "resultFactoryClass" properties. The resultType
+ * must be set to "RESULT" then.
+ * By defining the resultClass property with a classname the transformer will try to instantiate that class.
+ * The defined class must have a argumentless constructor and must implement the {@link javax.xml.transform.Result} interface.
+ * The resulting Result object will be used by Smooks as result and will be returned as the transformation result.
+ * If you need to use a factory class to instantiate the result class then this is also possible. By
+ * setting the "resultFactoryClass" with the class name of the factory the transformer will instantiate
+ * that factory an use its createResult() method to instantiate the Result object.
+ * The Factory must implement the {@link org.milyn.smooks.mule.ResultFactory} and have an argumentless constructor.
+ *
  * <p/>
- * It is expected that the above mechanism will be satisfactory for most usecase, but not all.
- * For the other usecases, this action supports {@link org.milyn.container.plugin.SourceResult}
+ * It is expected that the above mechanism will be satisfactory for most use cases, but not all.
+ * For the other use cases, this transformer supports {@link org.milyn.container.plugin.SourceResult}
  * payloads. This allows you to manually specify other Source and Result
- * types, which is of particular interest with respect to the Result type e.g. for streaming
- * the Result to a file etc.
+ * types.
  *
  * @author <a href="mailto:maurice@...">Maurice Zeijen</a>
  *

Modified: trunk/mule2/core/src/main/java/org/milyn/smooks/mule/NamedOutboundEndpointMuleDispatcher.java (64 => 65)

--- trunk/mule2/core/src/main/java/org/milyn/smooks/mule/NamedOutboundEndpointMuleDispatcher.java	2008-07-24 09:23:13 UTC (rev 64)
+++ trunk/mule2/core/src/main/java/org/milyn/smooks/mule/NamedOutboundEndpointMuleDispatcher.java	2008-07-24 15:00:14 UTC (rev 65)
@@ -29,6 +29,8 @@
 import org.mule.routing.outbound.AbstractOutboundRouter;
 
 /**
+ * This is the Mule 2.x implementation of the NamedEndpointMuleDispatcher. It
+ * is used by the Smook {@link MuleDispatcher} to actually dispatch a message.
  *
  * @author <a href="mailto:maurice@...">Maurice Zeijen</a>
  */

Modified: trunk/mule2/core/src/main/java/org/milyn/smooks/mule/Router.java (64 => 65)

--- trunk/mule2/core/src/main/java/org/milyn/smooks/mule/Router.java	2008-07-24 09:23:13 UTC (rev 64)
+++ trunk/mule2/core/src/main/java/org/milyn/smooks/mule/Router.java	2008-07-24 15:00:14 UTC (rev 65)
@@ -41,7 +41,74 @@
 import org.xml.sax.SAXException;
 
 /**
+ * The Router intended to be used with the Mule ESB.
+ * <p/>
+ * <h3>Usage:</h3>
+ * Declare the router in the Mule configuration file:
+ * <pre>
+ * &lt;outbound&gt;
+ * 	&lt;smooks:router configFile="/smooks-config.xml"&gt;
+ * 		&lt;jms:outbound-endpoint name="order" queue="order.queue"/&gt;
+ * 		&lt;jms:outbound-endpoint name="order-important" queue="order.important.queue"/&gt;
+ *	&lt;/smooks:router&gt;
+ * &lt;/outbound&gt;
  *
+ * <b>Required attributes/properties:</b>
+ * &lt;property name="configFile" value="smooks-config.xml" /&gt;
+ *
+ * <b>Optional attributes/properties:</b>
+ * &lt;property name="resultType" value="STRING" /&gt;
+ * &lt;property name="reportPath" value="/tmp/smooks-report.html" /&gt;
+ * &lt;property name="executionContextAsMessageProperty" value="false" /&gt;
+ * &lt;property name="executionContextMessagePropertyKey" value="SmooksExecutionContext" /&gt;
+ * &lt;property name="excludeNonSerializables" value="false" /&gt;
+ * </pre>
+ *
+ * <h3>Description of configuration attributes/properties</h3>
+ * <ul>
+ * <li><i>configFile</i> - the Smooks configuration file. Can be a path on the file system or on the classpath.
+ * <li><i>reportPath</i> - specifies the path and file name for generating a Smooks Execution Report.  This is a development tool.
+ * <li><i>executionContextAsMessageProperty</i> - If set to "true" then the attributes map of the Smooks execution context is added to the message
+ * 												  properties of every message that gets created by this router. The property key is defined with
+ * 												  the executionContextMessagePropertyKey property. Default is "false"
+ * <li><i>executionContextMessagePropertyKey</i> - The property key under which the execution context is put. Default is "SmooksExecutionContext"
+ * <li><i>excludeNonSerializables</i> - if true, non serializable attributes from the Smooks ExecutionContext will no be included. Default is true.
+ * </ul>
+ *
+ * <h3>Defining Endpoints</h3>
+ * As normal with Mule router you must at least define one endpoint to route the messages to. For this router it is
+ * also required that you define the name of the router. That name is used as reference within the Smooks configuration
+ * so that it knows which endpoint to use.
+ *
+ * <h3>Using the Smooks MuleDispatcher</h3>
+ * Within the Smooks Router the {@link org.milyn.smooks.mule.MuleDispatcher} resource is used to actually route the message parts
+ * to one of the defined endpoints (using the endpoint name). The following example demonstrates how to configure a MuleDispatcher:
+ *
+ * <pre>
+ * &lt;resource-config selector="order"&gt;
+ * 	&lt;resource&gt;org.milyn.smooks.mule.MuleDispatcher&lt;/resource&gt;
+ * 	&lt;param name="endpointName"&gt;orderEndpoint&lt;/param&gt;
+ * 	&lt;param name="beanId"&gt;orderBean&lt;/param&gt;
+ * &lt;/resource-config&gt;
+ * </pre>
+ *
+ * In this example Smooks calls the {@link MuleDispatcher} when it is in the visit after phase of the "order" element. The {@link MuleDispatcher}
+ * creates a new Mule message and it will use the object found under the beanId "orderBean" in the Smooks BeanMap as it's payload. It
+ * then dispatches that message to the endpoint with the name "orderEndpoint".
+ * <p/>
+ * More information on the configuration options of the {@link MuleDispatcher} can be found in the javadoc of the {@link MuleDispatcher} itself.
+ *
+ * <h3>Accessing Smooks ExecutionContext attributes</h3>
+ * When the {@link MuleDispatcher} dispatches a message and if the "executionContextAsMessageProperty" property
+ * is set to <code>true</code> then the MuleDispatcher will make the attributes that have been set in the
+ * ExecutionContext at that moment available for other actions in the Mule ESB by setting the attributes map as a property of the message.
+ * The attributes can be accessed by using the key defined under the property "executionContextMessagePropertyKey". Default
+ * "SmooksExecutionContext" is used, which is set under the constant {@link #MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT}.
+ * An example of accessing the attributes map is:
+ * <pre>
+ * umoEventContext.getMessage().get( SmooksTransformer.MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT );
+ * </pre>
+ *
  * @author <a href="mailto:maurice@...">Maurice Zeijen</a>
  *
  */

Modified: trunk/mule2/core/src/main/java/org/milyn/smooks/mule/Transformer.java (64 => 65)

--- trunk/mule2/core/src/main/java/org/milyn/smooks/mule/Transformer.java	2008-07-24 09:23:13 UTC (rev 64)
+++ trunk/mule2/core/src/main/java/org/milyn/smooks/mule/Transformer.java	2008-07-24 15:00:14 UTC (rev 65)
@@ -25,6 +25,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.milyn.Smooks;
 import org.milyn.container.ExecutionContext;
+import org.milyn.container.plugin.PayloadProcessor;
 import org.milyn.event.report.HtmlReportGenerator;
 import org.mule.api.MuleMessage;
 import org.mule.api.lifecycle.InitialisationException;
@@ -35,11 +36,86 @@
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
-/**
- * SmooksTransformer intended to be used with the Mule ESB.
- *
- *
- * @author <a href="mailto:maurice@...">Maurice Zeijen</a> */
+/**
+ * The Transformer intended to be used with the Mule ESB.
+ * <p/>
+ * <h3>Usage:</h3>
+ * <pre>
+ * Declare the transformer in the Mule configuration file:
+ * &lt;smooks:transformer name="smooksTransformer" configFile="/transformer-smooks-config.xml" /&gt;
+ *
+ * Configure the router with a transformer:
+ * &lt;inbound&gt;
+ * 	&lt;vm:inbound-endpoint path="messageInput" transformer-refs="smooksTransformer"/&gt;
+ * &lt;/inbound&gt;
+ *
+ * Required attributes/properties:
+ * &lt;property name="configFile" value="smooks-config.xml" /&gt;
+ *
+ * Optional attributes/properties:
+ * &lt;property name="resultType" value="STRING" /&gt;
+ * &lt;property name="javaResultBeanId" value="orderBean" /&gt;
+ * &lt;property name="resultClass" value="javax.xml.transform.dom.DOMResult" /&gt;
+ * &lt;property name="resultFactoryClass" value="your.package.SomeResultFactory" /&gt;
+ * &lt;property name="reportPath" value="/tmp/smooks-report.html" /&gt;
+ * &lt;property name="executionContextAsMessageProperty" value="false" /&gt;
+ * &lt;property name="executionContextMessagePropertyKey" value="SmooksExecutionContext" /&gt;
+ * &lt;property name="excludeNonSerializables" value="false" /&gt;
+ * </pre>
+ *
+ * <h3>Description of configuration attributes/properties</h3>
+ * <ul>
+ * <li><i>configFile</i> - the Smooks configuration file. Can be a path on the file system or on the classpath.
+ * <li><i>resultType</i> - type of result expected from Smooks ("STRING", "BYTES", "JAVA", "RESULT", "NORESULT"). Default is "STRING".
+ * <li><i>javaResultBeanId</i> - specifies the Smooks bean context beanId to be mapped as the result when the resultType is "JAVA".  If not specified,
+ *                               the whole bean context bean Map is mapped as the result.
+ * <li><i>resultClass</i> - When the resultType is set to "RESULT" then this attribute defines the Result Class which will be used.
+ * 							The class must implement the {@link javax.xml.transform.Result} interface and must have an argumentless constructor.
+ * <li><i>resultFactoryClass</i> - When the resultType is set to "RESULT" then this attribute defines the ResultFactory	Class which will be used
+ * 								   to create the	Result Class. The class must implement the	{@link org.milyn.smooks.mule.ResultFactory} interface and
+ * 								   must have an argumentless constructor.
+ * <li><i>reportPath</i> - specifies the path and file name for generating a Smooks Execution Report.  This is a development tool.
+ * <li><i>executionContextAsMessageProperty</i> - If set to "true" then the attributes map of the Smooks execution context is added to the message properties.
+ * 												  The property key is defined with the executionContextMessagePropertyKey property. Default is "false"
+ * <li><i>executionContextMessagePropertyKey</i> - The property key under which the execution context is put. Default is "SmooksExecutionContext"
+ * <li><i>excludeNonSerializables</i> - if true, non serializable attributes from the Smooks ExecutionContext will no be included. Default is true.
+ * </ul>
+ *
+ * <h3>Accessing Smooks ExecutionContext attributes</h3>
+ * After Smooks finished filtering they payload and if the "executionContextAsMessageProperty" property is set to <code>true</code>
+ * then the transform method will make the attributes that have been set in the the ExecutionContext available for
+ * other actions in the Mule ESB by setting the attributes map as a property of the message.
+ * The attributes can be accessed by using the key defined under the property "executionContextMessagePropertyKey". Default
+ * "SmooksExecutionContext" is used, which is set under the constant {@link #MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT}.
+ * An example of accessing the attributes map is:
+ * <pre>
+ * umoEventContext.getMessage().get( SmooksTransformer.MESSAGE_PROPERTY_KEY_EXECUTION_CONTEXT );
+ * </pre>
+ *
+ * <h3>Specifying the Source and Result Types</h3>
+ * From the object payload data type, this Transformer is able to automatically determine the type of
+ * {@link javax.xml.transform.Source} to use (via the Smooks {@link PayloadProcessor}).  The
+ * {@link javax.xml.transform.Result} type to be used can be specified via the "resultType"
+ * property, as outlined above. If the result is required but shouldn't be a String, Bytes or Java then it
+ * is also possible to set the "resultClass" property or the "resultFactoryClass" properties. The resultType
+ * must be set to "RESULT" then.
+ * By defining the resultClass property with a classname the transformer will try to instantiate that class.
+ * The defined class must have a argumentless constructor and must implement the {@link javax.xml.transform.Result} interface.
+ * The resulting Result object will be used by Smooks as result and will be returned as the transformation result.
+ * If you need to use a factory class to instantiate the result class then this is also possible. By
+ * setting the "resultFactoryClass" with the class name of the factory the transformer will instantiate
+ * that factory an use its createResult() method to instantiate the Result object.
+ * The Factory must implement the {@link org.milyn.smooks.mule.ResultFactory} and have an argumentless constructor.
+ *
+ * <p/>
+ * It is expected that the above mechanism will be satisfactory for most use cases, but not all.
+ * For the other use cases, this transformer supports {@link org.milyn.container.plugin.SourceResult}
+ * payloads. This allows you to manually specify other Source and Result
+ * types.
+ *
+ * @author <a href="mailto:maurice@...">Maurice Zeijen</a>
+ *
+ */
 public class Transformer extends AbstractMessageAwareTransformer {
 
 	private static final Logger log = LoggerFactory.getLogger(Transformer.class);


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MuleForge Dev" group.
To post to this group, send email to muleforgedev@...
To unsubscribe from this group, send email to muleforgedev-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/muleforgedev?hl=en
-~----------~----~----~----~------~----~------~--~---
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://admin.muleforge.org/manage_email