Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working on setting up a plugin store utilizing pf4j for a SaaS platform #557

Closed
jingsewu opened this issue Jan 2, 2024 · 6 comments
Closed
Labels

Comments

@jingsewu
Copy link

jingsewu commented Jan 2, 2024

I hope this message finds you well. I'm currently working on setting up a plugin store utilizing pf4j for a SaaS platform. However, I've encountered a challenge that I'd appreciate your insight on.

Specifically, I'm exploring how to effectively manage a plugin that may have multiple versions in use. For instance, imagine Customer A using plugin P version 1.0 while Customer B utilizes version 2.0 of the same plugin.

One concern I have relates to handling these different versions within the same package. I'm aiming to ensure compatibility while preventing any repetition of beans in the Spring container. Any guidance or suggestions you might have regarding this matter would be incredibly valuable.

Looking forward to your expertise on this issue.

@decebals
Copy link
Member

decebals commented Jan 2, 2024

I don't have an answer to your problem but I'm curios to see if anyone faced a similar request and if they solved the problem.
In the same SaaS context I have a request for a plug-able features, each feature comes with a contribution for database layer (create new tables, alter existed tables, .. - using flyway or liquibase), service layer and so on. Things seem relatively simple until this SaaS intervenes (multi tenant, ..).

@jingsewu
Copy link
Author

jingsewu commented Jan 3, 2024

Indeed, in my current design, I've integrated multi-tenancy and established a table that tracks each tenant's installed plugins along with their respective statuses, whether they're marked as "STARTED" or "STOPPED."

However, the challenge arises when dealing with plugins that possess multiple versions yet belong to the same package.

Your insights on this matter would be greatly appreciated.

@decebals
Copy link
Member

decebals commented Jan 3, 2024

To make a summary, if I understood correctly you have an application (SaaS platform) with a bunch of plugins, there is the possibility that one or more plugins come in several versions.
You have a store (database table) where you keep some metadata related to what plugins (plugin <-> version pair) uses each tenant (customer) and the status of these plugins for that tenant (started, stopped, ..).
The idea is that your application uses the same logic (code base) for all tenants -> your application loads and starts a bunch of plugins for all tenants. If your plugins come with extensions => you use getExtensions(Class<T> type, String pluginId) method instead of getExtensions(Class<T> type) method because you need to check if a plugin is "visible" for a tenant.
Is what I say correct, can you add additional information?

@jingsewu
Copy link
Author

jingsewu commented Jan 3, 2024

Yes. But I am now using pf4j-spring to manage these plugins. So if Saas platform has different versions of plugins. Suppose different versions of plugins have the same package name and class name, in that case it will report an error. Because the same bean cannot exist in the same spring container.
Do I need to set up different spring containers for different versions of the plugin? Or do I need to specify that different versions of the plugin cannot have the same package name? Or is there another better solution here.

@decebals
Copy link
Member

decebals commented Jan 4, 2024

Maybe the best place for a such question is pf4j-spring, because the problem is related to the integration of pf4j in a spring application.

Suppose different versions of plugins have the same package name and class name, in that case it will report an error. Because the same bean cannot exist in the same spring container.

An idea is to create a different spring ApplicationContext (in SpringPlugin) for each plugin version when you have multiple versions.

@jingsewu
Copy link
Author

jingsewu commented Jan 5, 2024

Thank you for your reply. Maybe it is a good idea to create a different spring ApplicationContext (in SpringPlugin) for each plugin version. I will close this issure and search more ideas form pf4j-spring.

@jingsewu jingsewu closed this as completed Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants