Wicket
  1. Wicket
  2. WICKET-2573

Allow applications to chose not to use CGLIB proxies for @SpringBean injections

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.3, 1.5-M1
    • Fix Version/s: 1.4.4, 1.5-M1
    • Component/s: wicket-spring
    • Labels:
      None

      Description

      Spring beans fetched from the spring context and injected into wicket components are currently proxied using CGLIB before being injected. These proxies are serializable, as required by the Servlet specification.

      However, this proxying puts restrictions on the beans being injected. If CGLIB cannot create the proxy (e.g. if the class to proxy has no default constructor, although there are other scenarios), then this technique does not work. Given that Spring beans can take on many obscure forms (Spring is less restrictive than CGLIB), this means that not all Spring beans can be injected.

      The simplest solution to this problem is to allow applications to specify that the injected Spring beans should not be proxied. Clearly, this should not be the default behaviour, since there's no guarantee that Spring beans are properly serializable. However, in many cases the developer knows this not to be an issue, either because they know the Spring beans are serializable (and will not drag half the appcontext along with them in the process), or because they know their container does not serialize sessions. In these situations, non-serializable objects are acceptable.

      It is trivial to modify SpringComponentInjector to support this behaviour. See attached patch.

      1. patch.txt
        3 kB
        Kenny MacLeod
      2. SpringComponentInjector.java
        6 kB
        Kenny MacLeod
      3. AnnotProxyFieldValueFactory.java
        4 kB
        Kenny MacLeod

        Activity

        Kenny MacLeod created issue -
        Kenny MacLeod made changes -
        Field Original Value New Value
        Attachment SpringComponentInjector.java [ 12424594 ]
        Attachment AnnotProxyFieldValueFactory.java [ 12424593 ]
        Attachment patch.txt [ 12424595 ]
        Igor Vaynberg made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Igor Vaynberg [ ivaynberg ]
        Fix Version/s 1.4.4 [ 12314323 ]
        Fix Version/s 1.5-M1 [ 12313078 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Igor Vaynberg
            Reporter:
            Kenny MacLeod
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development