
|
If you were logged in you would be able to see more operations.
|
|
|
|
When an object is marked as non-singleton. I.e. its singleton attribute is set to 'false', or its scope attribute is set to 'prototype' the mothod invocations aren't
being called on the resulting objects.
I've attached a sample application that illustrates the problem.
In the configuration you will see one object:
<object id="tst" class="com.classes.TestObject" singleton="false">
<method-invocation name="changeTest"/>
</object>
The changeTest method will change the 'test' property to 'true' but as you will by the value on the labels it remains 'false'
if you change the markup to this:
<object id="tst" class="com.classes.TestObject" singleton="true">
<method-invocation name="changeTest"/>
</object>
the method does get invoked on the right object and thus you will see the labels change accordingly.
|
|
Description
|
When an object is marked as non-singleton. I.e. its singleton attribute is set to 'false', or its scope attribute is set to 'prototype' the mothod invocations aren't
being called on the resulting objects.
I've attached a sample application that illustrates the problem.
In the configuration you will see one object:
<object id="tst" class="com.classes.TestObject" singleton="false">
<method-invocation name="changeTest"/>
</object>
The changeTest method will change the 'test' property to 'true' but as you will by the value on the labels it remains 'false'
if you change the markup to this:
<object id="tst" class="com.classes.TestObject" singleton="true">
<method-invocation name="changeTest"/>
</object>
the method does get invoked on the right object and thus you will see the labels change accordingly.
|
Show » |
Sort Order:
|
Method-invocation elements are preprocessed to MethodInvokingFactoryObjects. The MethodInvokingFactoryObject (MIFO) will execute once since it is a singleton and it will be instantiated when the container initializes. Since there is not reference from the target obejct to MIFO (we loose this info when preprocessing), we can't execute the method again.
I guess the best option would be to add a true method-invocation element and property to an object definition and remove the preprocessing. That way, the method invocations will be part of the object creation process.