[ 
https://issues.apache.org/jira/browse/S4-5?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207961#comment-13207961
 ] 

Leo Neumeyer commented on S4-5:
-------------------------------

I just committed the first version of the S4 Embedded Domain-Specific Language 
to the S4-5 branch. I ended up using Diezel to implement it. Eric, the author, 
was very responsive fixing the few bugs I found. The advantage of using Diezel 
is that it is almost impossible to code by hand and it makes it easy to modify 
and extend the grammar in the future. I created a Gradle build script that uses 
the Diezel Maven plugin to generate the EDSL Java source code. Here is the 
grammar I committed:

{code:title=S4 EDSL Grammar|borderStyle=solid}
(pe , type , prop* , (fireOn , afterInterval? , afterNumEvents?)? , (timer, 
withPeriod)? , (cache, size , expires? )? , asSingleton? , (emit, onField?, 
(withKey|withKeyFinder)?, to+ )*  )+ , build
{code}

and this is the counter app:

{code:title=Counter App using the S4 EDSL|borderStyle=solid}
 protected void onInit() {

        pe("Print").type(PrintPE.class).asSingleton().

        pe("User 
Count").type(CounterPE.class).fireOn(Event.class).afterInterval(100, 
TimeUnit.MILLISECONDS)
                .emit(CountEvent.class).withKeyFinder(new 
CountKeyFinder()).to("Print").

                pe("Gender 
Count").type(CounterPE.class).fireOn(Event.class).afterInterval(100, 
TimeUnit.MILLISECONDS)
                .emit(CountEvent.class).withKeyFinder(new 
CountKeyFinder()).to("Print").

                pe("Age 
Count").type(CounterPE.class).fireOn(Event.class).afterInterval(100, 
TimeUnit.MILLISECONDS)
                .emit(CountEvent.class).withKeyFinder(new 
CountKeyFinder()).to("Print").

                pe("Generate User 
Event").type(GenerateUserEventPE.class).timer().withPeriod(1, 
TimeUnit.MILLISECONDS)
                .asSingleton().

                emit(UserEvent.class).withKeyFinder(new 
UserIDKeyFinder()).to("User Count").

                emit(UserEvent.class).withKey("gender").to("Gender Count").

                emit(UserEvent.class).withKeyFinder(new AgeKeyFinder()).to("Age 
Count").

                build();
    }
{code}

We can iterate a bit on the names of the tokens.

For more details look at:

* The [Diezel Project|http://code.google.com/p/diezel]
* New subproject s4-edsl
* Test case in s4-edsl
* The Counter example in the s4-example subproject package 
org.apache.s4.edsl.counter


                
> Prototype app builder
> ---------------------
>
>                 Key: S4-5
>                 URL: https://issues.apache.org/jira/browse/S4-5
>             Project: Apache S4
>          Issue Type: New Feature
>    Affects Versions: 0.5
>            Reporter: Leo Neumeyer
>            Priority: Minor
>             Fix For: 0.5
>
>         Attachments: s4-fluent.pdf
>
>
> Extend Guice AbstractModule to create a simple application builder layer. The 
> idea is to evaluate if we can use Guice to do all the wiring including PEs 
> and Streams and Apps.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to