List of usage examples for com.vaadin.server VaadinRequest getService
public VaadinService getService();
From source file:com.freebox.engeneering.application.web.common.ApplicationUIProvider.java
License:Apache License
@SuppressWarnings("unchecked") @Override/*w w w. j a v a 2s . c o m*/ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { VaadinRequest request = event.getRequest(); Object uiBeanNameObj = request.getService().getDeploymentConfiguration() .getApplicationOrSystemProperty("UIBean", null); if (uiBeanNameObj instanceof String) { String uiBeanName = uiBeanNameObj.toString(); final ApplicationContext applicationContext = ApplicationContextLocator.getApplicationContext(); final Class<? extends UI> bean = (Class<? extends UI>) applicationContext.getType(uiBeanName); if (bean != null) { return bean; } else { ClassLoader classLoader = request.getService().getClassLoader(); try { Class<? extends UI> uiClass = Class.forName(uiBeanName, true, classLoader).asSubclass(UI.class); return uiClass; } catch (ClassNotFoundException e) { throw new RuntimeException("Could not find UI class", e); } } } return null; }
From source file:com.freebox.engeneering.application.web.common.ApplicationUIProvider.java
License:Apache License
@Override public UI createInstance(UICreateEvent event) { VaadinRequest request = event.getRequest(); Object uiBeanNameObj = request.getService().getDeploymentConfiguration() .getApplicationOrSystemProperty("UIBean", null); //Stored in VaadinSession to use it in // the ApplicationScope later to initialize vaadin application scope beans final Integer uiId = event.getUiId(); VaadinSession.getCurrent().setAttribute("applicationScope.UiId", uiId); if (uiBeanNameObj instanceof String) { String uiBeanName = uiBeanNameObj.toString(); return (UI) ApplicationContextLocator.getBean(uiBeanName); }/* w w w . j av a 2 s. co m*/ return super.createInstance(event); }
From source file:com.klwork.explorer.web.SpringUIProvider.java
License:Apache License
/** * Returns the bean name to be retrieved from the application bean context and * used as the UI. The default implementation uses the servlet init property * {@link #BEAN_NAME_PARAMETER} or "ui" if not defined. * * @param request the current Vaadin request * @return the UI bean name in the application context *///from ww w . j a va2s . c om protected String getUIBeanName(VaadinRequest request) { String vaadinBeanName = "ui"; //beanName, web.xml ?MyUi Object uiBeanName = request.getService().getDeploymentConfiguration() .getApplicationOrSystemProperty(BEAN_NAME_PARAMETER, null); if (uiBeanName != null && uiBeanName instanceof String) { vaadinBeanName = uiBeanName.toString(); } logger.debug("found BEAN_NAME_PARAMETER: {}", vaadinBeanName); return vaadinBeanName; }
From source file:com.lexaden.platform.web.ApplicationUIProvider.java
License:Apache License
@SuppressWarnings("unchecked") @Override/*from w w w. ja v a 2s . c o m*/ public UI createInstance(UICreateEvent event) { VaadinRequest request = event.getRequest(); Object uiBeanNameObj = request.getService().getDeploymentConfiguration() .getApplicationOrSystemProperty("UIBean", null); //Stored in VaadinSession to use it in // the ApplicationScope later to initialize vaadin application scope beans final Integer uiId = event.getUiId(); VaadinSession.getCurrent().setAttribute("applicationScope.UiId", uiId); if (uiBeanNameObj instanceof String) { String uiBeanName = uiBeanNameObj.toString(); return (UI) ApplicationContextLocator.getBean(uiBeanName); } return super.createInstance(event); }
From source file:org.lunifera.runtime.web.gyrex.vaadin.internal.VaadinOSGiServlet.java
License:Open Source License
@Override protected OSGiServletService createServletService(DeploymentConfiguration deploymentConfiguration) { OSGiServletService service = new OSGiServletService(this, deploymentConfiguration, webAppProperties, new OSGiServletService.IVaadinSessionFactory() { @Override/* www . j a va 2 s. c o m*/ public VaadinSession createSession(VaadinRequest request, HttpServletRequest httpServletRequest) { VaadinSession session = new VaadinSession(request.getService()); for (UiProviderInfo info : tracker.getInfos()) { session.addUIProvider(new OSGiUIProvider(info.getFactory(), info.getProviderClass())); } return session; } }); return service; }
From source file:org.lunifera.runtime.web.vaadin.osgi.servlet.VaadinOSGiServlet.java
License:Open Source License
@Override protected OSGiServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException { // create the servlet service initialized with the ui provider OSGiServletService service = new OSGiServletService(this, deploymentConfiguration, new OSGiServletService.IVaadinSessionFactory() { @Override/* w w w . j av a 2 s . com*/ public VaadinSession createSession(VaadinRequest request, HttpServletRequest httpServletRequest) { VaadinSession session = new VaadinSession(request.getService()); for (UIProvider provider : webApplication.getUiProviders()) { session.addUIProvider(provider); } return session; } }); service.init(); return service; }
From source file:org.lunifera.runtime.web.vaadin.standalone.servlet.VaadinOSGiServlet.java
License:Open Source License
@Override protected OSGiServletService createServletService(DeploymentConfiguration deploymentConfiguration) { // create the servlet service initialized with the ui provider OSGiServletService service = new OSGiServletService(this, deploymentConfiguration, new OSGiServletService.IVaadinSessionFactory() { @Override/*from ww w .j a v a 2s . co m*/ public VaadinSession createSession(VaadinRequest request, HttpServletRequest httpServletRequest) { VaadinSession session = new VaadinSession(request.getService()); for (OSGiUIProvider provider : webApplication.getUiProviders()) { session.addUIProvider(provider); } return session; } }); return service; }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
@Override protected void init(final VaadinRequest request) { // Register a cleanup request.getService().addSessionDestroyListener( (SessionDestroyListener) event -> m_widgetManager.removeUpdateListener(TopologyUI.this)); try {//from w w w .j a v a 2s .com m_headerHtml = getHeader(((VaadinServletRequest) request).getHttpServletRequest()); } catch (final Exception e) { LOG.error("failed to get header HTML for request " + request.getPathInfo(), e.getCause()); } //create VaadinApplicationContext m_applicationContext = m_serviceManager.createApplicationContext(new VaadinApplicationContextCreator() { @Override public VaadinApplicationContext create(OnmsServiceManager manager) { VaadinApplicationContextImpl context = new VaadinApplicationContextImpl(); context.setSessionId(request.getWrappedSession().getId()); context.setUiId(getUIId()); context.setUsername(request.getRemoteUser()); return context; } }); m_verticesUpdateManager = new OsgiVerticesUpdateManager(m_serviceManager, m_applicationContext); m_serviceManager.getEventRegistry().addPossibleEventConsumer(this, m_applicationContext); // Set the algorithm last so that the criteria and SZLs are // in place before we run the layout algorithm. m_graphContainer.setSessionId(m_applicationContext.getSessionId()); m_graphContainer.setLayoutAlgorithm(new TopoFRLayoutAlgorithm()); createLayouts(); setupErrorHandler(); // Set up an error handler for UI-level exceptions setupAutoRefresher(); // Add an auto refresh handler to the GraphContainer loadUserSettings(); // the layout must be created BEFORE loading the hop criteria and the semantic zoom level TopologyUIRequestHandler handler = new TopologyUIRequestHandler(); getSession().addRequestHandler(handler); // Add a request handler that parses incoming focusNode and szl query parameters handler.handleRequestParameter(request); // deal with those in init case // Add the default criteria if we do not have already a criteria set if (getWrappedVertexHopCriteria(m_graphContainer).isEmpty() && noAdditionalFocusCriteria()) { m_graphContainer.addCriteria(m_graphContainer.getBaseTopology().getDefaultCriteria()); // set default } // If no Topology Provider was selected (due to loadUserSettings(), fallback to default if (m_graphContainer.getBaseTopology() == null || m_graphContainer.getBaseTopology() == MergingGraphProvider.NULL_PROVIDER) { TopologySelectorOperation defaultTopologySelectorOperation = createOperationForDefaultGraphProvider( m_bundlecontext, "(|(label=Enhanced Linkd)(label=Linkd))"); Objects.requireNonNull(defaultTopologySelectorOperation, "No default GraphProvider found."); // no default found, abort defaultTopologySelectorOperation.execute(m_graphContainer); } // We set the listeners at the end, to not fire them all the time when initializing the UI setupListeners(); // We force a reload of the topology provider as it may not have been initialized m_graphContainer.getBaseTopology().refresh(); // We force a reload to trigger a fireGraphChanged() m_graphContainer.setDirty(true); m_graphContainer.redoLayout(); // Trigger a selectionChanged m_selectionManager.selectionChanged(m_selectionManager); }
From source file:org.opennms.features.vaadin.nodemaps.internal.NodeMapsApplication.java
License:Open Source License
@Override protected void init(final VaadinRequest vaadinRequest) { m_request = vaadinRequest;//from w w w .ja v a 2s .co m LOG.debug("initializing"); final VaadinApplicationContextImpl context = new VaadinApplicationContextImpl(); final UI currentUI = UI.getCurrent(); context.setSessionId(currentUI.getSession().getSession().getId()); context.setUiId(currentUI.getUIId()); context.setUsername(vaadinRequest.getRemoteUser()); Assert.notNull(m_alarmTable); Assert.notNull(m_nodeTable); final String searchString = vaadinRequest.getParameter("search"); final Integer maxClusterRadius = Integer.getInteger("gwt.maxClusterRadius", 350); LOG.info("Starting search string: {}, max cluster radius: {}", searchString, maxClusterRadius); m_alarmTable.setVaadinApplicationContext(context); final EventProxy eventProxy = new EventProxy() { @Override public <T> void fireEvent(final T eventObject) { LOG.debug("got event: {}", eventObject); if (eventObject instanceof VerticesUpdateEvent) { final VerticesUpdateEvent event = (VerticesUpdateEvent) eventObject; final List<Integer> nodeIds = new ArrayList<Integer>(); for (final VertexRef ref : event.getVertexRefs()) { if ("nodes".equals(ref.getNamespace()) && ref.getId() != null) { nodeIds.add(Integer.valueOf(ref.getId())); } } m_mapWidgetComponent.setSelectedNodes(nodeIds); return; } LOG.warn("Unsure how to deal with event: {}", eventObject); } @Override public <T> void addPossibleEventConsumer(final T possibleEventConsumer) { LOG.debug("(ignoring) add consumer: {}", possibleEventConsumer); /* throw new UnsupportedOperationException("Not yet implemented!"); */ } }; m_alarmTable.setEventProxy(eventProxy); m_nodeTable.setEventProxy(eventProxy); createMapPanel(searchString, maxClusterRadius); createRootLayout(); addRefresher(); // Notify the user if no tileserver url or options are set if (!NodeMapConfiguration.isValid()) { new InvalidConfigurationWindow().open(); } // Schedule refresh of node data m_executor.scheduleWithFixedDelay(() -> m_mapWidgetComponent.refreshNodeData(), 0, 5, TimeUnit.MINUTES); // If we do not shutdown the executor, the scheduler keeps refreshing the node data, even if the // UI may already been detached, resulting at one point in a OutOfMemory. See NMS-8589. vaadinRequest.getService().addSessionDestroyListener(new SessionDestroyListener() { @Override public void sessionDestroy(SessionDestroyEvent event) { m_executor.shutdown(); } }); }
From source file:org.semanticsoft.vaaclipse.app.servlet.VaadinOSGiServlet.java
License:Open Source License
@Override protected OSGiServletService createServletService(DeploymentConfiguration deploymentConfiguration) { // create the servlet service initialized with the ui provider OSGiServletService service = new OSGiServletService(this, deploymentConfiguration, new OSGiServletService.IVaadinSessionFactory() { @Override//from w w w . j a v a 2 s. c o m public VaadinSession createSession(VaadinRequest request, HttpServletRequest httpServletRequest) { VaadinSession session = new VaadinSession(request.getService()); session.addUIProvider(new OSGiUIProvider()); return session; } }); return service; }