Hi Simon,

>To change the object in the service you'll have to arrange to
>send the changes back to the service. You'll need to devise a service
>interface to allow this to happen.

In the meantime I have implemented another service that accept changed object 
and change the old one with updated version, and this works for me, but it was 
very important for me to know how the thinks work with tuscany and I couldn't 
find the explanation of this on Google or I couldn't formulate appropriate 
question.
Thank you so much for your thorough explanation. That's exactly what I needed.

Zoran




________________________________
From: Simon Laws <[email protected]>
To: [email protected]
Sent: Tue, July 27, 2010 10:42:45 AM
Subject: Re: Java instance accessed through Tuscany

On Mon, Jul 26, 2010 at 7:28 PM, Zoran Jeremic <[email protected]> wrote:
> Hi,
>
> I've created Tuscany Web service that returns an instance of Java class.
> Then I work locally on this class and change it's properties. However, when
> I access the same instance from web service, there is no change on it's
> properties. As I'm new with tuscany I'm wondering if this java instance I
> get through tuscany behaves as the same instance or as another instance? Do
> I have to pass and change the old instance with the updated one?
>
> Thanks
>
>

Hi

The short answer is yes you are working with a copy of the original object.

When you communicate with a service using Web Services you are using a
remote interface. In SCA terms the service's Java interface must be
marked as @Remotable (there are other ways that it can be marked as
remotable but I'm skipping over those for the purpose of this
explanantion).

A remote interface allows you to communicate with services regardless
of where they are running. For example, the service could be running
on a completely separate machine from component that's calling it.
Hence the use of the term remote.

To make this work, remote interfaces always exploit pass by value
semantics. By this we mean that when an object is passed into the
remote service or when the remote service returns an object a copy
(the value) of the object is passed rather than a reference to the
original object. This must be the case because, when using protocols
such as SOAP/HTTP, the object will be serialized out to XML to be
sent. When the XML is received it is converted back into the right
sort of object. As you can imagine you can't do this sort of thing
while maintaining an reference to the original object.

Hence when you make changes to the object that has been returned to
you in the client component the original object in the service is not
changed. To change the object in the service you'll have to arrange to
send the changes back to the service. You'll need to devise a service
interface to allow this to happen.

Hope that helps

Simon


-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com



      

Reply via email to