How to write custom helper methods for by business rules


I want to write custom methods which I can use while defining my business rules. This can be index time rules or search time rules. 


You could follow the steps mentioned below to create a Java class with helper methods that you require and then use them in your business rules.

  1. Create the Java class with the helper functions required. You could have a look at the structure of DroolsHelper.class mentioned here -
  2. Compile the Java class using - "javac com/rules/". 
  3. To create a JAR file run - "jar cf jar-name.jar com/rules/MyHelper.class"
  4. Place the JAR in the following directory "$LWS_HOME/app/webapps/lwe-core/lwe-core/WEB-INF/lib/" -
  5. Create your rule in any of the .drl files under "$LWS_HOME/conf/solr/cores/[core-name]/conf/rules/"
    1. Don't forget to import the methods you have defined in the .drl file - "import function come.rules.MyHelper.*;"
    2. Use the functions you have defined in the "then" section of your rule file. 
  6. Restart the LWS server



Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk