}
}
}
Socket sock = null;
MulticastAnnouncement announcement = null;
UnicastResponse response = null;
if (req instanceof Socket) {
// Perform unicast discovery on the connected socket.
DiscoveryConstraints unicastDiscoveryConstraints =
DiscoveryConstraints.process(
rawUnicastDiscoveryConstraints);
sock = (Socket)req;
UnicastResponse resp;
try {
prepareSocket(sock, unicastDiscoveryConstraints);
resp = doUnicastDiscovery(sock,
unicastDiscoveryConstraints);
} finally {
try {
sock.close();
} catch (IOException e) { /* ignore */ }
}
maybeAddNewRegistrar(resp);
} else if(req instanceof LookupLocator) {
// Perform unicast discovery using the LookupLocator
// host and port.
LookupLocator loc = (LookupLocator)req;
UnicastResponse resp = new MultiIPDiscovery() {
protected UnicastResponse performDiscovery(
Discovery disco,
DiscoveryConstraints dc,
Socket s)
throws IOException, ClassNotFoundException
{
return doUnicastDiscovery(s, dc, disco);
}
protected void singleResponseException(Exception e,
InetAddress addr,
int port)
{
logger.log(
Levels.HANDLED,
"Exception occured during unicast discovery " +
addr + ":" + port, e);
}
}.getResponse(loc.getHost(),
loc.getPort(),
rawUnicastDiscoveryConstraints);
maybeAddNewRegistrar(resp);
} else if(req instanceof CheckGroupsMarker) {
// handle group changes
announcement = ((CheckGroupsMarker)req).announcement;
ServiceID srvcID = announcement.getServiceID();
UnicastResponse resp = null;
synchronized (registrars) {
resp = (UnicastResponse)registrars.get(srvcID);
}
if(resp != null) {
maybeSendEvent(resp, announcement.getGroups());