private static final Logger logger = LoggerFactory.getLogger(AtmosphereHandlerServiceProcessor.class);
@Override
public void handle(AtmosphereFramework framework, Class<AtmosphereHandler> annotatedClass) {
try {
AtmosphereHandlerService a = annotatedClass.getAnnotation(AtmosphereHandlerService.class);
atmosphereConfig(a.atmosphereConfig(), framework);
filters(a.broadcastFilters(), framework);
Class<?>[] interceptors = a.interceptors();
List<AtmosphereInterceptor> l = new LinkedList<AtmosphereInterceptor>();
for (Class i : interceptors) {
try {
AtmosphereInterceptor ai = (AtmosphereInterceptor) framework.newClassInstance(AtmosphereHandler.class, i);
l.add(ai);
} catch (Throwable e) {
logger.warn("", e);
}
}
if (a.path().contains("{")) {
framework.interceptors().add(framework.newClassInstance(AtmosphereInterceptor.class, AtmosphereHandlerServiceInterceptor.class));
}
AtmosphereInterceptor aa = listeners(a.listeners(), framework);
if (aa != null) {
l.add(aa);
}
framework.sessionSupport(a.supportSession());
AtmosphereHandler handler = framework.newClassInstance(AtmosphereHandler.class, annotatedClass);
for (String s : a.properties()) {
String[] nv = s.split("=");
IntrospectionUtils.setProperty(handler, nv[0], nv[1]);
IntrospectionUtils.addProperty(handler, nv[0], nv[1]);
}
framework.addAtmosphereHandler(a.path(), handler, broadcaster(framework, a.broadcaster(), a.path()), l);
framework.setBroadcasterCacheClassName(a.broadcasterCache().getName());
} catch (Throwable e) {
logger.warn("", e);
}
}