Giter VIP home page Giter VIP logo

rulest's Introduction

RulEST

A drools rule engine RESTful Web Services.The purpose is let user can use drools rule engine by resuful web service.

Requirement

  • Java JDK 1.7
  • Gradle

Build and Run

Get source code

$ git clone https://github.com/eternnoir/RulEST.git
$ cd RulEst

Build and test

$ ./gradlew build 
$ ./gradlew test

Run

$ ./gradlew run

Test Sample Rule

The rule is

package drools
import org.enoir.rulest.sample.SampleFact

rule "Hello World"
    when
        m : SampleFact( status == 1, myMessage : message )
    then
        System.out.println( myMessage );
        m.setMessage( "Goodbye world" );
        m.setStatus( 0 );
        update( m );
end

rule "GoodBye"
    when
        SampleFact( status == 0, myMessage : message )
    then
        System.out.println( myMessage );
end

POST Josn to http://127.0.0.1:8080/execute

{
   "targetRulePackage":"SampleRP",
   "Facts":[
      {
         "id": 1,
         "message":"Hello RulEST",
         "status":1
      }
   ]
}

Server will return

[
   {
      "id":1,
      "message":"Goodbye world",
      "status":0
   }
]

Console output:

2015-04-20 14:06:15.601  INFO 17534 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2015-04-20 14:06:15.615  INFO 17534 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 14 ms
2015-04-20 14:06:17.473  INFO 17534 --- [nio-8080-exec-1] org.reflections.Reflections              : Reflections took 1812 ms to scan 63 urls, producing 4818 keys and 23463 values 
Hello RulEST
Goodbye world

Multiple facts:

{
   "targetRulePackage":"SampleRP",
   "Facts":[
      {
         "id":1,
         "message":"Hello RulEST",
         "status":1
      },
      {
         "id":2,
         "message":"Hello RulEST2",
         "status":1
      },
      {
         "id":3,
         "message":"Hello RulEST3",
         "status":1
      }
   ]
}

Result:

[
   {
      "id":2,
      "message":"Goodbye world",
      "status":0
   },
   {
      "id":1,
      "message":"Goodbye world",
      "status":0
   },
   {
      "id":3,
      "message":"Goodbye world",
      "status":0
   }
]

Console output:

Hello RulEST3
Hello RulEST2
Hello RulEST
Goodbye world
Goodbye world
Goodbye world

TODO

  • Pluginable RulePackage.
  • Support Drools stream mode.

rulest's People

Contributors

eternnoir avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.