JdkNpnSslEngine(SSLEngine engine, final JdkApplicationProtocolNegotiator applicationNegotiator, boolean server) {
super(engine);
checkNotNull(applicationNegotiator, "applicationNegotiator");
if (server) {
final ProtocolSelectionListener protocolListener = checkNotNull(applicationNegotiator
.protocolListenerFactory().newListener(this, applicationNegotiator.protocols()),
"protocolListener");
NextProtoNego.put(engine, new ServerProvider() {
@Override
public void unsupported() {
protocolListener.unsupported();
}
@Override
public List<String> protocols() {
return applicationNegotiator.protocols();
}
@Override
public void protocolSelected(String protocol) {
try {
protocolListener.selected(protocol);
} catch (Throwable t) {
PlatformDependent.throwException(t);
}
}
});