use of com.vaadin.server.VaadinServletService in project opennms by OpenNMS.
the class VaadinOSGiServlet method createServletService.
@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException {
final VaadinServletService service = super.createServletService(deploymentConfiguration);
service.addSessionInitListener(new SessionInitListener() {
@Override
public void sessionInit(SessionInitEvent event) throws ServiceException {
final VaadinSession session = event.getSession();
m_sessions.add(session);
if (session.getUIProviders().isEmpty() || !session.getUIProviders().contains(m_provider)) {
session.addUIProvider(m_provider);
}
}
});
service.addSessionDestroyListener(new SessionDestroyListener() {
@Override
public void sessionDestroy(SessionDestroyEvent event) {
final VaadinSession session = event.getSession();
m_sessions.remove(session);
if (session.getUIProviders().contains(m_provider)) {
session.removeUIProvider(m_provider);
}
}
});
// Additional listeners
SessionListenerRepository sessionListenerRepository = SessionListenerRepository.getRepository(m_context);
if (sessionListenerRepository != null) {
service.addSessionInitListener(sessionListenerRepository);
service.addSessionDestroyListener(sessionListenerRepository);
}
// The Default location of the favicon is "theme://favicon.ico".
// However the theme may not provide a favicon. To avoid each theme to host the favicon.ico file, we just use
// the one defined in /opennms
service.addSessionInitListener(new SessionInitListener() {
@Override
public void sessionInit(SessionInitEvent event) throws ServiceException {
event.getSession().addBootstrapListener(new BootstrapListener() {
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
response.getDocument().head().getElementsByAttributeValue("rel", "shortcut icon").attr("href", "/opennms/favicon.ico");
response.getDocument().head().getElementsByAttributeValue("rel", "icon").attr("href", "/opennms/favicon.ico");
}
@Override
public void modifyBootstrapFragment(BootstrapFragmentResponse response) {
}
});
}
});
return service;
}
Aggregations