[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [ecf-dev] Problem with SharedObject API
|
- From: Samolisov Pavel <samolisov@xxxxxxxxx>
- Date: Wed, 04 Nov 2009 19:39:43 +0500
- Delivered-to: ecf-dev@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :user-agent:mime-version:to:cc:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=16JPjeBG7BPbWDYHJSX01iMoqPowD336sDv/nuRHYLM=; b=KI9UGMmf313+WrMapXgDnUzo9XCyhMYw1CZ2Aglne+gXjPv8fEJjn5KGSc0zbGyDC6 kVU7q6iwoBLKXaEkQnzWiqvr4eKXB18Fv69w81TQqBAI62bYTCgw2LBH5HJiZykupMO8 yLov33tFIU+7pAXYo6acDd2fxkcZolnnfnoV8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=gI+LjwB98Yu0hRP4sn2nHmIdFCrYJl/czEvdyxYeFv7dViSOW4oXMZWaTlEySihaY9 UvBPcBTeokJGlZjfEIgrEGTwj21hPv+TnQ52lrRluoTeY+g790QDpZ/SlDPvlc66fwjn sVh6vZAGiJdbBpe6IGHGbCsroNvnMNE2u9LAY=
- User-agent: Thunderbird 2.0.0.23 (X11/20091018)
-----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-----