}
@SuppressWarnings({ "unchecked", "rawtypes" })
private ValidationResult applyValidator(Exchange exchange, Validator validator) {
Message message = exchange.getMessage();
ValidationResult validationResult = null;
if (Message.class.isAssignableFrom(validator.getType())) {
validationResult = validator.validate(message);
} else {
validationResult = validator.validate(message.getContent(validator.getType()));
}
if (validationResult.isValid()) {
if (_logger.isDebugEnabled()) {
_logger.debug("Validated Message (" + System.identityHashCode(message)
+ ") with name '" + validator.getName() + "' using validator type '" + validator.getType() + "'.");
}
}