I am trying to pad some text in a velocity template in the camel component. To do this, I'd like to use the StringUtils class of apache commons. Per suggestions from other sources, I've tried this:
public class StringUtilsHelper { public void addStringUtilsToExchange( final Exchange exchange ) { exchange.setProperty( "StringUtils", new StringUtils() ); exchange.getIn().setHeader( "StringUtils", new StringUtils() ); } } and in my template: ${exchange.StringUtils.leftPad("foo", 10)} ${in.StringUtils.leftPad("foo", 10)} I've also tried: $exchange.StringUtils.leftPad("foo", 10) $in.StringUtils.leftPad("foo", 10) When I call this template by calling velocity without camel it works, something like this: Velocity.getTemplate( "string-padding-test.vm" ).merge( new VelocityContext() { { put( "StringUtils", StringUtils.class ); } }, stringWriter ); My route is pretty simple, and when I add: $body to the template the objects in the body do render, so I'm at a loss. <route id="my-route"> <from uri="timer://my-timer?period=24h" /> <bean ref="dataAcquisition" /> <bean ref="stringUtilsHelper" /> <split> <simple>${body}</simple> <to uri="velocity:template.vm" /> <to id="sftpOut" uri="ref:sftp-out" /> </split> </route> I'm willing to use other things, but I'd prefer not to have to write extra macros in to my template for padding and other formatting, if it came to that I'd build a decorator class to wrap my objects to be rendered. Does anyone have any idea why this is not working? -- View this message in context: http://camel.465427.n5.nabble.com/padded-text-and-or-static-classes-in-velocity-template-of-velocity-component-tp5736136.html Sent from the Camel - Users mailing list archive at Nabble.com.