Short version: How can I disable the MVEL strict mode using the new KIE API?
I know that there is a configuration property "drools.dialect.mvel.strict" that can be set using the old KnowledgeBuilder API. However I can not find a way to accomplish the same with the new API.
Long version: I have an object method, called Object attribute(String name), and the result can be many different types. Sometimes could be a List, others String or whatever. Now in order to use that method I have to use a lot of casting or drools throws exceptions. For the following example:
$entity : RootEntity( attribute('authors') != null &&
attribute('authors').size() >= 3 &&
attribute('authors')[2] == 'whatever' )
I get errors like this:
Unable to Analyse Expression attribute("authors").size() >= 3:
[Error: unable to resolve method using strict-mode: java.lang.Object.size()]
Unable to Analyse Expression attribute("authors")[2] == "whatever":
[Error: unknown collection type: class java.lang.Object; property=]
In order to make this work with the strict typing enabled I have to type the same expression as such:
$entity : RootEntity( attribute('authors') != null &&
((java.util.List) attribute('authors')).size() >= 3 &&
((java.util.List) attribute('authors'))[2] == 'whatever' )
Which can be disabled with the strict typing option.