I've implemented a ServiceDiscoveryListener which monitors all services in the lookup service and simply puts and removes serviceItems in a hashtable as they are removed or registered. The problem is that whenever a new services is registered with or removed from the lookup service, it seems that the lookup service doesn't notify my client at all!!
ServiceDiscoveryManager sdm = new ServiceDiscoveryManager(null,null); LookupCache cache = sdm.createLookupCache(null,null,this); //try to get all services available ServiceItem[] items = cache.lookup(null,Integer.MAX_VALUE);
(Exception handling were ommitted here for simplicity)are those lines right? If not, what should I do? Thanks a lot for any help, I've been stucked on this whole night and nearly mad.......
Okay, I dunno, because I can't see all your code but are you expecting that call to lookup to actually go talk to all the service registrars and return the results?
If so, I'm not sure that's what actually happens. I think what's probably happening is that you haven't allowed enough time for the cache to be populated with entries - i.e. the populating of the cache is asynchronous not synchronous.
Try creating the cache, sleeping for a couple of minutes and then invoking the lookup and see what happens......
I've noticed that if your codebase isn't set correctly, the client won't get called. The easy way to tell is to run the example browser on another machine. If you point it at your lookup server and you see your service as "Unknown Service" then your codebase is foobar.
w/o more info it would be hard to speculate more than I already have... I just ran into this reciently and thought your problem sounded familar.