Call library rule functions from plugin?

We have several very large libraries of functions written in BeanShell as rules.
We need to call a couple of these functions from a plugin. Is that possible?

(To be clear, we know there’s a way to expose classes from the plugin to the beanshell rule. This is about the opposite path, executing the beanshell function from the plugin.)

SailPointContext implements RuleRunner, which has two runRule() methods. You can use them to invoke rules programmatically, provide suitable parameters and get an Object back.

What parameters to provide and what object you get back depends on your rules.

I see. A way to run a “whole” rule.
Maybe not a way to invoke a method in a rule that is normally included by reference as a library?

You can have a new rule to run a single function from your rule library, or I guess you can make use of the script version of RuleRunner.

java.lang.Object	runScript(Script script, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<Rule> libraries)
Run a script and return the result, also include any passed in libraries into the script's runtime context.

You can create a Script object by providing the source as a String.

Ah, these are great suggestions! Most premium.
Great thanks!

Since the runRule API takes a Map of parameters and return an Object, why not add a proxy method as the main body in your rule library. Take an additional functionName parameter to determine which method in the rule library to call and how to extract parameters from the Map.

Beats having lots of extra rules as entry points, or messing with source code with Script object.

Perhaps, but probably a single separate rule per library that does this instead?
The libraries are being called from existing rules and workflows currently, and any change in the rule itself feels dangerous.

Agreed, that’s probably the safest.