1 17 package org.apache.servicemix.expression; 18 19 import javax.jbi.messaging.MessageExchange; 20 import javax.jbi.messaging.MessagingException; 21 import javax.jbi.messaging.NormalizedMessage; 22 23 28 public class PropertyExpression implements Expression { 29 private String property; 30 private Object defaultValue; 31 32 public PropertyExpression(String property) { 33 this.property = property; 34 } 35 36 public PropertyExpression(String property, Object defaultValue) { 37 this.property = property; 38 this.defaultValue = defaultValue; 39 } 40 41 public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { 42 Object answer = message.getProperty(property); 43 if (answer == null) { 44 answer = exchange.getProperty(property); 45 if (answer == null) { 46 answer = defaultValue; 47 } 48 } 49 return answer; 50 } 51 } 52 | Popular Tags |