}
// first try to lookup a service appropriate for the mode
// that has been configured.
final String serviceName = ((isNpnMode) ? "spdy-npn" : "spdy-plane");
AddOn spdyAddon = locator.getService(AddOn.class, serviceName);
// if no service was found, attempt to load via reflection.
if (spdyAddon == null) {
Class<?> spdyMode;
try {
spdyMode = Utils.loadClass("org.glassfish.grizzly.spdy.SpdyMode");
} catch (ClassNotFoundException cnfe) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Unable to load class org.glassfish.grizzly.spdy.SpdyMode. SPDY support cannot be enabled");
}
return;
}
Object[] enumConstants = spdyMode.getEnumConstants();
Object mode = ((isNpnMode) ? enumConstants[1] : enumConstants[0]);
spdyAddon = loadAddOn("org.glassfish.grizzly.spdy.SpdyAddOn", new Class[]{spdyMode}, mode);
}
if (spdyAddon != null) {
// Configure SpdyAddOn
configureElement(locator, listener, spdyElement, spdyAddon);
// Spdy requires access to more information compared to the other addons
// that are currently leveraged. As such, we'll need to mock out a
// Grizzly NetworkListener to pass to the addon. This mock object will
// only provide the information necessary for the addon to operate.
// It will be important to keep this mock in sync with the details the
// addon requires.
spdyAddon.setup(createMockListener(), builder);
isSpdyEnabled = true;
}
}
}