update documentation for version 1.3.0

pull/7/head
Mahmoud Ben Hassine 10 years ago
parent 9deb03e011
commit dc572bfaf8

@ -20,6 +20,17 @@ All Easy Rules documentation can be found here : [http://www.easyrules.org](http
You can find some slides about Easy Rules on [speaker deck](https://speakerdeck.com/benas/easy-rules).
## Continuous integration
[Jenkins job @ cloudbees.com](https://buildhive.cloudbees.com/job/benas/job/easy-rules/)
## Current version
* The current stable version is 1.3.0: [![Build Status](https://buildhive.cloudbees.com/job/benas/job/easy-rules/badge/icon)](https://buildhive.cloudbees.com/job/benas/job/easy-rules/)
* The current development version is 1.3.1-SNAPSHOT
## Agile Board
[Backlog items @ waffle.io](https://waffle.io/benas/easy-rules)
## Contribution
You are welcome to contribute to the project with pull requests on GitHub.
@ -37,6 +48,11 @@ For any further question, you can use the [Gitter](https://gitter.im/benas/easy-
Thank you all for your contributions!
## Credits
Many thanks to [YourKit, LLC](https://www.yourkit.com/) for providing a free license of [YourKit Java Profiler](https://www.yourkit.com/java/profiler/index.jsp) to kindly support the development of Easy Rules.
![YourKit Java Profiler](https://www.yourkit.com/images/yklogo.png)
## License
Easy Rules is released under the [MIT License](http://opensource.org/licenses/mit-license.php/):

@ -1 +0,0 @@
Easy Rules website.

@ -1,4 +1,4 @@
version: 1.2.0
version: 1.3.0
highlighter: pygments
url: http://www.easyrules.org
google_analytics_id: UA-46301888-1

@ -1,11 +1,12 @@
<footer>
<div class="grid">
<div class="unit one-third center-on-mobiles">
<p>Project created and maintained by <a target="_blank" href="{{ site.author.web }}">{{ site.author.name}}</a>.</p>
<p>Project created and maintained by <a target="_blank" href="{{ site.author.web }}">{{ site.author.name}}</a>
and the <a href="https://github.com/benas/easy-rules#awesome-contributors" target="_blank">awesome contributors</a>.</p>
</div>
<div class="unit two-thirds align-right center-on-mobiles">
<p>
Inspired by and built with <a target="_blank" href="http://jekyllrb.com">Jekyll</a>. Hosted on <a target="_blank" href="https://github.com">Github</a>.
<p>Easy Rules is released under the terms of the <a href="http://opensource.org/licenses/mit-license.php/" target="_blank">MIT license</a>.<br/>
This website is inspired by and built with <a target="_blank" href="http://jekyllrb.com">Jekyll</a>.
</p>
</div>

@ -6,6 +6,9 @@
<li class="{% if page.doc %}current{% endif %}">
<a href="{{ site.url }}/about/overview.html">Documentation</a>
</li>
<li>
<a target="_blank" href="{{ site.url }}/apidocs/">API docs</a>
</li>
<li>
<a target="_blank" href="https://github.com/{{ site.author.github }}/{{ site.project.github }}">View on GitHub</a>
</li>

@ -17,16 +17,17 @@ Please follow these instructions :
{% highlight bash %}
$ git clone https://github.com/benas/easy-rules.git
$ cd easy-rules
$ mvn package
{% endhighlight %}
Easy Rules core jar **_easyrules-core-${version}.jar_** will be generated in the target folder.
Easy Rules core jar **_easyrules-core-{{site.version}}.jar_** will be generated in the **_target_** folder.
## Use with maven
Easy Rules is a single jar file with no dependencies. You have to simply add the jar **_easyrules-core-{{site.version}}.jar_** to your application's classpath.
Easy Rules is a single jar file with no dependencies. You have to add the jar **_easyrules-core-{{site.version}}.jar_** to your application's classpath.
Using maven, you should add the following dependency to your pom.xml :
If you use maven, you should add the following dependency to your **_pom.xml_** :
```xml
<dependencies>

@ -14,7 +14,7 @@ Easy Rules is a simple yet powerful Java rules engine providing the following fe
* The ability to create composite rules from primitive ones
* Dynamic rule configuration at runtime using JMX
In a very interesting [article](http://martinfowler.com/bliki/RulesEngine.html) about rules engines, [Martin Fowler](http://martinfowler.com/) says the following :
In a very interesting <a href="http://martinfowler.com/bliki/RulesEngine.html" target="_blank">article</a> about rules engines, <a href="http://martinfowler.com/" target="_blank">Martin Fowler</a> says:
>You can build a simple rules engine yourself. All you need is to create a bunch of objects with conditions and actions, store them in a collection, and run through them to evaluate the conditions and execute the actions.

@ -1004,3 +1004,14 @@ code.option, code.flag, code.filter, code.output {
display: inline;
}
}
/* miscellaneous */
.logo {
height: 80% !important;
width: 90% !important;
margin-top: 20px !important;
margin-left: auto !important;
margin-right: auto !important;
text-align: center !important;
}

@ -10,6 +10,25 @@ doc: true
<a href="/get-involoved/release-notes.html">{{ page.title }}</a>
</h2>
<div class="release">
<span class="post-category">
<span class="label">Version 1.3.0</span>
</span>
<div class="post-meta">
<span class="post-date">2015-03-11</span>
</div>
<div class="post-content">
<p>This release added the following features:</p><p></p>
<ul>
<li>Moved JMX support to a separate module so that the core engine can be used in both Java and Android applications (<a href="https://github.com/benas/easy-rules/pull/5" target="_blank">PR #5</a>).</li>
<li>Fixed <a href="https://github.com/benas/easy-rules/issues/6" target="_blank">issue #6</a>: Can't register multiple rules with the same priority to DefaultRulesEngine</li>
<li>Refactored tests to use <a href="http://mockito.org/" target="_blank">Mockito</a> and <a href="http://assertj.org" target="_blank">AssertJ</a></li>
<li>Improved test coverage</li>
<li>Updated documentation and tutorials</li>
</ul>
</div>
</div>
<div class="release">
<span class="post-category">
<span class="label">Version 1.2.0</span>

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

@ -46,6 +46,7 @@ overview: true
<div class="shell">
<div class="highlight"><pre><code class="language-java" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size: 16px"><span class="kd">public class</span> <span class="nc">Test</span> <span class="o">{</span>
<span class="kd">public static void</span> <span class="nf">main</span><span class="o">(</span>String<span class="o">[]</span> args<span class="o">)</span> <span class="o">{</span>
<span class="c1">// create a rules engine</span>
AnnotatedRulesEngine rulesEngine <span class="o">=</span>
<span class="k">new</span> AnnotatedRulesEngine<span class="o">();</span>
@ -62,6 +63,7 @@ overview: true
<div class="shell">
<div class="highlight"><pre><code class="language-java" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size: 16px"><span class="nd">@Rule</span> <span class="o">(</span>name <span class="o">=</span> <span class="s">"my awesome rule"</span> <span class="o">)</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyRule</span> <span class="o">{</span>
<span class="nd">@Condition</span>
<span class="kd">public boolean</span> <span class="nf">when</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> true<span class="o">;</span>
@ -84,7 +86,7 @@ overview: true
<div class="unit whole">
<div class="pane-content">
<h2>License</h2>
<p>Easy Rules is open source, hosted on <a target="_blank" href="https://github.com/benas/easy-rules">GitHub</a> and is released under the <a target="_blank" href="http://opensource.org/licenses/mit-license.php/">MIT License</a>.</p>
<p>Easy Rules is open source, hosted on <a target="_blank" href="https://github.com/benas/easy-rules">GitHub</a> and is released under the terms of the<a target="_blank" href="http://opensource.org/licenses/mit-license.php/">MIT License</a>.</p>
</div>
<div class="pane-content align-center">
@ -95,6 +97,18 @@ overview: true
<iframe src="http://ghbtns.com/github-btn.html?user=benas&type=follow&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="165" height="20"></iframe>
</div>
<div class="pane-content">
<h2>Credits</h2>
<div class="grid">
<div class="unit four-fifths">
<p>Many thanks to <a href="https://www.yourkit.com/" target="_blank">YourKit, LLC</a> for providing a free license of
<a href="https://www.yourkit.com/java/profiler/index.jsp" target="_blank">YourKit Java Profiler</a> to kindly support the development of Easy Rules.</p>
</div>
<div class="unit one-fifth">
<img class="logo" src="{{ site.url }}/img/yourkit.png" alt="yourkit profiler"/>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>

@ -18,7 +18,32 @@ In the second part, we will add JMX capability to the business rule developed in
## Part 1 : Implementing the business rule
In this application, orders and customers are represented by the _Order_ and _Customer_ classes.
In this application, orders and customers are represented by the _Order_ and _Customer_ classes:
```java
class Order {
private long orderId;
private float amount;
//getters and setters
}
```
<br/>
```java
class Customer {
private long customerId;
private boolean isNew;
//getters and setters
}
```
First, let's implement the rule's logic by extending the `BasicRule` class:
@ -47,7 +72,7 @@ public class SuspectOrderRule extends BasicRule {
customer.getCustomerId(), order.getOrderId(), order.getAmount(), suspectOrderAmountThreshold);
}
// getters and setters for customer and order fields omitted
// getters and setters for customer and order fields
}
```
@ -112,7 +137,7 @@ In this tutorial, we need to expose the order amount threshold as a JMX attribut
```java
@javax.management.MXBean
public interface SuspectOrderJmxRule extends Rule {
public interface SuspectOrderJmxRule extends JMXRule {
/**
* Get the current suspect order amount threshold

@ -49,7 +49,7 @@ public class HelloWorldRule {
}
```
Then, we have to register an instance of this rule to an Easy Rules engine and launch the program with the following class :
Then, we have to register an instance of this rule in a Easy Rules engine and launch the program with the following class :
```java
public class HelloWorldSampleLauncher {
@ -99,10 +99,8 @@ If you run this tutorial, you would get the following output:
```
Are you a friend of duke? [yes/no]:
yes
10 sep. 2014 13:26:19 org.easyrules.core.DefaultRulesEngine fireRules
INFO: Rule 'Hello World rule' triggered.
Hello duke's friend!
10 sep. 2014 13:26:19 org.easyrules.core.DefaultRulesEngine fireRules
INFO: Rule 'Hello World rule' performed successfully.
```

@ -78,7 +78,7 @@ The `markAsAdult` method annotated with `@Action` will mark the person as adult
Finally, the `getPriority` method annotated with `@Priority` tells Easy Rules engine to fire this rule in first order.
Now, let's a class for rule 2:
Now, let's create a class for rule 2:
```java
@Rule(name = "alcoholRule",
@ -152,12 +152,10 @@ If you run this tutorial, you would get the following output:
```
Tom: Hi! can I have some Vodka please?
Oct 13, 2014 9:37:14 PM org.easyrules.core.AnnotatedRulesEngine fireRules
INFO: Rule alcoholRule triggered.
Sorry Tom, you are not allowed to buy alcohol.
Oct 13, 2014 9:37:14 PM org.easyrules.core.AnnotatedRulesEngine fireRules
INFO: Rule alcoholRule performed successfully.
```
As you can see, since Tom's age is under 18, he has not been allowed to buy alcohol as expected.
As expected, since Tom's age is under 18, he has not been allowed to buy alcohol.

@ -71,16 +71,21 @@ public class MyRule {
private BusinessData myBusinessData; //data to operate on
@Condition
public boolean checkConditions() {
public boolean when() {
//my rule conditions
return true;
}
@Action
public void performActions() throws Exception {
@Action(order = 1)
public void then() throws Exception {
//my actions
}
@Action(order = 2)
public void finally() throws Exception {
//my final actions
}
}
```
@ -98,16 +103,16 @@ respectively.
Easy Rules allows you to create complex rules from primitive ones. A `CompositeRule` is composed of a set of rules.
This is typically an implementation of the [composite design pattern](http://en.wikipedia.org/wiki/Composite_pattern).
This is typically an implementation of the <a href="http://en.wikipedia.org/wiki/Composite_pattern" target="_blank">composite design pattern</a>.
A composite rule is triggered if _all_ conditions of its composing rules are satisfied.
When a composite rule is applied, actions of _all_ composing rules are performed in the natural order of
A composite rule is triggered if **_all_** conditions of its composing rules are satisfied.
When a composite rule is applied, actions of **_all_** composing rules are performed in the natural order of
rules which is rules priorities by default.
To create a composite rule from two primitive rules, you can use the following snippet:
```java
//Create the composite rule from two primitive rules
//Create a composite rule from two primitive rules
CompositeRule myCompositeRule =
new CompositeRule("myCompositeRule", "a composite rule");
myCompositeRule.addRule(myRule1);

@ -17,5 +17,5 @@ Most business rules can be represented by the following rule definition:
Easy Rules provides an abstraction for each of these key points that define a business rule.
Next section will show you how to define a rule in Easy Rules either by extending a base class or by annotating your
Next section will show you how to define a rule either by extending a base class provided by Easy Rules or by annotating your
own domain class.

@ -11,10 +11,22 @@ Being able to dynamically reconfigure business rules at runtime in production sy
Thanks to JMX, Easy Rules can expose rules attributes to be managed via any JMX compliant client.
To make your rule manageable via JMX, you can register it in Easy Rules engine as a JMX managed rule:
To make your rule manageable via JMX, first you need to add the following dependency to your **_pom.xml_**:
```xml
<dependencies>
<dependency>
<groupId>org.easyrules</groupId>
<artifactId>easyrules-jmx</artifactId>
<version>{{site.version}}</version>
</dependency>
</dependencies>
```
Then, you can register it in Easy Rules engine as a JMX managed rule:
```java
RulesEngine rulesEngine = new DefaultRulesEngine();
JMXRulesEngine rulesEngine = new DefaultJMXRulesEngine();
rulesEngine.registerJmxRule(myRule);
```
@ -23,6 +35,6 @@ This will register your rule as a JMX managed bean with the following object nam
`org.easyrules.core.jmx:type=YourRuleClassName,name=YourRuleName`
By default, rule description and priority are exposed as JMX manageable attributes.
If you need to expose more specific attributes, you can extend the `Rule` interface and add getters and setters of your manageable attributes.
If you need to expose more specific attributes, you can extend the `JMXRule` interface and add getters and setters of your manageable attributes.
An example of using dynamic rule reconfiguration at runtime is provided in the [online shop tutorial]({{site.url}}/tutorials/dynamic-configuration.html).

@ -7,7 +7,7 @@ next_section: user-guide/managing-rules
doc: true
---
Easy Rules engine handles a registry of rules with unique names. Each instance of Easy Rules engine can be seen as a separate namespace.
Easy Rules engine holds a registry of rules with unique names. Each instance of Easy Rules engine can be seen as a separate namespace.
Rules are applied according to their natural order.
@ -46,7 +46,7 @@ You can specify these parameters at rules engine construction time.
## Create a default rules engine
To create a default Easy Rules engine and register a rule, use the following snippet:
To create a default rules engine and register a rule, use the following snippet:
```java
RulesEngine<Rule> rulesEngine = new DefaultRulesEngine();
@ -68,7 +68,7 @@ AnnotatedRulesEngine rulesEngine = new AnnotatedRulesEngine();
rulesEngine.registerRule(myRule);
```
As with default engine, you can fire rules using the following snippet :
As with the default engine, you can fire rules using the following snippet :
```java
rulesEngine.fireRules();

Loading…
Cancel
Save