Coder Social home page Coder Social logo

Comments (6)

decebals avatar decebals commented on May 9, 2024

Is https://github.com/decebals/pf4j/blob/master/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java#L559 what you are looking for?

from pf4j.

defec8edc0de avatar defec8edc0de commented on May 9, 2024

I tried to use it like this:

...
pluginManager.startPlugins();
myExtensions = pluginManager.getExtensions(IMyExtensionPoint.class);
for (IMyExtensionPoint currentExtension: myExtensions) {
            Plugin plugin = pluginManager.whichPlugin(currentExtension.getClass()).getPlugin();
            ...
}
...

and it couldn't find the plugin, to the extension (classloaders where not equal..)

If this helps:

  • My extensions extend a class: AbstractExtension (extends LogOutputStream implements IMyExtensionPoint, IMyExtensionPoint extends ExtensionPoint)
  • in whichPlugin() the classloader of MyExtension.class is the default app launch class loader...

My current workaround for this problem:

  • extend DefaultPluginManager and override whichPlugin with:
    @Override
    public PluginWrapper whichPlugin(Class<?> clazz) {
        String extensionClassName = clazz.getName();
        for (PluginWrapper plugin : getStartedPlugins()) {
            String pluginClassName = plugin.getPlugin().getClass().getName();
            if (extensionClassName.contains(pluginClassName)) {
                return plugin;
            }
        }
        System.out.println("Couldn't find Plugin to class: "+ clazz.getName());
        return null;
    }

Obvious drawback...the Extension MUST be declared inside the corresponding plugin class.

from pf4j.

decebals avatar decebals commented on May 9, 2024

I am in vacation. I will come back Monday.

from pf4j.

decebals avatar decebals commented on May 9, 2024

So, your MyExtension is a default extension (it's declared in application not in a plugin)?

from pf4j.

defec8edc0de avatar defec8edc0de commented on May 9, 2024

MyExtension extends AbstractExtension extends LogOutputStream implements IMyExtensionPoint extends ExtensionPoint ....over a view inheritances its a default extension.

MyExtension is implemented as inner class of the Plugin.

from pf4j.

decebals avatar decebals commented on May 9, 2024

@s3phir0th Did you solve this issue? I used Plugin.whichPlugin in SpringExtensionFactory and everything seems OK.

from pf4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.