/** * Gets the related Vaadin service. * * @return the Vaadin service */ public VaadinService getService() { return session.getService(); } }
/** * Creates a new event for the given session and connector. * * @param session * the session for which a connector id is needed, not * <code>null</code> * @param connector * the connector that should get an id, not <code>null</code> */ public ConnectorIdGenerationEvent(VaadinSession session, ClientConnector connector) { super(session.getService()); assert session != null; assert connector != null; this.session = session; this.connector = connector; }
private static String getSessionDetails(VaadinSession session) { if (session == null) { return null; } else { return session + " for " + session.getService().getServiceName(); } }
/** * Sets current instances for the {@link VaadinSession} and all related * classes. The previously defined values can be restored by passing the * returned map to {@link #restoreInstances(Map)}. * * @since 7.1 * * @param session * The VaadinSession * @return A map containing the old values of the instances this method * updated. */ public static Map<Class<?>, CurrentInstance> setCurrent( VaadinSession session) { Map<Class<?>, CurrentInstance> old = new HashMap<>(); old.put(VaadinSession.class, set(VaadinSession.class, session)); VaadinService service = null; if (session != null) { service = session.getService(); } old.put(VaadinService.class, set(VaadinService.class, service)); return old; }
return getService().accessSession(this, runnable);
/** * Generates a unique id to use for a newly attached connector. * * @see ConnectorIdGenerator * @see #initConnectorIdGenerator(List) * * @since 8.1 * * @param session * the session to which the connector has been attached, not * <code>null</code> * @param connector * the attached connector for which to generate an id, not * <code>null</code> * @return a string id that is unique within the session, not * <code>null</code> */ public String generateConnectorId(VaadinSession session, ClientConnector connector) { assert session.getService() == this; String connectorId = connectorIdGenerator.generateConnectorId( new ConnectorIdGenerationEvent(session, connector)); assert connectorId != null; return connectorId; }
String requestToken) { if (session.getService().getDeploymentConfiguration() .isXsrfProtectionEnabled()) { String sessionToken = session.getCsrfToken();
/** * Adds the performance timing data (used by TestBench 3) to the UIDL * response. * * @throws IOException */ private void writePerformanceData(UI ui, Writer writer) throws IOException { if (!ui.getSession().getService().getDeploymentConfiguration() .isProductionMode()) { writer.write(String.format(", \"timings\":[%d, %d]", ui.getSession().getCumulativeRequestDuration(), ui.getSession().getLastRequestDuration())); } }
InputStream is = null; try { is = ui.getSession().getService().getThemeResourceAsStream(ui, ui.getTheme(), resource); } catch (final Exception e) {
@Override public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { UI uI = session.getService().findUI(request); if (uI == null) { getUINotFoundErrorJSON(session.getService(), request)); return true;
/** * Handles a heartbeat request for the given session. Reads the GET * parameter named {@link UIConstants#UI_ID_PARAMETER} to identify the UI. * If the UI is found in the session, sets it * {@link UI#getLastHeartbeatTimestamp() heartbeat timestamp} to the current * time. Otherwise, writes a HTTP Not Found error to the response. */ @Override public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { UI ui = session.getService().findUI(request); if (ui != null) { ui.setLastHeartbeatTimestamp(System.currentTimeMillis()); // Ensure that the browser does not cache heartbeat responses. // iOS 6 Safari requires this (#10370) response.setHeader("Cache-Control", "no-cache"); // If Content-Type is not set, browsers assume text/html and may // complain about the empty response body (#12182) response.setHeader("Content-Type", "text/plain"); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND, "UI not found"); } return true; }
VaadinService service = serviceSession.getService();
VaadinService service = session.getService(); SystemMessages messages = ui.getSession().getService() .getSystemMessages(ui.getLocale(), null);
@Override public void setPushMode(PushMode pushMode) { if (pushMode == null) { throw new IllegalArgumentException("Push mode cannot be null"); } VaadinSession session = ui.getSession(); if (session == null) { throw new UIDetachedException( "Cannot set the push mode for a detached UI"); } assert session.hasLock(); if (pushMode.isEnabled() && !session.getService().ensurePushAvailable()) { throw new IllegalStateException( "Push is not available. See previous log messages for more information."); } PushMode oldMode = getState().mode; if (oldMode != pushMode) { getState().mode = pushMode; if (!oldMode.isEnabled() && pushMode.isEnabled()) { // The push connection is initially in a disconnected state; // the client will establish the connection ui.setPushConnection(new AtmospherePushConnection(ui)); } // Nothing to do here if disabling push; // the client will close the connection } }
getService().runPendingAccessTasks(this); getService().ensureAccessQueuePurged(this);
session.getService().runPendingAccessTasks(session);
session.getService().runPendingAccessTasks(session);
uI = session.getService().findUI(request);
/** * Load and initialize the mobile drag-drop-polyfill if needed and not yet * done so. */ private void loadMobileHtml5DndPolyfill() { if (mobileHtml5DndPolyfillLoaded) { return; } if (!getPage().getWebBrowser().isTouchDevice()) { return; } mobileHtml5DndPolyfillLoaded = true; String vaadinLocation = getSession().getService().getStaticFileLocation( VaadinService.getCurrentRequest()) + "/VAADIN/"; getPage().addDependency(new Dependency(Type.JAVASCRIPT, vaadinLocation + ApplicationConstants.MOBILE_DND_POLYFILL_JS)); getRpcProxy(PageClientRpc.class).initializeMobileHtml5DndPolyfill(); }
pushMode = session.getService().getDeploymentConfiguration() .getPushMode();