if (stream == null) {
return;
}
AtmosphereConfigReader reader = new AtmosphereConfigReader(stream);
Map<String, String> atmosphereHandlerNames = reader.getAtmosphereHandlers();
Set<Entry<String, String>> entries = atmosphereHandlerNames.entrySet();
for (Entry<String, String> entry : entries) {
AtmosphereHandler handler;
String handlerClassName = entry.getValue();
String handlerPath = entry.getKey();
try {
if (!handlerClassName.equals(ReflectorServletProcessor.class.getName())) {
handler = (AtmosphereHandler) c.loadClass(handlerClassName).newInstance();
InjectorProvider.getInjector().inject(handler);
} else {
handler = new ReflectorServletProcessor();
}
logger.info("successfully loaded handler: {} mapped to context-path: {}", handler, handlerPath);
AtmosphereHandlerWrapper wrapper = new AtmosphereHandlerWrapper(handler);
atmosphereHandlers.put(handlerPath, wrapper);
boolean isJersey = false;
for (Property p : reader.getProperty(handlerPath)) {
if (p.value != null && p.value.indexOf("jersey") != -1) {
isJersey = true;
initParams.put(DISABLE_ONSTATE_EVENT, "true");
useStreamForFlushingComments = true;
}
IntrospectionUtils.setProperty(handler, p.name, p.value);
}
config.supportSession = !isJersey;
if (!reader.supportSession().equals("")) {
sessionSupport(Boolean.valueOf(reader.supportSession()));
}
for (Property p : reader.getProperty(handlerPath)) {
IntrospectionUtils.addProperty(handler, p.name, p.value);
}
String broadcasterClass = reader.getBroadcasterClass(handlerPath);
/**
* If there is more than one AtmosphereHandler defined, their Broadcaster
* may clash each other with the BroadcasterFactory. In that case we will use the
* last one defined.
*/
if (broadcasterClass != null) {
broadcasterClassName = broadcasterClass;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class<? extends Broadcaster> bc = (Class<? extends Broadcaster>) cl.loadClass(broadcasterClassName);
wrapper.broadcaster = BroadcasterFactory.getDefault().get(bc, handlerPath);
}
String bc = reader.getBroadcasterCache(handlerPath);
if (bc != null) {
broadcasterCacheClassName = bc;
}
if (reader.getCometSupportClass() != null) {
cometSupport = (CometSupport) c.loadClass(reader.getCometSupportClass())
.getDeclaredConstructor(new Class[]{AtmosphereConfig.class})
.newInstance(new Object[]{config});
}
if (reader.getBroadcastFilterClasses() != null) {
broadcasterFilters = reader.getBroadcastFilterClasses();
}
}
catch (Throwable t) {
logger.warn("unable to load AtmosphereHandler class: " + handlerClassName, t);