picku
picku

Reputation: 157

Dynamic loading of spring bean from jar along with dependent beans

I am running a spring application.

My requirement is user will be placing a plugin jar file at run time at designated lib folder location. This plugin jar file will have spring application context file as well. I want to load this jar, means all the classes - spring beans and all its dependent beans/components(this is important), from this jar file at run time.

I do not want to create new/child application context and want to use the existing spring bean context loaded at application start up.

I reffered to few other similar threads/questions on SO and could resolve the issue of dynamically loading of spring beans. But i am not able to resolve issue of loading all the dependent beans for the spring beans.

Could you please provide any pointers/hints to dynamically load all the dependent beans of spring bean(which is also)loaded at run time?

Thanks in advance, Picku

Upvotes: 2

Views: 694

Answers (1)

Michael Wiles
Michael Wiles

Reputation: 21186

If you want to be able to load the plugin after startup you are not going to get away with not creating another application context as a child.

I'd suggest you do exactly this and then create some hooks in parent context whereby your plugin will integrate itself.

The alternative is to include that plugin.jar in the main classpath and then restart the application to include the plugin.

Upvotes: 3

Related Questions