2013/11/11 Jan Matèrne (jhm) <[email protected]>:
>> I was able to get this working
>>
>> from("direct:start").filter("when", "MON-FRI 9:30-18:30").to(...)
>
> Does that matches the current system time?
Yes.
You can also define an header called "when.date" to do the matching on
this one instead. I do not like this "trick", that's why I'm working
on matches.
> A static import?
Yes, it would work, but I feel like something is actually missing from
BuilderSupport.
Why can I do this
.filter(header("anyHeader").matches(xpath("..."))
or this
.setHeader("any").language("groovy", "123")
but not this?
.filter(header("anyHeader").matches(language("when", "MON-FRI")))
It feels like it's extremely easy to plug-in a new DSL language but
not always so immediate to use this new language in routes definition.
>> or even better
>> .filter(header("anyHeader").matches("when", "MON-FRI"))
>
> Not sure which method to modify ...
I would add this to ValueBuilder:
public Predicate matches(String language, String expression) {
return matches(new LanguageExpression(language, expression));
}
just like the filter method.
>> or maybe (quite dangerous, but more flexible):
>> .filter(header("anyHeader").matches("{when} MON-FRI"))
>
> I found org.apache.camel.builder.BuilderSupport.header(String) :
> ValueBuilder.
> And in org.apache.camel.builder.ValueBuilder.matches(Expression) :
> Predicate.
>
> Maybe a Converter String>Expression?
Again this would work. But it's an extra setup to ask to the many
users of my component ;)
The filter method was overloaded to support custom languages. A lot of
custom methods have been added for the main languages: groovy, xpath,
etc.
Maybe camel needs a simpler standard way to plug-in new expressions
from other languages, from here the "{prefix}" idea.
Just my 1 cent after a couple of experiments.
Bye
Lorenzo