public Object evaluate(Exchange exchange) {
try {
if (locations != null) {
// the properties component is optional as we got locations
// getComponent will create a new component if none already exists
Component component = exchange.getContext().getComponent("properties");
PropertiesComponent pc = exchange.getContext().getTypeConverter()
.mandatoryConvertTo(PropertiesComponent.class, component);
// enclose key with {{ }} to force parsing
String[] paths = locations.split(",");
return pc.parseUri(PropertiesComponent.PREFIX_TOKEN + key + PropertiesComponent.SUFFIX_TOKEN, paths);
} else {
// the properties component is mandatory if no locations provided
Component component = exchange.getContext().hasComponent("properties");
if (component == null) {
throw new IllegalArgumentException("PropertiesComponent with name properties must be defined"
+ " in CamelContext to support property placeholders in expressions");
}
PropertiesComponent pc = exchange.getContext().getTypeConverter()