/** * Creates the component that is responsible for Polymer template * functionality using the provided {@code parser}. * * @param parser * a template parser */ public PolymerTemplate(TemplateParser parser) { this(parser, VaadinService.getCurrent()); }
/** * Get the current {@link I18NProvider}, if available. * @return Optional current {@link I18NProvider} */ private static Optional<I18NProvider> getCurrentI18nProvider() { final VaadinService service = VaadinService.getCurrent(); if (service != null) { return Optional.ofNullable(VaadinService.getCurrent().getInstantiator().getI18NProvider()); } return Optional.empty(); }
/** * Creates the component that is responsible for Polymer template * functionality. */ public PolymerTemplate() { this(DefaultTemplateParser.getInstance(), VaadinService.getCurrent()); }
private static RouteRegistry getApplicationRegistry() { VaadinService service = VaadinService.getCurrent(); if (service instanceof VaadinServletService) { return ApplicationRouteRegistry .getInstance(((VaadinServletService) service).getServlet() .getServletContext()); } else { // TODO Once we have PortletService, this will explode // we will need route registry for portlet context throw new IllegalStateException("Cannot access " + ApplicationRouteRegistry.class.getName() + ", because no " + "VaadinServletService available for " + "fetching ServletContext"); } }
private I18NProvider getI18NProvider() { return VaadinService.getCurrent().getInstantiator().getI18NProvider(); }
private void reportException(Exception exception, String path, String exceptionText) { getElement().appendChild(Element.createText(exceptionText)); VaadinService vaadinService = VaadinService.getCurrent(); // Check that we have a vaadinService as else we will fail on a NPE and // the stacktrace we actually got will disappear and getting a NPE is // confusing. boolean productionMode = vaadinService != null && vaadinService .getDeploymentConfiguration().isProductionMode(); if (!productionMode) { checkLogBinding(); printStacktrace(exception); } getLogger().error( "There was an exception while trying to navigate to '{}'", path, exception); }
private Router getRouter() { Router router = null; if (getElement().getNode().isAttached()) { StateTree tree = (StateTree) getElement().getNode().getOwner(); router = tree.getUI().getRouter(); } if (router == null) { router = VaadinService.getCurrent().getRouter(); } if (router == null) { throw new IllegalStateException( "Implicit router instance is not available. " + "Use overloaded method with explicit router parameter."); } return router; }