[windup-dev] Rules API

Ondrej Zizka ozizka at redhat.com
Fri May 2 19:26:34 EDT 2014


Hi,

WRT rules API, as proposed at
https://github.com/windup/windup/blob/master/engine/config/api/src/main/java/org/jboss/windup/addon/config/example/MavenExampleConfigurationProvider.java#L22

It's nice, with some comments.

I know it was typed in a hurry, but anyway:

1) The  (when, perform) structure would be basic for all rules?

2) This seems like it will build object tree, which will then be 
processed, right? No space for custom code?

3) Isn't that a fluent API overuse? How about something like:

new ConfigBuilder( ... ){{
     addRule( new MavenPomRule( this, ... ){
              boolean when(  ) { return Selection.exists(XMLFile.class, 
"xmls").with("doctype", DOCTYPE_POM); }
              void perform( MavenPomInfo mpi ){ ... }
         }
     );
}}.run();

It's verbose now but with Java 8 lambdas, it would be less.

While it's a bit more verbose, it would have obvious benefits of better 
debuggability, and would better leverage Java's features like 
inheritance (imagine AbstractXmlFileRule and it's subclasses for 
whatever one would want to do with a XML file, having few of its 
properties passed as parameters.

Btw this code above is inspired by Wicket and GWT.

4) .withDoctype("http://maven.apache.org/POM/4.0.0") ?
doctype is a property...  Better .with(PropNames.DOCTYPE, 
"http://maven.apache.org/POM/4.0.0") ?

5) Could the variable be filled outside .when () ? But perhaps just a 
matter of taste.

More later when we have some more examples.

Nice!
Ondra


More information about the windup-dev mailing list