camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Matèrne (jhm) <apa...@materne.de>
Subject AW: When - an Apache Camel Component for time slots management
Date Mon, 11 Nov 2013 12:50:29 GMT
> 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?


> but I'm struggling with the matches method. This works:
>   .filter(
>      header("anyHeader")
>      .matches( new LanguageExpression("when", timeExpression) ))
> 
> but I'd like to do something like:
>   .filter(
>      header("anyHeader")
>      .matches( language("when", "MON-FRI") ))

A static import?
  
public class LanguageExpression {
    public static LanguageExpression language(String s, String pattern) {
        return new LanguageExpression(s, pattern);
    }
}

import static LanguageExpression.language;
public class MyBuilder {
    ...
    from(...).filter(language("when", "MON-FRI")).to(...);
}


> or even better
>   .filter(header("anyHeader").matches("when", "MON-FRI"))

Not sure which method to modify ...



> 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?



Jan


Mime
View raw message