[ 
https://issues.apache.org/jira/browse/TUSCANY-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542590
 ] 

Simon Nash commented on TUSCANY-1909:
-------------------------------------

I have found the cause of the problem and I have a fix that seems to work OK.

For each reference in a Java implementation, there is a WireObjectFactory that 
creates the proxies that are injected into instances of the implementation.  
Each time a new instance is created, the getInstance() method of 
WireObjectFactory is called to create a proxy for injection into that instance.

Some time ago, WireObjectFactory  was made into a subclass of 
ServiceReferenceImpl and CallableReferenceImpl, which means that all the 
proxies returned by a given WireObjectFactory instance share the same 
CallableReferenceImpl instance (this instance is actually the WireObjectFactory 
that created the proxy).  This causes the problem you are seeing.

The fix is to change the implementation of WireObjectFactory so that it does 
not extend ServiceReferenceImpl, but instead creates a new ServiceReferenceImpl 
instance each time that WireObjectFactory.newInstance() is called.  This gives 
each proxy instance its own distinct instance of 
ServiceReferenceImpl/CallableReferenceImpl, and this solves the problem without 
any need for cloning.

I will rebuild everything to verify this fix and check it in together with the 
test case.

> Conversational Component referring to another Conversational Component always 
> uses the same instance
> ----------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1909
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1909
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SCA Core Runtime
>            Reporter: Mark Combellack
>            Assignee: Simon Nash
>             Fix For: Java-SCA-Next
>
>         Attachments: ConversationalWire_HACK_DO_NOT_APPLY.patch, 
> ConversationalWireFix_itest.patch
>
>
> I've run into a problem with two conversational Services. Consider the 
> following scenario:
> AService
>   * Has member variable called state
>   * Has reference to BService
>   * Has set/getState method for setting state on A
>   * Has set/getStateOnB method for setting state on B
> BService
>   * Has member variable called state
> Calling SCADomain.getService(AService) twice, I am expecting to get:
>      AService_1 -> BService_1
> and  AService_2 -> BService_2
> However, I am getting:
>      AService_1 -> BService_1
> and  AService_2 -> BService_1
> i.e a second instance of BService is not being created.
> The first time I get a new instance of AService, a new instance of BService 
> is created.
> The second time I get a new instance of AService, the original BService 
> instance is shared.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to