Bug 204433 - [Discovery] Extract superclass out of JSLPDiscoveryContainerAdapter and JMDNSDiscoveryContainerAdapter
Summary: [Discovery] Extract superclass out of JSLPDiscoveryContainerAdapter and JMDNS...
Status: CLOSED FIXED
Alias: None
Product: ECF
Classification: RT
Component: ecf.providers (show other bugs)
Version: 1.1.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: ecf.core-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on: 204423
Blocks: 200804
  Show dependency tree
 
Reported: 2007-09-24 07:14 EDT by Markus Kuppe CLA
Modified: 2008-05-18 19:46 EDT (History)
1 user (show)

See Also:


Attachments
patch implementing this enhancement (17.00 KB, patch)
2007-09-24 07:20 EDT, Markus Kuppe CLA
no flags Details | Diff
patch makes members protected and adds missing method (1.46 KB, patch)
2007-10-11 10:17 EDT, Markus Kuppe CLA
no flags Details | Diff
protected collection/map in superclass should be thread safe (1.86 KB, patch)
2007-10-22 02:32 EDT, Markus Kuppe CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Kuppe CLA 2007-09-24 07:14:31 EDT
Both providers have several methods in common, thus it makes sense to factor out a common superclass.

Cheers
Markus
Comment 1 Markus Kuppe CLA 2007-09-24 07:20:43 EDT
Created attachment 79064 [details]
patch implementing this enhancement
Comment 2 Scott Lewis CLA 2007-10-01 16:07:05 EDT
Applied patch to HEAD and committed.  Please review and comment on this bug.
Comment 3 Markus Kuppe CLA 2007-10-11 10:17:16 EDT
Created attachment 80137 [details]
patch makes members protected and adds missing method
Comment 4 Markus Kuppe CLA 2007-10-11 10:37:38 EDT
+1 for FIXED
Comment 5 Scott Lewis CLA 2007-10-11 10:46:50 EDT
Hi Markus.

Thanks for the additional patch.  I've applied the member protection changes, but not the addition of getConnectedID, as I would like to leave the implementation of getConnectedID up to subclasses, as they also have to implement connect()/disconnect (and the meaning of getConnectedID() is really dependent upon connect()).

Anyway, thanks again for the patch.  IP log also updated.

Resolving as fixed, as I think this works.
Comment 6 Markus Kuppe CLA 2007-10-11 11:01:55 EDT
But why not leave getConnectedID { return config.getID(); } as the default impl. It isn't final so subclasses can overwrite.
Comment 7 Scott Lewis CLA 2007-10-11 11:09:15 EDT
Because subclasses that implement connect may then forget to implement getConnectedID.
Comment 8 Markus Kuppe CLA 2007-10-11 11:12:39 EDT
But isn't this always the problem with providing an implementation in the superclass? But can you elaborate on the semantical meaning of getConnectID(), so I better understand why config.getID() might not be sufficient in a couple of scenarios.
Comment 9 Scott Lewis CLA 2007-10-11 13:10:40 EDT
(In reply to comment #8)
> But isn't this always the problem with providing an implementation in the
> superclass? 

Yes, absolutely...to differing degrees.  

As an example, it's relatively clear that getID() can/should be implemented by the abstract superclass, because subclasses (typically) don't implement anything that would affect the getID() behavior.

OTOH, forcing subclasses to implement IContainer.connect() implies that they can/should? also implement getConnectedID() (since getConnectedID() is dependent upon connect).

>But can you elaborate on the semantical meaning of getConnectID(),
> so I better understand why config.getID() might not be sufficient in a couple
> of scenarios.

getConnectedID returns the targetID (or null if not connected at all) of the remote container that the given container is connected to (e.g. after call to connect(ID targetID).

Discovery API is somewhat unusual (compared to other container adapters...e.g. presence, etc), in that it doesn't have a clear notion of 'connection' to a particular identified (except to perhaps the/a network itself...e.g. to a particular network interface eth0, eth1, etc).


Comment 10 Markus Kuppe CLA 2007-10-22 02:32:46 EDT
Created attachment 80854 [details]
protected collection/map in superclass should be thread safe
Comment 11 Markus Kuppe CLA 2007-10-22 02:33:54 EDT
reopened because of previous comment
Comment 12 Scott Lewis CLA 2007-10-22 10:58:56 EDT
Added synchronization to relevant places in class rather than creating synchronized collection.  Marking as fixed.
Comment 13 Markus Kuppe CLA 2007-10-22 11:03:08 EDT
Hi Scott,

this way subclasses will have to synchronize "simple" access to the collections as well which wouldn't be necessary if the collections would be instantiated as synchronized ones.
Comment 14 Scott Lewis CLA 2007-10-22 11:20:56 EDT
(In reply to comment #13)
> Hi Scott,
> 
> this way subclasses will have to synchronize "simple" access to the collections
> as well which wouldn't be necessary if the collections would be instantiated as
> synchronized ones.
> 

Added creation of synchronized map/set and documentation for member variables.
Comment 15 Scott Lewis CLA 2008-05-18 19:46:45 EDT
closing.