Skip to content

Add guide on adding custom Java function library#543

Open
edison23 wants to merge 1 commit intomasterfrom
docs/master/add/use-custom-java-function-libraries-in-midpoint
Open

Add guide on adding custom Java function library#543
edison23 wants to merge 1 commit intomasterfrom
docs/master/add/use-custom-java-function-libraries-in-midpoint

Conversation

@edison23
Copy link
Copy Markdown
Contributor

This guide / use case is based on a question and subsequent solution provided in the public mailing list: https://lists.evolveum.com/pipermail/midpoint/2026-January/008670.html

I humbly ask for a fact-check / review of the article from someone on the eng (or dev) team. Thank you.

This guide / use case is based on a question and subsequent solution provided in the public mailing list:
https://lists.evolveum.com/pipermail/midpoint/2026-January/008670.html
Copy link
Copy Markdown
Contributor

@licehammer licehammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can expect the person reading this is a java programmer.

:page-description: Package Java classes to JAR files to use them as custom functions in midPoint expression scripts

MidPoint makes compiled Java classes available to all script expressions similarly to functions in expression function libraries.
Methods of public classes packaged in JAR files and placed in midPoint home directory are accessible in expressions using their fully qualified class name.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it can be placed anywhere on classpath (which includes MIDPOINT_HOME/lib). You can then address using fully qualified class name or use java import mechanism.

Requirements and constraints:

* Classes must be `public`.
* Methods called from expression scripts must be `public static`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work even with non-static methods, but you would have to instantiate the class first which is an overkill for most scripts.

* Classes must be `public`.
* Methods called from expression scripts must be `public static`.
* The class and its dependencies must be compatible with the JVM version midPoint runs on.
* Do not use package or class names that would collide with those already used by midPoint.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use colliding class names. That's why Java have packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants