@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); getService().addSessionInitListener((SessionInitEvent event) -> { try { onVaadinSessionStarted(event.getRequest(), event.getSession()); } catch (ServletException e) { throw new ServiceException(e); } }); }
@Override public String getConfiguredWidgetset(VaadinRequest request) { return getDeploymentConfiguration() .getWidgetset(VaadinServlet.DEFAULT_WIDGETSET); }
@Override protected URL getApplicationUrl(VaadinRequest request) throws MalformedURLException { return getServlet().getApplicationUrl((VaadinServletRequest) request); }
/** * Creates a vaadin servlet service. * * @param deploymentConfiguration * the deployment configuration to be used * * @return the created vaadin servlet service * * @throws ServiceException * if creating the vaadin servlet service fails * * @since 7.0.0 */ protected VaadinServletService createServletService( DeploymentConfiguration deploymentConfiguration) throws ServiceException { VaadinServletService service = new VaadinServletService(this, deploymentConfiguration); service.init(); return service; }
@Override public String getStaticFileLocation(VaadinRequest request) { VaadinServletRequest servletRequest = (VaadinServletRequest) request; String staticFileLocation; // if property is defined in configurations, use that staticFileLocation = getDeploymentConfiguration().getResourcesPath(); if (staticFileLocation != null) { return staticFileLocation; } // the last (but most common) option is to generate default location // from request by finding how many "../" should be added to the // requested path before we get to the context root String requestedPath = servletRequest.getServletPath(); String pathInfo = servletRequest.getPathInfo(); if (pathInfo != null) { requestedPath += pathInfo; } return getCancelingRelativePath(requestedPath); }
public PushRequestHandler(VaadinServletService service) throws ServiceException { service.addServiceDestroyListener(event -> destroy()); final ServletConfig vaadinServletConfig = service.getServlet() .getServletConfig(); getLogger().log(Level.WARNING, "Failed to initialize Atmosphere for " + service.getServlet().getServletName() + ". Push will not work.", e);
@Override protected void servletInitialized() throws ServletException { super.servletInitialized(); final WebApplicationContext applicationContext = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); try { SystemMessagesProvider systemMessagesProvider = applicationContext.getBean(SystemMessagesProvider.class); LOGGER.info("Using custom SystemMessagesProvider {}", systemMessagesProvider); getService().setSystemMessagesProvider(systemMessagesProvider); } catch (BeansException ex) { LOGGER.info("Could not find a SystemMessagesProvider in the application context, using default"); } for (SessionInitListener sessionInitListener : applicationContext.getBeansOfType(SessionInitListener.class) .values()) { LOGGER.info("Adding SessionInitListener {}", sessionInitListener); getService().addSessionInitListener(sessionInitListener); } for (SessionDestroyListener sessionDestroyListener : applicationContext .getBeansOfType(SessionDestroyListener.class).values()) { LOGGER.info("Adding SessionDestroyListener {}", sessionDestroyListener); getService().addSessionDestroyListener(sessionDestroyListener); } for (ServiceDestroyListener serviceDestroyListener : applicationContext .getBeansOfType(ServiceDestroyListener.class).values()) { LOGGER.info("Adding ServiceDestroyListener {}", serviceDestroyListener); getService().addServiceDestroyListener(serviceDestroyListener); } LOGGER.info("Custom Vaadin4Spring servlet initialization completed"); }
protected void initializePlugin(VaadinServletService service) { // Spring system messages provider if (systemMessagesBeanName != null && systemMessagesBeanName != "") { SpringVaadinSystemMessagesProvider messagesProvider = new SpringVaadinSystemMessagesProvider(applicationContext, systemMessagesBeanName); logger.debug("set SpringVaadinSystemMessagesProvider"); service.setSystemMessagesProvider(messagesProvider); } String uiProviderProperty = service.getDeploymentConfiguration().getApplicationOrSystemProperty(Constants.SERVLET_PARAMETER_UI_PROVIDER, null); // Add SpringUIProvider if custom provider doesn't defined. if (uiProviderProperty == null) { service.addSessionInitListener(new SessionInitListener() { @Override public void sessionInit(SessionInitEvent event) throws ServiceException { event.getSession().addUIProvider(new SpringUIProvider()); } }); } }
service.addSessionInitListener(new SessionInitListener() { @Override public void sessionInit(SessionInitEvent event) throws ServiceException { service.addSessionDestroyListener(new SessionDestroyListener() { @Override public void sessionDestroy(SessionDestroyEvent event) { service.addSessionInitListener(sessionListenerRepository); service.addSessionDestroyListener(sessionListenerRepository); service.addSessionInitListener(new SessionInitListener() { @Override public void sessionInit(SessionInitEvent event) throws ServiceException {
/** * @see com.vaadin.server.VaadinServlet#servletInitialized() */ @Override protected void servletInitialized() throws ServletException { super.servletInitialized(); getService().setSystemMessagesProvider(this); getService().addSessionInitListener(this); }
service.requestStart(vaadinRequest, null); session = service.findVaadinSession(vaadinRequest); assert VaadinSession.getCurrent() == session; } catch (SessionExpiredException e) { SystemMessages msg = service .getSystemMessages(ServletPortletHelper.findLocale(null, null, vaadinRequest), vaadinRequest); sendNotificationAndDisconnect(resource, session.lock(); try { ui = service.findUI(vaadinRequest); assert UI.getCurrent() == ui; } catch (final Exception e) { SystemMessages msg = service .getSystemMessages(ServletPortletHelper.findLocale(null, null, vaadinRequest), vaadinRequest); try { if (websocket) { service.requestEnd(vaadinRequest, null, session);
if (getService().getDeploymentConfiguration().isProductionMode()) { final String mimetype = getService().getMimeType(filename); writeResponse(response, mimetype, cacheEntry.getCss());
session = service.findVaadinSession(vaadinRequest); } catch (ServiceException e) { getLogger().log(Level.SEVERE, VaadinSession.setCurrent(session); ui = service.findUI(vaadinRequest); if (ui == null) {
@Override protected void servletInitialized() throws ServletException { super.servletInitialized(); getService().setSystemMessagesProvider((SystemMessagesProvider) systemMessagesInfo -> { CustomizedSystemMessages messages = new CustomizedSystemMessages(); // Don't show any messages, redirect immediately to the session expired URL messages.setSessionExpiredNotificationEnabled(false); // Don't show any message, reload the page instead messages.setCommunicationErrorNotificationEnabled(false); return messages; }); } }
MyDeploymentConfiguration deploymentConfiguration = new MyDeploymentConfiguration(MyVaadinServlet.class, new Properties()); VaadinServletService vaadinService = new VaadinServletService(vaadinServlet, deploymentConfiguration); VaadinServletRequest vaadinRequest = new VaadinServletRequest(new MockHttpServletRequest(), vaadinService); VaadinSession vaadinSession = vaadinService.findVaadinSession(vaadinRequest); Integer uiId = Integer.valueOf(vaadinSession.getNextUIid()); UI ui = new MyUI();
@Override protected VaadinServletService createServletService( DeploymentConfiguration deploymentConfiguration) throws ServiceException { VaadinServletService service = new LocalVaadinServletService(this, deploymentConfiguration); service.init(); return service; }
@Override protected void servletInitialized() throws ServletException { super.servletInitialized(); final WebApplicationContext applicationContext = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); try { SystemMessagesProvider systemMessagesProvider = applicationContext.getBean(SystemMessagesProvider.class); LOGGER.info("Using custom SystemMessagesProvider {}", systemMessagesProvider); getService().setSystemMessagesProvider(systemMessagesProvider); } catch (BeansException ex) { LOGGER.info("Could not find a SystemMessagesProvider in the application context, using default"); } for (SessionInitListener sessionInitListener : applicationContext.getBeansOfType(SessionInitListener.class) .values()) { LOGGER.info("Adding SessionInitListener {}", sessionInitListener); getService().addSessionInitListener(sessionInitListener); } for (SessionDestroyListener sessionDestroyListener : applicationContext .getBeansOfType(SessionDestroyListener.class).values()) { LOGGER.info("Adding SessionDestroyListener {}", sessionDestroyListener); getService().addSessionDestroyListener(sessionDestroyListener); } for (ServiceDestroyListener serviceDestroyListener : applicationContext .getBeansOfType(ServiceDestroyListener.class).values()) { LOGGER.info("Adding ServiceDestroyListener {}", serviceDestroyListener); getService().addServiceDestroyListener(serviceDestroyListener); } LOGGER.info("Custom Vaadin4Spring servlet initialization completed"); }
service.addSessionInitListener(new SessionInitListener() { @Override public void sessionInit(SessionInitEvent event) throws ServiceException { service.addSessionDestroyListener(new SessionDestroyListener() { @Override public void sessionDestroy(SessionDestroyEvent event) { service.addSessionInitListener(sessionListenerRepository); service.addSessionDestroyListener(sessionListenerRepository); service.addSessionInitListener(new SessionInitListener() { @Override public void sessionInit(SessionInitEvent event) throws ServiceException {
service.requestStart(vaadinRequest, null); session = service.findVaadinSession(vaadinRequest); assert VaadinSession.getCurrent() == session; session.lock(); try { ui = service.findUI(vaadinRequest); assert UI.getCurrent() == ui; callErrorHandler(session, e); } catch (final Exception e) { SystemMessages msg = service.getSystemMessages( ServletHelper.findLocale(null, vaadinRequest), vaadinRequest); try { if (websocket) { service.requestEnd(vaadinRequest, null, session);
protected VaadinServletService createServletService( DeploymentConfiguration deploymentConfiguration) throws ServiceException { VaadinServletService service = new VaadinServletService(this, deploymentConfiguration); service.init(); return service; }