Programatically refresh spring bean definitions

I recently wrote a plugin that hooks into the IntelliJ spring support to register custom spring beans based on external metadata.  The custom beans provider is registered like so:

<customModuleComponentsDiscoverer implementation="com.dealer.rc.plugin.BeansProvider" />

This works fine and the little bean icon shows up when I load the project.  I also added a toolbar that shows the injected beans and has a "refresh" button, but I couldn't figure out how to refresh the spring data from my code.  I basically want the same effect as if I'd re-imported my maven projects.  Is there an easy way to accomplish this?  I have access to the Project object.

4 comments
Comment actions Permalink
Official comment

If I understand correctly, you should implement your own ModificationTracker which gets incremented by the "Refresh" button and return it from com.intellij.spring.model.custom.CustomModuleComponentsDiscoverer#getDependencies

Comment actions Permalink

Thanks for the quick response!

I added a SimpleModificationTracker to my ProjectComponent, and overrode getDependencies (I'm extending SpringImplicitBeansProviderBase, not CustomModuleComponentsDiscoverer directly).  I look up the correct ProjectComponent off the module and get the tracker, and return that in an Object[].  I also added the following to the refresh button created by my ProjectComponent:

tracker.incModificationCount();

I've verified that getDependencies is called and my tracker is added (I also tried adding the trackers from super.getDependencies), and I've verified that my refresh button increments the tracker, but nothing seems to be happening.  Am I missing something else?

0
Comment actions Permalink

This will only refresh the model/underlying beans provided. Highlighting in editor has to be restarted explicitly via com.intellij.codeInsight.daemon.DaemonCodeAnalyzer#restart()

0
Comment actions Permalink

Awesome, that was the missing piece.  Thanks!

0

Please sign in to leave a comment.