ozeebee
Apr 20th, 2010, 05:50 AM
Hi guys,
Sorry to bother you again with my little problems ... but i think I found an issue with autowiring by type.
I leave it up to you to decide whether it is a bug or a misunderstanding :
I have configured an object for which one property is injected through declaration (using a constant / FieldRetrievingFactoryObject).
So far, it works.
The problem is that I have a second property in my object with the same type that also receives the constant value !
Consider this object definition :
<object id="object" class="org.ozb.SimpleObject" scope="singleton" autowire="byType">
<property name="value1">
<util:constant static-field="org.ozb.Constants.SOMEVALUE"/>
</property>
</object>
And the SimpleObject class :
public class SimpleObject implements IInitializingObject {
private static var logger:ILogger = logger = LoggerFactory.getClassLogger(SimpleObject);
public var value1:String;
public var value2:String;
public function SimpleObject() {
}
public function afterPropertiesSet():void {
logger.debug("value1 = [{0}]", value1);
logger.debug("value2 = [{0}]", value2);
}
}
When I configure a context using these definitions I get the following log traces :
…
Tue Apr 20 11:07:04 GMT+0200 2010 DEBUG - org.ozb.SimpleObject - value1 = [someValue]
Tue Apr 20 11:07:04 GMT+0200 2010 DEBUG - org.ozb.SimpleObject - value2 = [someValue]
…
And this is not the expected result. I expect value1 to be "someValue" but value2 to be untouched (thus null). Am I right ?
If I ever turn autowiring off, then it works.
I have a small eclipse project at your disposal if you ever need some working code.
I'm working with a SAS version from yesterday (trunk)
Thanks,
Alain
Sorry to bother you again with my little problems ... but i think I found an issue with autowiring by type.
I leave it up to you to decide whether it is a bug or a misunderstanding :
I have configured an object for which one property is injected through declaration (using a constant / FieldRetrievingFactoryObject).
So far, it works.
The problem is that I have a second property in my object with the same type that also receives the constant value !
Consider this object definition :
<object id="object" class="org.ozb.SimpleObject" scope="singleton" autowire="byType">
<property name="value1">
<util:constant static-field="org.ozb.Constants.SOMEVALUE"/>
</property>
</object>
And the SimpleObject class :
public class SimpleObject implements IInitializingObject {
private static var logger:ILogger = logger = LoggerFactory.getClassLogger(SimpleObject);
public var value1:String;
public var value2:String;
public function SimpleObject() {
}
public function afterPropertiesSet():void {
logger.debug("value1 = [{0}]", value1);
logger.debug("value2 = [{0}]", value2);
}
}
When I configure a context using these definitions I get the following log traces :
…
Tue Apr 20 11:07:04 GMT+0200 2010 DEBUG - org.ozb.SimpleObject - value1 = [someValue]
Tue Apr 20 11:07:04 GMT+0200 2010 DEBUG - org.ozb.SimpleObject - value2 = [someValue]
…
And this is not the expected result. I expect value1 to be "someValue" but value2 to be untouched (thus null). Am I right ?
If I ever turn autowiring off, then it works.
I have a small eclipse project at your disposal if you ever need some working code.
I'm working with a SAS version from yesterday (trunk)
Thanks,
Alain