use of org.apache.camel.model.validator.ValidatorDefinition in project camel by apache.
the class ValidatorBuilder method configure.
/**
* Configure a Validator according to the configurations built on this builder
* and register it into given {@code CamelContext}.
*
* @param camelContext {@code CamelContext}
*/
public void configure(CamelContext camelContext) {
ValidatorDefinition validator;
if (uri != null) {
EndpointValidatorDefinition etd = new EndpointValidatorDefinition();
etd.setUri(uri);
validator = etd;
} else if (expression != null) {
PredicateValidatorDefinition dtd = new PredicateValidatorDefinition();
dtd.setExpression(expression);
validator = dtd;
} else if (clazz != null) {
CustomValidatorDefinition ctd = new CustomValidatorDefinition();
ctd.setClassName(clazz.getName());
validator = ctd;
} else if (beanRef != null) {
CustomValidatorDefinition ctd = new CustomValidatorDefinition();
ctd.setRef(beanRef);
validator = ctd;
} else {
throw new IllegalArgumentException("No Validator type was specified");
}
validator.setType(type);
camelContext.getValidators().add(validator);
}
Aggregations