MessagePropertySetter --------------------- Key: SM-486 URL: https://issues.apache.org/activemq/browse/SM-486 Project: ServiceMix Type: New Feature
Components: servicemix-components Versions: 3.0 Reporter: Ramon Buckland Priority: Minor Attachments: servicemix-components-mps.zip A new component which sets properties on messages as it goes through based on config. A while back now I created this TransformComponentSupport based Component which assists in loading properties from XML config, and setting them on JBI properties as the message goes through. It's a little hard to explain, so here goes. Essentially, sending a message past/through the messagPropertySetter, will as name suggests set some properties on the message. The properties it sets is derived from a list in the XML config file it is configured with. The property-set name to use can be supplied by (a) a static spring configured name (thus making this component) always apply the "same" set (b) a value of a JBI property, which is used to determine the set of properties to load (c) an XPath expression which is evaluated against the incoming message, and the resulting "string" is the name of the set of properties to apply to the out message. -- the VALUE of the properties from the chosen set is derived by a list of "precdence" value Resolvers. the Value for any one property is either (a) a static string (b) the value of an existing property (c) the value of the xpath expresssion applied to the message. These can be applied in any order, and the first that returns a value, will be the value that is used. --------- from the class comments ---- Sets properties on the message, loaded from an XML MPS file where the properties to set are located in a <property-set ..> inside the XML config file. There can be more than one propertySet to "load". The property values are derived from 3 types of config. The first config that can return a value as a String to set onto the message, will be the "value" that is set as that property. <static-value> As it's name suggests, the "value" of this element will be the value of the JBI property. This is helpful as a default value, or as a static value. <exisiting-property> and <existing-property name="..."/> This will obtain the value of an existing property (itself) or another property on the same message. This can be helpful when you want the to "ONLY" change the the value of the property if there is some "xpath" expression that could not be derived. name=".." form will copy the string value of the other JBI property onto this one, (duping it). This may be handy when you have a component which expects a new property, but you have it as a different name at the moment. <xpath-expression> As it's name suggests, will locate a value in the inMessage source and set the resulting XPath String as the value of the JBI property. So given the three types, they can be arranged in any order. and the first PropertyValue Type that returns a value, will become the "value" of the JBI property. Regards Ramon A sample config looks like <mps> <property-set name="someSetNameForASetOfProperties"> <property name="some.property.name1"> <static-value> <![CDATA[value for the property]]> </static-value> </property> <property name="some.property.name2"> <xpath-expression> <![CDATA[/someexpath/statement/to/be/applied/to/message/source]]> </xpath-expression> <xpath-expression> <![CDATA[/some/other/xpath]]> </xpath-expression> <existing-property name="someproperty"/> <static-value> <![CDATA[a default value]]> </static-value> </property> <property name="prop.xpath.with.static.default"> <xpath-expression> <![CDATA[/someexpath/statement]]> </xpath-expression> <static-value> <![CDATA[some default if xpath does not resolve]]> </static-value> </property> <property name="prop.xpath.or.keep.existing"> <xpath-expression> <![CDATA[/someexpath/statement]]> </xpath-expression> <existing-property/> </property> <property name="new.prop.name"> <existing-property name="other.property"/> </property> <property name="..."> ... </property> </property-set> <property-set name="..."> ... </property-set> </mps> -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira