hank-cp / sbp

Plugin framework for Spring Boot based on pf4j.
Apache License 2.0
205 stars 67 forks source link

How to customize the plugin manager? #12

Closed fabioformosa closed 4 years ago

fabioformosa commented 4 years ago

I've tried to define a custom plugin manager

@Configuration
public class AppConfig {

    @Bean
    public SpringBootPluginManager pluginManager() {
        return new CustomPluginManager();
    }
   ...
}

public class CustomPluginManager extends SpringBootPluginManager {
 ...
}

and I got this error:

Caused by: java.lang.ClassCastException: class org.mypackage.CustomPluginManager cannot be cast
 to class org.laxture.sbp.SpringBootPluginManager (org.mypackage.CustomPluginManager is in 
unnamed module of loader 'app'; org.laxture.sbp.SpringBootPluginManager is in unnamed module 
of loader org.pf4j.PluginClassLoader @69228e85)

How can I define a CustomPluginManager that extends SpringBootPluginManager?

hank-cp commented 4 years ago

org.laxture.sbp.SpringBootPluginManager is in unnamed module of loader org.pf4j.PluginClassLoader

this doesn't smell good, SpringBootPluginManager should be loaded by main classLoader. I will fork your poc project to demonstrate it and come back with a PR later.

fabioformosa commented 4 years ago

Ok, you're very kind helping me. Yesterday I submitted in poc project also the branch feature/plugin-loader-for-springboot with an attempt to extend JarPluginLoader for executable springboot jar, but it suffers for the issue linked to SpringBootPluginManager override.

hank-cp commented 4 years ago

see https://github.com/fabioformosa/sbp-pluggable-project/pull/1

I know it's ugly, please see the reason