Search in sources :

Example 1 with ValidatorDefinition

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);
}
Also used : PredicateValidatorDefinition(org.apache.camel.model.validator.PredicateValidatorDefinition) EndpointValidatorDefinition(org.apache.camel.model.validator.EndpointValidatorDefinition) CustomValidatorDefinition(org.apache.camel.model.validator.CustomValidatorDefinition) EndpointValidatorDefinition(org.apache.camel.model.validator.EndpointValidatorDefinition) PredicateValidatorDefinition(org.apache.camel.model.validator.PredicateValidatorDefinition) CustomValidatorDefinition(org.apache.camel.model.validator.CustomValidatorDefinition) ValidatorDefinition(org.apache.camel.model.validator.ValidatorDefinition)

Aggregations

CustomValidatorDefinition (org.apache.camel.model.validator.CustomValidatorDefinition)1 EndpointValidatorDefinition (org.apache.camel.model.validator.EndpointValidatorDefinition)1 PredicateValidatorDefinition (org.apache.camel.model.validator.PredicateValidatorDefinition)1 ValidatorDefinition (org.apache.camel.model.validator.ValidatorDefinition)1