}
Map<String, ServerSentEventApplication> applicationMap = extension.getApplicationMap();
ServerSentEventApplication sseApp = applicationMap.get(req.getServletPath());
Class<?> clazz = sseApp.getHandlerClass();
ServerSentEventHandler sseh;
CreationalContext cc;
// Check if SSE handler can be instantiated via CDI
Iterator<Bean<?>> it = bm.getBeans(clazz).iterator();
if (it.hasNext()) {
Bean bean = it.next();
cc = bm.createCreationalContext(bean);
sseh = (ServerSentEventHandler) bean.create(cc);
} else {
throw new RuntimeException("Cannot create ServerSentEventHandler using CDI");
}
ServerSentEventHandler.Status status = sseh.onConnecting(req);
if (status == ServerSentEventHandler.Status.DONT_RECONNECT) {
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
cc.release();
return;
}