Uploaded image for project: '[Read Only] - Hippo Site Toolkit 2'
  1. [Read Only] - Hippo Site Toolkit 2
  2. HSTTWO-3290

TestSuite - Spring Bean Bridge Example should be better with prototype bean

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • CMS-10.0-GA
    • 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

      Attachments

        Activity

          People

            Unassigned Unassigned
            wko Woonsan Ko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: