Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Problem with SharedObject API

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks Scott.

Tests works fine, my code works too. But I do not understand why this
code is in TestSharedObject (in method initialize()):

// This is a replica, so initialize the name from property
name = (String) getConfig().getProperties().get(NAME_PROPERTY);

Is this code a deserialization from Config to SharedObject? Why name do
not replicate with SharedObject automaticaly?

And another question: Does SharedObject API have any listeners that
calls when shared object has been added?


Scott Lewis пишет:
> Hi Pavel,
> 
> Samolisov Pavel wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hello folks,
>>
>> I'm playing with SharedObject API and Generic Server/Client. I'm tring
>> to create shared object in one bundle and to get it in another bundle.
>>
>> In the first bundle, I get SharedObjectManager and call
>> ISharedObjectManager#addSharedObject:
>>
>> public static final String DEMO_SHARED_OBJECT_ID = "foo";
>>
>> //...
>>
>> _server = createServer();
>>
>> ISharedObjectManager manager = getServerSOManager();
>>
>> ID id = manager.addSharedObject(createNewID(DEMO_SHARED_OBJECT_ID), new
>> MySharedObject(), null);
>> System.out.println("Added new SharedObject with ID = " + id.getName());
>>
>> It works, I get "Added new SharedObject with ID = foo" in the OSGi
>> console.
>>
>> In another bundle activator:
>>
>> createClients();
>> connectClients();
>>
>> System.out.println("Clients created and connected");
>>
>> ISharedObjectManager manager = getClientSOManager(0);
>>
>> ISharedObject sharedObject =
>> manager.getSharedObject(createNewID(DEMO_SHARED_OBJECT_ID));
>> System.out.println(sharedObject);
>>
>> and I get
>>
>> "Clients created and connected
>> null"
>>
>> in the OSGi Console :-(
>>
>>
>> May be I make mistake? Any ideas?
>>   
> 
> The shared object instance is responsible for replicating itself to
> remotes, and your MySharedObject class has to have code to do this
> replication.  The default (in BaseSharedObject...which I assume
> MySharedObject extends), is to *not* automatically replicate the object
> to remote containers.
> 
> There's an example of code for replicating a shared object (and
> replicating the state of the primary copy...i.e. the one created via
> addSharedObject) onto a remote container in this test class:
> 
> org.eclipse.ecf.tests.sharedobject.TestSharedObject
> 
> This class is in the test bundle:  org.eclipse.ecf.tests.sharedobject
> 
> Note that since the replication is done asynchronously (BaseSharedObject
> subclasses...see [1]) that you might want to put some delay into your
> test code after connection (to allow the replication to complete).
> 
> Scott
> 
> [1] Note there is also the TransactionSharedObject super class, which
> has logic built in for replicating transactionally/all or
> nothing...which will block on addSharedObject until replication is
> complete...if desired.
> 
> 


- --
Pavel Samolisov

Meet me at:
Vkontakte.ru: http://vkontakte.ru/id3178981
Blog: http://samolisov.blogspot.com
Twitter: http://twitter.com/samolisov
XMPP/Jabber: samolisov@xxxxxxxxx
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrxki8ACgkQ20T0Vos3rqCingCeNvqvZzIbtaarPZIyouVoBGNX
m3UAoMtJoXwt5zV2hctRBek9I+EBACma
=5GIK
-----END PGP SIGNATURE-----


Back to the top