| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| README.md | 2020-05-17 | 5.4 kB | |
| v4.0.0 source code.tar.gz | 2020-05-17 | 58.2 kB | |
| v4.0.0 source code.zip | 2020-05-17 | 239.5 kB | |
| Totals: 3 Items | 303.2 kB | 0 | |
This is a major release which is based on Java 8. This version comes with a number of new features and bug fixes (See detailed list below). Moreover, some breaking changes have been introduced to fix a couple of design inconsistencies in v3. Here are the major changes:
- Introducing a new
Factdomain concept which replaces theMap<String, Object>data structure used in v3. This new concept has a number of advantages like type safety, better encapsulation and a cleaner API. - MVEL/SpEL conditions now throw runtime exceptions instead of catching them and returning
false. This makes it possible to correctly unit test conditions as well as listen to evaluation errors with a rule listener (a new methodRuleListener#onEvaluationErrorhas been introduced for this purpose). - SpEL conditions and actions should now use the
#{ ... }template by default. This is configurable but it has been made the default to be consistent with Spring's default template parser.
Moreover, thanks to this major Java version upgrade, a lot of improvements have been introduced in the API (like using default methods in interfaces, adding @FunctionalInterface where appropriate, etc) as well as in the code base (using lambdas and streams where it made sense, using new reflection APIs introduced in Java 8, etc).
Here is the list of issues resolved in this release:
New features
- issue [#276]: Add
Factconcept - issue [#250]: Add a
clearmethod inFactsAPI - issue [#259]: Add
BeanResolvertoSpELActionandSpELCondition
Bug fixes
- issue [#267]:
Facts#asMapshould return an immutable map or a copy of the facts - issue [#211]:
MVELConditiondoes not re-throw exceptions - issue [#257]: Inconsistent SpEL expression templating between
SpELRuleandSpELRuleFactory
Enhancements
- issue [#268]: Improve Javadoc of
Facts#iteratorto mention that it should not be used to remove facts - issue [#253]: Add default methods in interfaces
I would like to thank all contributors who made this release possible by reporting issues, testing fixes, requesting features and participating in discussions: @readilychen, @elitacco, @snok3r, @AleksandrPalchuk, @turiandras, @Alexey1Gavrilov, @yunfengwang and @R-Gerard ! Thank you all for your contributions!
A special BIG thank you to @zhhaojie for following up on issues, helping in design discussions and all the time and effort put on Easy Rules!
Migration guide from v3 to v4
Moved APIs
The following APIs have been moved between packages for better cohesion:
RulesEngineParametershas been moved from packageorg.jeasy.rules.coretoorg.jeasy.rules.apiCompositeRuleand its implementations (ActivationRuleGroup,UnitRuleGroupandConditionalRuleGroup) have been moved from the root packageorg.jeasy.rules.supportto a dedicated packageorg.jeasy.rules.support.compositeRuleDefinitionReaderand its implementations (AbstractRuleDefinitionReader,YamlRuleDefintionReaderandJsonRuleDefintionReader) have been moved from the root packageorg.jeasy.rules.supportto a dedicated packageorg.jeasy.rules.support.reader
Action: Update import statements where the aforementioned classes are used
Removed APIs
For both MVEL and SpEL modules, the ParserContext is now passed to rules and rule factories at construction time. Hence, all overloaded methods where the parser context is passed as a parameter (which are now useless) have been removed:
- Methods
org.jeasy.rules.mvel.MVELRule.when(String, ParserContext)andorg.jeasy.rules.mvel.MVELRule.then(String, ParserContext) - Methods
org.jeasy.rules.mvel.MVELRuleFactory.createRule(Reader, ParserContext)andorg.jeasy.rules.mvel.MVELRuleFactory.createRules(Reader, ParserContext) - Methods
org.jeasy.rules.spel.SpELRule.when(String, ParserContext)andorg.jeasy.rules.spel.SpELRule.then(String, ParserContext) - Methods
org.jeasy.rules.spel.SpELRuleFactory.createRule(Reader, ParserContext)andorg.jeasy.rules.spel.SpELRuleFactory.createRules(Reader, ParserContext) - Methods
org.jeasy.rules.support.AbstractRuleFactory.createSimpleRule(RuleDefinition, ParserContext)andorg.jeasy.rules.support.AbstractRuleFactory.createCompositeRule(RuleDefinition, ParserContext)do not take aParserContextas parameter anymore.
Action: Pass the parser context at construction time (to the rule or the rule factory) and call new methods that do not take the parser context as parameter.
Changed APIs
Due to the introduction of the new Fact concept (issue [#276]), the following method signatures have been changed:
Facts#put(String, Object)does not return the previous associated value if any, the return type is nowvoidFacts#remove(String)does not return the removed fact anymore, the return type is nowvoidFacts#iteratornow returns aIterator<Fact>instead ofIterator<Map.Entry<String, Object>>
Actions:
- Update the assigned variable type where those methods are called.
- For
Facts#put, since the previously associated value if any is not returned anymore, one can query theFactsAPI to see if there is a fact mapped for the given name before callingput. - For
Facts#remove, since the removed fact is not returned anymore, one can query theFactsAPI to get the fact before removing it.