List<TargetTuple> newTTs =
Arrays.asList(sipBindingCtx.getTargetTuples());
for (TargetTuple newTT : newTTs) {
TargetTuple oldTT =
pair.getLeft().getTargetTupleForProtocol(newTT.getProtocol());
if (oldTT != null) {
if (!oldTT.equals(newTT)) {
//remove the old one add the new one
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "sip.network.grizzly.update.tt",
new Object[]{
newTT.getProtocol().name(),
sipBindingCtx.getContext()
});
}
//Remove
Pair<SelectorHandler, SelectorHandler> selHdlPair = pair.getRight().
get(newTT.getProtocol());
if (selHdlPair != null) { //disable can cause the pair to be absent.
shutdownAndRemoveSelectorHandlers(newTT.getProtocol(),
selHdlPair.getLeft(), selHdlPair.getRight());
//Add
final ProtocolChain udpProtocolChain =
getProtocolChain();
ProtocolChainInstanceHandler instanceHandler =
new SimpleProtocolChainInstanceHandler(udpProtocolChain);
startSelectorHandlers(newTT, selHdlPair,
instanceHandler, sipBindingCtx);
}
oldTTs.remove(oldTT);
} else {
//okidoki
//Check updateSSL, there the SSL changes are taken into
//account.
}
} else {
//Add it
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "sip.network.grizzly.update.tt",
new Object[]{
newTT.getProtocol().name(),
sipBindingCtx.getContext()
});
}
final ProtocolChain udpProtocolChain = getProtocolChain();
ProtocolChainInstanceHandler instanceHandler =
new SimpleProtocolChainInstanceHandler(udpProtocolChain);
Pair<SelectorHandler, SelectorHandler> selHdlPair =
new Pair<SelectorHandler, SelectorHandler>();
startSelectorHandlers(newTT, selHdlPair, instanceHandler,
sipBindingCtx);
pair.getRight().put(newTT.getProtocol(), selHdlPair);
}
}
for (TargetTuple oldTT : oldTTs) {
//Remove it
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "sip.network.grizzly.update.remove.tt",
new Object[]{
oldTT.getProtocol().name(),
sipBindingCtx.getContext()
});
}
Pair<SelectorHandler, SelectorHandler> selHdlPair = pair.getRight().
remove(oldTT.getProtocol());
shutdownAndRemoveSelectorHandlers(oldTT.getProtocol(),
selHdlPair.getLeft(), selHdlPair.getRight());
}
}