Zoran Jeremic 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

Zoran,

I think that Simon explains things very well.

Services are not like simple Java classes - the idea is that the service and the client are independent and are only connected through the contract defined by the service interface - and separation of the client and the service provider is a key goal of the services model.

So, if you want a service operation which returns some Java object/data structure from the service provider to the client - and then allow the client to modify that Java object and pass back the changed object to the service, then you should design a service interface that has a second operation that passes back the modified object to the service.

Something like:

public interface ServiceFoo {
        
        public Foo getAFoo( );

        public void returnUpdatedFoo( Foo updatedFoo );

}

Note that this potentially allows for the service to have many clients simultaneously and for the service to deal with independent updates. Handing out a single Java object from the service would be a recipe for disaster if there are multiple clients.


Yours,  Mike.

Reply via email to