Announcement Announcement Module
No announcement yet.
Instantiated beans Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Instantiated beans

    i use spring to encapsulate a given class (with gruely public instancevariables, not my design ;-)) using BeanPrototyping for unique instances...

    but there seems to be strange things happen, on access to these vars

    maybe i've not understand the spring doc's correctly
    they state that the proxy of a (class)target (therefore using CGLIB)
    is a SUBCLASS of the target. So the variables should be accessible and unique in the different instances..... but as told above, there are strange results.....sometimes null....sometimes correctly filled.

    so Is this true.......that it is a subclass?!?
    or are there some sideeffects i dont know?!?

    thanx in advance Chris

  • #2

    The dynamically created proxy *will* be a subclass and as such will have all the same public fields. However, the state between the proxy and target in these fields will be different and will *never* be synchronized when using direct field access.

    The reason behind this is that, at runtime, it is only possible (currently and consistently) to create proxies that intercept method invocations and not field access. As such, a call such as = "Rob" will not update the value of the name field on the underlying target object.



    • #3

      for the fast reply :-)

      i think, that means its encapsulated (the target is a member of the proxy?!?) not derived... this should be clear in the docs, and too in springwalls ebooks (knowing you are not responsible for this ;-))
      i thought it is a real fault :-()

      wahooo means wrapping all with getters and setters.... (i know this should be standard, the sources i reworking reflects not always the best programming practices.... ) ..... read you later having much to do :-)

      however thanx