private static void verifyUIClass(String className, ClassLoader classLoader) throws ServiceException { if (className == null) { throw new ServiceException( VaadinSession.UI_PARAMETER + " init parameter not defined"); } // Check that the UI layout class can be found try { Class<?> uiClass = classLoader.loadClass(className); if (!UI.class.isAssignableFrom(uiClass)) { throw new ServiceException( className + " does not implement UI"); } // Try finding a default constructor, else throw exception uiClass.getConstructor(); } catch (ClassNotFoundException e) { throw new ServiceException(className + " could not be loaded", e); } catch (SecurityException e) { throw new ServiceException( "Could not access " + className + " class", e); } catch (NoSuchMethodException e) { throw new ServiceException( className + " doesn't have a public no-args constructor"); } }
private static UIProvider getUIProvider(String uiProviderProperty, ClassLoader classLoader) throws ServiceException { try { Class<?> providerClass = classLoader.loadClass(uiProviderProperty); Class<? extends UIProvider> subclass = providerClass .asSubclass(UIProvider.class); return ReflectTools.createInstance(subclass); } catch (ClassNotFoundException e) { throw new ServiceException( "Could not load UIProvider class " + uiProviderProperty, e); } catch (ClassCastException e) { throw new ServiceException("UIProvider class " + uiProviderProperty + " does not extend UIProvider", e); } }
public static void checkUiProviders(VaadinSession session, VaadinService vaadinService) throws ServiceException { if (session.getUIProviders().isEmpty()) { throw new ServiceException( "No UIProvider has been added and there is no \"" + VaadinSession.UI_PARAMETER + "\" init parameter."); } }
return addedConnectorIdGenerators.get(0); default: throw new ServiceException( "Cannot start application since there are multiple connector id generators. Remove redundant implementations from the classpath or override VaadinService.initConenctorIdGenerator to explicitly select one to use. The found generators are: " + addedConnectorIdGenerators);
static Class<? extends LegacyApplication> getLegacyApplicationClass( VaadinService vaadinService) throws ServiceException { Properties initParameters = vaadinService.getDeploymentConfiguration() .getInitParameters(); String applicationParameter = initParameters.getProperty("application"); ClassLoader classLoader = vaadinService.getClassLoader(); if (applicationParameter == null) { throw new ServiceException( "No \"application\" init parameter found"); } try { return classLoader.loadClass(applicationParameter) .asSubclass(LegacyApplication.class); } catch (final ClassNotFoundException e) { throw new ServiceException( "Failed to load application class: " + applicationParameter, e); } }
@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 void init(PortletConfig portletConfig) throws PortletException { super.init(portletConfig); getService().addSessionInitListener((SessionInitEvent event) -> { try { onVaadinSessionStarted( (VaadinPortletRequest) event.getRequest(), (VaadinPortletSession) event.getSession()); } catch (PortletException e) { throw new ServiceException(e); } }); }
throw new ServiceException( "Handling of session expired failed", e); throw new ServiceException(e);
throw new ServiceException(t);
private void configureRouter(String configuratorClassName) throws ServiceException { try { Class<?> configuratorClass = Class.forName(configuratorClassName, true, getClassLoader()); if (!RouterConfigurator.class.isAssignableFrom(configuratorClass)) { throw new IllegalStateException( "The defined router configurator class " + configuratorClassName + " does not implement " + RouterConfigurator.class.getName()); } if (configuratorClass.getDeclaringClass() != null && !Modifier.isStatic(configuratorClass.getModifiers())) { throw new ServiceException("Configurator class " + configuratorClassName + " cannot be a non-static inner class. " + "If an inner class is used, it must be static."); } RouterConfigurator configurator = (RouterConfigurator) ReflectTools .createInstance(configuratorClass); getRouter().reconfigure(configurator); } catch (ClassNotFoundException e) { throw new ServiceException( "Could not find router class " + configuratorClassName, e); } }
@Override public void sessionInit(SessionInitEvent event) throws ServiceException { try { ApplicationContext context = PortletApplicationContextUtils .getRequiredWebApplicationContext(getPortletContext()); SpringAwareUIProvider uiProvider = new SpringAwareUIProvider(context); event.getSession().addUIProvider(uiProvider); } catch (IllegalStateException e) { throw new ServiceException(e); } } });
throw new ServiceException( "Handling of session expired failed", e); throw new ServiceException(e);
atmosphere = initAtmosphere(vaadinServletConfig); } catch (Exception e) { throw new ServiceException( "Failed to initialize Atmosphere for " + service.getServlet().getServletName()
throw new ServiceException(t);