Announcement Announcement Module
Collapse
No announcement yet.
object requires dependency getter for dependency satisfaction test Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • object requires dependency getter for dependency satisfaction test

    Assuming this is my config:
    Code:
    <object id="myObject" class="com.test.MyObject">
            <property name="objectProperty">
                   <dictionary id="securityMapping">
                            ....
                   </dictionary>
            </property>
    </object>
    Code:
    public class MyObject implements IInitializingObject {
        private var _objectProperty:Dictionary;
    
        public function set objectProperty(value:Dictionary):void {
            _objectProperty = value;
        }
    
        public function afterPropertiesSet():void {
             ...
        }
    }
    In this case the afterPropertiesSet isn't called because according to SpringAS2 the objectProperty dependency hasn't been satisfied yet, so it skips DefaultDependencyInjector.initializeInstance(). More specifically because of this block of code in DefaultDependencyChecker.checkDependenciesSatisfie d():
    Code:
    var isNull:Boolean = true;
    try {
        if (!property.isStatic) {
            isNull = (instance[property.qName] == null);
        } else {
            isNull = ((objectDefinition.clazz)[property.qName] == null);
        }
    } catch (e:Error) {
    }
    because the field isn't static, it will try to access the property, but since it only has a setter it will return null. I've debugged the code and the objectProperty property has been injected, so it is not null.
    This was working in SpringAS1.

    Am I missing something or is this indeed a bug?

  • #2
    I've logged the issue here together with a unit test: https://jira.springsource.org/browse...ONSCRIPTAS-148

    Comment

    Working...
    X