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

Spring application with spring enabled plugins #22

Closed
michaelruocco opened this issue Nov 13, 2018 · 2 comments
Closed

Spring application with spring enabled plugins #22

michaelruocco opened this issue Nov 13, 2018 · 2 comments

Comments

@michaelruocco
Copy link
Contributor

Hi,

I have been playing with this framework and managed to get an initial project working which is a spring application which makes use of plugins through the pf4j framework. The git repo is here: https://github.com/michaelruocco/spring-boot-plugin-example.

What I would now like to do is to make use of spring within the plugins themselves. I have had a go at adding this following this element of the demo: https://github.com/pf4j/pf4j-spring/tree/master/demo/plugins/plugin2/src/main/java/org/pf4j/demo/hello, however I am having some issues.

The changes are pushed to a branch here: https://github.com/michaelruocco/spring-boot-plugin-example/tree/spring-enabled-plugin. I can see that the problem is that the ChannelIdProvider bean is not being injected into the extension but I am not sure why. I am also confused as to why the .log message from BidvAliasLoaderPlugin are not being printed out on startup. I suspect that I am doing something wrong but I am not sure what. Any help you can provide would be much appreciated.

Thanks.

@decebals
Copy link
Member

@michaelruocco
I will try to help. I wrote in a comment (I didn't find the link) that I am not expert in Spring, so, from this reason I don't add to much comments on this subject (PF4J in Spring).
Maybe other people that use PF4J in Spring applications can help us to improve the interoperability between PF4J and Spring.

@michaelruocco
Copy link
Contributor Author

michaelruocco commented Nov 16, 2018

@decebals for info I found the solution to this problem. It turns out the project appeared to be working as the plugins were just being picked up from the classpath. However on debugging the plugin loading a bit more closely I found that the plugin classes were not being fired up correctly (which explains my confusion around the .log messages from BidvAliasLoaderPlugin not being printed out on startup.)

In order to get them started correctly I needed to set the -Dpf4j.pluginsDir on the spring boot application when starting it up. I added a jvmArgs argument to my bootRun command like this:

bootRun {
    classpath += configurations.provided
    jvmArgs = [ "-Dpf4j.pluginsDir=${rootDir}/internal-plugin/build/libs" ]
}

And this meant the SpringPlugin is now loaded correctly and works as expected.

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