j-easy / easy-rules

The simple, stupid rules engine for Java
https://github.com/j-easy/easy-rules/wiki
MIT License
4.92k stars 1.06k forks source link

I have a class and in that i have different conditions..based on each condition i have to call a separate method.so how do i configure rule in this case.since we dont have any if then else in easyrule. also i dont want to use one rule for each if condition. #49

Closed nagarajusattenapallikewill closed 8 years ago

nagarajusattenapallikewill commented 8 years ago

I have a class and in that i have different conditions..based on each condition i have to call a separate method.so how do i configure rule in this case.since we dont have any if then else in easyrule. also i dont want to use one rule for each if condition.Suggest me how to proceed in this case. Also i have a small question that will it support jdk1.6 or not??

Thank you in advance.

fmbenhassine commented 8 years ago

Hi,

Production systems and rules engine do not have "else" statement. You have to design one rule for the condition and another rule for "not condition". Here are some resources on that:

I think even drools does not have "else" statement. An interesting answer here.

So Easy Rules is no exception to that.

Also i have a small question that will it support jdk1.6 or not??

Easy Rules v1.x requires Java 1.6+ . Easy Rules v2.x is compiled and tested with Java 7 but it should be fine with Java 6 too. Please let me know if you have any issue with that.

Kind regards Mahmoud

nagarajusattenapallikewill commented 8 years ago

Thanks a lot for the quick reply benas

Here is the exception which i am getting when i tried to run the sample program with jdk1.60._45 version

java.lang.UnsupportedClassVersionError: com/om/ruleengine/MainApp : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Exception in thread "main"

Please suggest do i need to change anything.

fmbenhassine commented 8 years ago

No problem, you are welcome.

Please suggest do i need to change anything.

Either use Easy Rules v1.x with Java 6 or upgrade to Java 7 and use Easy Rules v2.x

nagarajusattenapallikewill commented 8 years ago

Even i tried with all other versions of easy rules.. like 1.3.0 , 2.0.0 , 2.10 , 2.2.0 Still i am facing the same issue.

fmbenhassine commented 8 years ago

Hi,

Here is a complete working example with easy rules 1.3 + java 1.6:

https://gist.github.com/benas/5d14f99dc85f431a85d48eeb8133997d

If you run the Main class, you should see: "it works" in the console.

Do you confirm?

Kind regards Mahmoud

nagarajusattenapallikewill commented 8 years ago

Thanks for the suggestion benas I will check and confirm.

fmbenhassine commented 8 years ago

Hi,

Have you got time to check?

Kind regards Mahmoud