We wrote a framework which uses spring under the hood. This framework is used by two applications. It is possible to configure a production server with running application1 OR application2 OR application1 and application2.
Now I am looking for a spring mechanism which works similar to OSGI Extension-point idea, so that each application can “contribute” to framework without a configuration file where all applications need to be listed.
Complete project-structure (simplified ;-)):
Framework: A, IPlugin, A.xml
Application 1: B extends IPlugin, b.xml
Application 2: C extends IPlugin, c.xml
Explenation:
“A” uses a list of IPllugin which will be called if a specific task has to be achieved.
I only found the spring way of declaring A as prototyp and setting “B” and “C” as attributes. Therefore I have to list both explicitly in A.xml. But I want to configure contributions in b.xml and c.xml.
Questions:
-
Is there a possibility in spring to be modified if an instance of a special kind of bean is created?
-
Is there something similar to OSGI/Eclipse extension-point in spring out of the box?
-
Any other suggestions?
My solution was to create a “registry” in the framework project which will be created in spring with scope “singleton”. So each plugin can contribute to this registry because it is available to all plugins during runtime of the application server. Since each plugin should be created new I used the help of a factory which creates new plugin-instances from spring-context.
More details can be found in a small article I wrote and which can be downloaded