Re: Recommendations for working with LookupCache
Patrick Wright <[email protected]>
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
Hi Mark > ServiceItem is the data container for the service proxy and its meta > data (lookup attributes and ServiceID). The lookup attributes might > change while time progresses so there is no stable notion of a > ServiceItem. In case you would pass in ServiceItem the lookup cache > could only use the stable parts to determine the service (and its > associated meta data) to discard. That would either be the ServiceID or > the service proxy [1]. > > In my experience in most cases, once obtained, you pass around the > service proxy for computations and you don't remember the ServiceItem so > it is more likely you have the service proxy object to discard than > access to the ServiceItem. Thank you, the clarification is helpful. In our case, the LookupCache is conceptually "far away" from the clients of the service reference. Thus I reasoned that the ServiceItem was more central to the cache than the reference (as our factory is more interested in items than references). > > BTW was the API for LookupCache not completely clear to you? In case > ServiceItem was expected I would have also assumed the > LookupCache.discard() method to take a ServiceItem object. Always be > extremely cautious when a method takes an object as an argument ;-) Unfortunately, the API threw me for a bit. I remember asking myself some months ago what discard() actually applied to. We hadn't been testing failure scenarios until now so I had never actually tested it. You're right about the Object argument. I just assumed that because the lookup() always returned a ServiceItem, the cache was based on ServiceItems, not service references. Not thinking of equals(), I wasn't sure how the LookupCache would perform a reverse lookup in its cache (so to speak). I thought the Object argument was possibly there to handle some Jini oddity. Oh well! But in that sense I personally find the API for discard() a little out of place compared to the other methods in the class. > [1] this assumes that in case of a specialized proxy a proper equals has > been implemented or in case you have a pure Jini ERI proxy (or JRMP > stub) this is taken care of automatically. ...and thanks for reminding me as well to take care of equals(). Regards Patrick -------------------------------------------------------------------------- Getting Started: http://www.jini.org/wiki/Category:Getting_Started Community Web Site: http://jini.org jini-users Archive: http://archives.java.sun.com/archives/jini-users.html Unsubscribing: email "signoff JINI-USERS" to [email protected]