BUG: Supporting multiple identities with service discovery

Hello,

I’m bumping into the issue of two static fields being the only support for identity in the ServiceDiscoveryManager. I’ve created a patch (with tests!) against the Smack 3.2 branch. The topic has already been discussed here: http://community.igniterealtime.org/message/216719#216719

The patch makes changes to ServiceDiscoveryManager. The static methods setIdentityName and setIdentityType have been removed. I tried to figure out how to keep them in order to avoid breaking existing code, but there wasn’t a good solution. I did however keep a “default” identity that is created for each ServiceDiscoveryManager. This “default” identity has the same category/name/type values (client/Smack/pc) as the previous ServiceDiscoveryManager. This way any issues that might result from my changes would be compile time issues (which are easy to find) as opposed to issues with the value of the identity changing.

Identity now is an instance member of ServiceDiscoveryManager. This way every ServiceDiscoveryManager can independently have multiple identities. Identity instances are added and removed to the ServiceDiscoveryManager instead of dealing with individual Strings for identity name, type and category, I’ve made the adding/removing of identities threadsafe with minimal locking. I’ve also added “equals” and “hashCode” to Identity.

The public constructor for ServiceDiscoveryManager has been made private. This is to force the use of the static getInstanceFor(Connection), and this enforces one ServiceDiscoveryManager per connection. Having multiple managers per connections can lead to bugs so this is why I made the scope change on the constructor. With the public constructor it is possible to accidently make multiple ServiceDiscoveryManagers per connection.

Please let me know if there is anything you would like done differently. If you like the patch I’ll complete and fax the form for contributing. Would you please provide a link to the form? The form is mentioned here (http://community.igniterealtime.org/docs/DOC-1848) but there isn’t a link to it.

Leon
disco_with_multiple_identities.patch.zip (5759 Bytes)

2 Likes

Just wondering if there is any interest in this patch? Should it have been against a different branch or trunk?

Thanks,

Leon

1 Like