Is it possible to integrate plugin with Spring framework? Follow
Answered
Hi,
I'm developing an IntelliJ plugin and wanted to know if is possible to integrate it with Spring framework for autowire and stuff. If is possible, could you provide some guidance on this? Thanks in advance!
Please sign in to leave a comment.
Hi Ricardo,
I recommend checking Spring API and SDK Docs in general if you are not familiar with it yet.
Hi Karol, thanks for your guidance. But what I really want to know if there is a possibility to use spring's dependency injection in the development of a plugin for IntelliJ? I saw in other forum question that IntelliJ uses dependency injection based on picocontainer but I wasn't able to make it work in my action based plugin neither, so I want to try with spring dependency injection. Is there a way to do it? If not can you provide me guidance on dependency injection for my action based plugin? Thanks again.
Hi Ricardo,
I misunderstood your question then, sorry about that.
I wouldn't recommend using Spring Framework. The approach for plugins is to use services when we need them, so e.g. your action should retrieve a service just before calling it as described in Retrieving a Service. The service is created only if it wasn't created before. It makes the plugins more performant because there is no need to build the objects graph in advance, which would slow down the plugin loading.
If you wanted to use dependency injection for code testability, then the approach for testing plugins is different from "standard" unit testing. We recommend implementing functional tests over unit tests as explained in the Testing Plugins article. There is rarely need for mocking something.
If you want to provide some dumb/mock implementations of services for testing purposes though, you can provide them via
testServiceImplementation
attribute as mentioned in Declaring a Service section.