0

I have written below part in my drool file. I am not getting any compilation error, but it's not executing at run time. can we read data from properties file in the drool or do we have any alternative for reading data from config file. can you please help me on this.

Piece of code added in Drool :

InputStream fileInput = Thread.currentThread().getContextClassLoader().getResourceAsStream("rules.properties");
Properties properties = new Properties();
System.out.println("Client From Properties : "+fileInput);
properties.load(fileInput);
fileInput.close();
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • where do you have this code? What do you mean by "it's not executing at runtime"? Do you have any exception during runtime? Where do you have the properties file? – Esteban Aliverti Nov 28 '16 at 23:05

1 Answers1

1

Did you write that code snippet in a different java class and called it through the drool?

  1. Write the code inside a class called Test.java :

    public class Test { public static void testFileRead(){ //Your code } }

  2. import that function in the .drl file,

    import function Test.testFileRead;

  3. Execute the method on the "Then" section of your rule

    Then

        testFileRead();
    
Hemadri
  • 56
  • 3