Details
-
Improvement
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
-
None
Description
SpringBridgeHstComponent is the bridge class of the Spring Bean Bridge integration [1] and gets a reference to a spring bean (type of HstComponent) lazily.
And it invokes on #init() method of the spring bean.
This is problematic in the following case:
- when multiple SpringBridgeHstComponent component configurations are referring to single spring bean (type of HstComponent),
- when each SpringBridgeHstComponent component configuration defines different parameters,
- and when the spring bean is 'singleton' (default) bean
- because one SpringBridgeHstComponent component instance invokes #init() on the singleton spring bean and sets it to a member variable and another SpringBridgeHstComponent component instance invokes #init() on the singleton spring bean and sets it to a member again...
- As a result, the singleton spring bean (type of HstComponent) can be set with different parameters than the expected configuration.
Users can choose to either:
(a) define a separate spring bean (type of HstComponent) per SpringBridgeHstComponent component configuration
(b) or set the shared spring bean (type of HstComponent) as 'prototype'.
The choice (b) is an easier choice in most cases. Also, because SpringBridgeHstComponent retrieves a reference of the spring bean only once, the prototype beans do not make more object instances than needed.
Therefore, we'd better change the example in the testsuite to use prototype bean for the SpringBridgeHstComponent example and add some notes on this in the documentation.
[1] http://www.onehippo.org/library/concepts/web-application/spring-bridge.html