Comments (13)
After I read again the description of the issue I want too add more clarifications:
Can you show me some example to see how to do that Autowired of a plugin class (extending SpringPlugin) thru Spring Boot?
You cannot. In documentation Autowired
is used only to inject extensions.
The idea is to load the plugin without package the plugin in a jar, i have just the plugin in the source code. I want the two ways, load from a jar and load without packaged in jar (is this possible?).
Yes. I use this approach in my projects (but I don't use Spring). I run my application in development from my IDE (IntelliJ). In this mode (development) my application together with all the plugins looks like a regular multi module application.
In production (deployment
mode in PF4J - it's the default) I packages the plugins in JARs.
from pf4j-spring.
OK. Please share the project maybe I have some time to take a look.
from pf4j-spring.
But i don't see any example of loading this plugin via @Autowired (in Spring Boot) like you say in the documentation
from pf4j-spring.
Hello, thanks for answering.
I mean an example of use of this structure public class HelloPlugin extends SpringPlugin written in your example.
How/where i should obtain/instantiate the SpringPlugin in the spring boot application? (i dont see it in the demo)
Greetings.
from pf4j-spring.
I don't understand your question, and what you are looking for. Take a look at demo application to see a concrete example. They are some examples/projects available on internet.
How/where i should obtain/instantiate the SpringPlugin in the spring boot application? (i dont see it in the demo)
You don't need to obtain/instantiate the SpringPlugin
. You need to obtain only the extensions in your application. A concrete (Spring) plugin is instantiated internally by PF4J. PF4J-Spring is a simple adapter of PF4J for Spring applications.
from pf4j-spring.
So, if i do something like this, i will obtain that HelloPlugin implementation?
PluginManager pluginManager = new SpringPluginManager();
List<PluginWrapper> helloplugins = pluginManager.getPlugins();
Or how can i access to this HelloPlugin?
from pf4j-spring.
So, if i do something like this, i will obtain that HelloPlugin implementation?
SpringPlugin plugin = (SpringPlugin) pluginManager.whichPlugin(MyService.class);
where MyService
is a class from your plugin.
You can also try with PluginManager#getPlugin(String pluginId)
or PluginManager#getStartedPlugins
. The result is a PluginWrapper
, but you can continue with PluginWrapper#getPlugin
to retrieve the concrete plugin instance.
from pf4j-spring.
So, if i do something like this, i will obtain that HelloPlugin implementation?
SpringPlugin plugin = (SpringPlugin) pluginManager.whichPlugin(MyService.class);where
MyService
is a class from your plugin.You can also try with
PluginManager#getPlugin(String pluginId)
orPluginManager#getStartedPlugins
. The result is aPluginWrapper
, but you can continue withPluginWrapper#getPlugin
to retrieve the concrete plugin instance.
That is not correct, it is:
PluginWrapper plugin = pluginManager.whichPlugin(HelloPlugin.class);
But that doesn't work, it returns null (or with getPlugin also returns null). Debugging it, within the class AbstractPluginManager the map plugins is always empty:
/**
* A map of plugins this manager is responsible for (the key is the 'pluginId').
*/
protected Map<String, PluginWrapper> plugins;
So, it is returning always null.
Remember, im testing it without package it in a jar, the plugin (that HelloPlugin referenced in your documetantion) is just in source code of my main app.
from pf4j-spring.
Debugging it, within the class AbstractPluginManager the map plugins is always empty
My advice for you is to start with quickstart or/and Spring demo.
Did you started your application in development mode? Are you sure?
I'm sorry but I cannot help you with more information.
from pf4j-spring.
I have the project in GitLab, could i share with you? and then you can test it and see what things are wrong or not compatible? the main app is Spring boot (last version)
from pf4j-spring.
Could you give me permissions to push a new branch (issue/37) , i have cloned this:
https://github.com/pf4j/pf4j-spring.git
from pf4j-spring.
I did a push to master. For running the test:
-
For building project pf4j-spring-boot-demo:
- 1) mvn clean install -Pmain-build
- 2) mvn clean install -Pjar-client-build
Then build project pf4j-spring-boot-demo-jar-plugins:
- 3) mvn clean install -
For running the demo test, run the spring boot app: org.pf4j.demo.boot.MainApp in pf4j-spring-boot-demo project.
I hope this can help.
from pf4j-spring.
@Vikcen What is the status of this issue? Can we close it?
from pf4j-spring.
Related Issues (20)
- update dependencies to newest spring 5.+ versions HOT 1
- Concrete bean could not be received from the application context HOT 1
- SpringPlugin start/stop/start results in Exception HOT 2
- Loading plugin on-runtime : Ambiguous hander methods mapped & ConcurrentModificationException when unregistering routes
- I use it SpringPluginManager, It seems to be a single case. HOT 4
- How to update the βList<Greeting>β while some plugins unloaded and deleted? HOT 4
- How to add integration tests for the plugin?
- self contained example HOT 1
- Jpa in plug-in not working HOT 1
- Hi author, Can I send a pull request to PF4J-Spring to support the Spring parent-child context οΌ
- Injecting beans from plugin in application doesn't work HOT 2
- run exception on pf4j-spring demo
- pf4j plugin needs to refresh and detect changes automatically with spring HOT 6
- How to get this repo versions release notes? HOT 2
- Problems with Using Pf4j-Spring HOT 1
- The real implementation cannot be accessed through the api interface. HOT 2
- When 'spring-boot-devtools' is introduced in the project, the extensions are not available. HOT 2
- How do you extend with kafka HOT 1
- Retrieve Resource from Inside Plugin HOT 1
- When will plan support Spring6.x ? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pf4j-spring.