SPI class loader isolation #60
Replies: 1 comment 9 replies
|
Hi @karelkryda, thanks for the detailed write-up — this is a good question and it overlaps with another request we have (optional DB drivers), so we want to solve it generally rather than case-by-case. Short answer: Don't try to merge your extension into our fat jar. Instead, we're adding a supported external extensions directory that gets added to the runtime classpath without rebuilding the AP jar. You drop your extension jar (and any deps we don't already ship) into that folder, and your SPI implementations are picked up automatically. How it is supposed to work: The So the deployment model becomes: or in Docker, mount a volume at How to package your extension (the important part): A full shadow/fat jar of your extension is exactly what causes the clashes you're worried about, because you'd be re-bundling copies of things the AP already has (Spring, phase4, ph-commons, the AWS SDK, etc.) on a flat classpath. Instead, build a jar that contains only what the AP doesn't already ship:
On isolated class loaders: To set expectations honestly - this gives you a shared external classpath, not per-extension child-first classloader isolation. In practice the provided-scope discipline above removes the version conflicts for the vast majority of cases, so we're going with this first because it's robust and simple. True classloader isolation (a plugin framework like PF4J, or JPMS module layers) is a much larger change — we're keeping it on the table as a follow-up only if a concrete clash can't be resolved by dependency alignment. If you hit one, please report the specific collision and we'll look at it. We'll wire this up, test it, and add a "Deploying extensions / custom drivers" page to the Wiki. I'll follow up here once it's available. |
Uh oh!
There was an error while loading. Please reload this page.
Hey @phax,
we are currently deploying your AP and we need to connect it to our Artemis MQ backend. We used forwarder SPI for it and also enriched it with few other functionalities needed for us. It mainly uses Artemis MQ client, S3 and DynamoDB (enhanced).
Since your AP supports S3 bultin (and few other low level deps), my question is how to properly "pack" the resulting SPI extension for compatibility.
Generally, fat jar (shadowJar) - with all deps for our SPI included - should be the right packaging mechanism, however I think the final AP runtime dependencies of yours and ours will clash.
To the question, could you please help us determine the right way to do it? How to properly pack it? How to properly start the AP to load our SPIs? Is there a way to have isolated class loaders?
Thank you in advance!
All reactions