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

Question: Migrate from other plugin system #578

Open
makiam opened this issue Apr 5, 2024 · 4 comments
Open

Question: Migrate from other plugin system #578

makiam opened this issue Apr 5, 2024 · 4 comments
Labels

Comments

@makiam
Copy link

makiam commented Apr 5, 2024

I'm researching the possibility of migrating code from another Plugin Framework and there are several functions that I can't express using pf4j.
Current framework allows me to register some localized resources inside plugin and then access them in code. Ex. I can declare in my plugin descriptor (i.e xml file)

    <resource type="TranslateBundle" id="polymesh" name="polymesh"/>
    <resource type="UITheme" id="polymesh" name="polymesh/theme.xml"/>

it is also possible for several different localized versions of a resource to be available provided by different plugins.

So this resources can be accessed from application Plugin and UITheming managers like this:
var name = Translate.text("polymesh:menu.lathe");
Another functionality is to register function in plugin to be accessed from other parts application this way:
Register:

        <export method="getString" id="preferences.getString" >
            Get a String value

            @param owner String name of the preferences owner
            @param name  String name of the preference value

            @return the preference value as a String
        </export>


NB. Method call can be documented here!
Call:
PluginRegistry.invokeExportedMethod("preferences.getString", "spmanager", "userName");

So the question is such functionality can be adopted with pf4j
Thanks.

@decebals
Copy link
Member

decebals commented Apr 6, 2024

Current framework allows me to register some localized resources inside plugin and then access them in code.

Probably you can use ClassLoader/PluginClassLoader to achieve this.

So this resources can be accessed from application Plugin and UITheming managers like this

The plugin that contains the resources can be declared as a dependency for other plugins => in that plugins you can use ClassLoader#getResource or ClassLoader#getResources

Another functionality is to register function in plugin to be accessed from other parts application this way

Put these methods in a static class?

I'm sure that you can emulate all these behaviors in your pf4j based application. In the end you need to think in terms of functionalities and not in the terms in which that functionality was implemented in the old plugin system (xml stuff, ..). If you insist to preserve the old API you can add a tiny layer over PF4J to obtain the same API.

@makiam
Copy link
Author

makiam commented Apr 13, 2024

Main question is how to register resources/methods inside plugin system. Once I try to migrate codу I add implements ExtensionPoint and apply @extension annotation and its works. But this way cannot be applied to static resources
Looks like I need extra pass when plugin started to process my xml metadata (But this not looks handsome)

@decebals
Copy link
Member

Start small/lean with a quickstart project which highlights your problem in a narrow context. Share with us your quickstart project. It's more simple and easy to follow.
As I mention in my previous project, my feeling is that you are stuck thinking in the old framework. Try to think more freely, to think about what you have to do, what you want to achieve, and not how to translate in a 1:1 ratio code from the old framework into pf4j.

@makiam
Copy link
Author

makiam commented Apr 20, 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