/** * Returns the internal push connection object used by this UI. This method * should only be called by the framework. * <p> * This method is not intended to be overridden. If it is overridden, care * should be taken since this method might be called in situations where * {@link UI#getCurrent()} does not return this UI. * * @return the push connection used by this UI, or {@code null} if push is * not available. */ public PushConnection getPushConnection() { assert !(getPushConfiguration().getPushMode().isEnabled() && pushConnection == null); return pushConnection; }
getPushConfiguration().setPushMode(PushMode.DISABLED);
/** * Sets the internal push connection object used by this UI. This method * should only be called by the framework. * <p> * The {@code pushConnection} argument must be non-null if and only if * {@code getPushConfiguration().getPushMode().isEnabled()}. * * @param pushConnection * the push connection to use for this UI */ public void setPushConnection(PushConnection pushConnection) { // If pushMode is disabled then there should never be a pushConnection; // if enabled there should always be assert (pushConnection == null) ^ getPushConfiguration().getPushMode().isEnabled(); if (pushConnection == this.pushConnection) { return; } if (this.pushConnection != null && this.pushConnection.isConnected()) { this.pushConnection.disconnect(); } this.pushConnection = pushConnection; }
if (!getPushConfiguration().getPushMode().isEnabled()) { throw new IllegalStateException("Push not enabled");
PushMode pushMode = ui.getPushConfiguration().getPushMode(); AtmospherePushConnection pushConnection = getConnectionForUI(ui);
.getPushMode(); ui.getPushConfiguration().setPushMode(pushMode); ui.getPushConfiguration().setTransport(transport);
if (ui.getPushConfiguration() .getPushMode() == PushMode.AUTOMATIC) { Map<Class<?>, CurrentInstance> oldCurrent = CurrentInstance
/** * Returns the internal push connection object used by the related UI. This * method should only be called by the framework. * <p> * This method is not intended to be overridden. If it is overridden, care * should be taken since this method might be called in situations where * {@link UI#getCurrent()} does not return the UI. * * @return the push connection used by the UI, or {@code null} if push is * not available. */ public PushConnection getPushConnection() { assert !(ui.getPushConfiguration().getPushMode().isEnabled() && pushConnection == null); return pushConnection; }
protected UI createAndInitUI(Class<? extends UI> uiClass, VaadinRequest request, VaadinSession session) { Integer uiId = Integer.valueOf(session.getNextUIid()); UI ui = ReflectTools.createInstance(uiClass); // Initialize some fields for a newly created UI ui.getInternals().setSession(session); PushMode pushMode = AnnotationReader.getPushMode(uiClass).orElseGet( session.getService().getDeploymentConfiguration()::getPushMode); ui.getPushConfiguration().setPushMode(pushMode); AnnotationReader.getPushTransport(uiClass) .ifPresent(ui.getPushConfiguration()::setTransport); // Set thread local here so it is available in init UI.setCurrent(ui); ui.doInit(request, uiId.intValue()); session.addUI(ui); return ui; }
final UI currentUI = UI.getCurrent(); if (currentUI != null) { final Transport transport = currentUI.getPushConfiguration().getTransport(); if (Transport.WEBSOCKET.equals(transport) || Transport.WEBSOCKET_XHR.equals(transport)) { LOGGER.warn(
/** * Sets the internal push connection object used by the the related UI. This * method should only be called by the framework. * <p> * The {@code pushConnection} argument must be non-null if and only if * {@code getPushConfiguration().getPushMode().isEnabled()}. * * @param pushConnection * the push connection to use for the UI */ public void setPushConnection(PushConnection pushConnection) { // If pushMode is disabled then there should never be a pushConnection; // if enabled there should always be assert (pushConnection == null) ^ ui.getPushConfiguration().getPushMode().isEnabled(); if (pushConnection == this.pushConnection) { return; } if (this.pushConnection != null && this.pushConnection.isConnected()) { this.pushConnection.disconnect(); } this.pushConnection = pushConnection; }
final UI currentUI = UI.getCurrent(); if (currentUI != null) { final Transport transport = currentUI.getPushConfiguration().getTransport(); if (Transport.WEBSOCKET.equals(transport) || Transport.WEBSOCKET_XHR.equals(transport)) { LOGGER.warn(
ui.getPushConfiguration().setPushMode(PushMode.DISABLED); setPushConnection(null);
public PushMode getPushMode() { if (pushMode == null) { pushMode = getUI().getPushConfiguration().getPushMode(); if (pushMode == null) { pushMode = getRequest().getService() .getDeploymentConfiguration().getPushMode(); } if (pushMode.isEnabled() && !getRequest().getService().ensurePushAvailable()) { /* * Fall back if not supported (ensurePushAvailable will log * information to the developer the first time this happens) */ pushMode = PushMode.DISABLED; } } return pushMode; }
PushMode pushMode = ui.getPushConfiguration().getPushMode(); AtmospherePushConnection pushConnection = getConnectionForUI(ui);
if (ui.getPushConfiguration() .getPushMode() == PushMode.AUTOMATIC) { Map<Class<?>, CurrentInstance> oldCurrent = CurrentInstance
if (!getPushConfiguration().getPushMode().isEnabled()) { throw new IllegalStateException("Push not enabled");