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

can extension add name attribute #245

Closed
zhaoyta opened this issue Oct 25, 2018 · 4 comments
Closed

can extension add name attribute #245

zhaoyta opened this issue Oct 25, 2018 · 4 comments

Comments

@zhaoyta
Copy link

zhaoyta commented Oct 25, 2018

can extension add name attribute.
some times i have multi extension implement.
i select use which extension on runtime . every time i have to scan extension class name to select.

it is very inconvenience.

@decebals
Copy link
Member

decebals commented Oct 25, 2018

Can you add more information please? Maybe some pseudo code.
In some of my applications I have (probably) de same case as you.
In UI (user interface) I present a drop down (combo box) with a all extensions available for an extension point.
But it's the responsability of UI (rendering layer) to present a nice name.
For example, for demo project that comes with PF4J, for Greeting extension point we have three extensions available:

  • WelcomeGreeting (from plugin1)
  • HelloGreeting (from plugin2)

You can use PluginManager#getExtensionClasses to achive all extension classes for Greeting extension point.
Now, to display a nice list with all extensions you can use as extension name something like this (pseudo code):

extensionClass.getSimpleName().removeSuffix("Greeting");

In this case the displayed labels in list are: Welcome and Hello.
So, it's all about convention. In some projects I used "Extension" as suffix.

If the solution presented above it's not what you want, please add more information about your use case.

@zhaoyta
Copy link
Author

zhaoyta commented Oct 25, 2018

my current way is similar to you .but user may be write some code to manage this extension. these code can omit for user if framework supply to direct to extension method by simple name .

@decebals
Copy link
Member

@zhaoyta
And, do you have a clear technical proposal? Can you create a PR to talk more concrete?

@decebals
Copy link
Member

In the end I think that the convention to have the extension ID (something unique in an application) equals with the class name (including the package name) is perfect. I think that a configuration approach vs convention is not a good idea in this case (it comes with a complexity that is not necessary).
A complete new name attribute can be a solution in some cases. In my projects that uses PF4J I didn't identified a such case. In the end, to display the extension name in UI maybe you need some i18n support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants