Class SwingBridgeVaadinServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable
@WebServlet(urlPatterns = "/*", asyncSupported = true)
public class AppServlet extends SwingBridgeVaadinServlet {}
That empty subclass is the whole host-app servlet. It exists only to carry the app's own
@WebServlet mapping, which is the app's to choose.
Why the lock has to be wrapped. EHelper.callSwing runs every peer→Swing
callback as a UI fiber — a virtual thread — so a modal dialog can park, and the session lock is
held by the *carrier* platform thread rather than by the virtual thread mounted on it — so a
virtual thread taking that lock would deadlock its session. VirtualThreadAwareLock makes
both the check and the acquisition work; the loom runner's SessionLockCheck refuses a
deployment that skipped it, at each session's first request (R_match_swing_errors case (9),
D_vt_aware_session_lock). This class is how an app stops having to know that.
It deliberately installs no ErrorHandler — that is app policy, not runtime
plumbing. Install one from a SessionInitListener, which reaches
the same place as overriding createVaadinSession because
ErrorEvent.findErrorHandler reads the session's handler when the error happens
(D_library_servlet).
On Spring, do not use this class — the servlet has to extend SpringServlet so
Vaadin's own bean-based route and instantiator discovery keeps working. See
:emulators-spring, which auto-configures the equivalent.
An app needing its own VaadinServletService overrides
createSwingBridgeService(DeploymentConfiguration), not createServletService — which is final
here, so the wrap cannot be dropped and service.init() cannot be forgotten.
SamplerServlet is the worked example. An app whose service must extend something else
entirely cannot use this class at all: extend VaadinServlet and apply
VirtualThreadAwareLock.wrap(VaadinService, WrappedSession, Lock) in your own getSessionLock, which is public for
exactly that case.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAVaadinServletServicewhose session lock is virtual-thread-aware. -
Field Summary
Fields inherited from class com.vaadin.flow.server.VaadinServlet
INTERNAL_VAADIN_SERVLET_VITE_DEV_MODE_FRONTEND_PATHFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final com.vaadin.flow.server.VaadinServletServicecreateServletService(com.vaadin.flow.function.DeploymentConfiguration configuration) finalon purpose: this is the seam through which the session-lock wrap could be lost silently, and losing it surfaces later and elsewhere as aStackOverflowErrorin Vaadin internals.createSwingBridgeService(com.vaadin.flow.function.DeploymentConfiguration configuration) The service this servlet runs on, beforeinit().Methods inherited from class com.vaadin.flow.server.VaadinServlet
createDeploymentConfiguration, createDeploymentConfiguration, createServletService, createStaticFileHandler, createVaadinRequest, destroy, getCurrent, getFrontendMapping, getLastPathParameter, getService, getServletConfig, handleContextOrServletRootWithoutSlash, init, serveStaticOrWebJarRequest, service, servletInitialized, whenFrontendMappingAvailableMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
SwingBridgeVaadinServlet
public SwingBridgeVaadinServlet()
-
-
Method Details
-
createServletService
protected final com.vaadin.flow.server.VaadinServletService createServletService(com.vaadin.flow.function.DeploymentConfiguration configuration) throws com.vaadin.flow.server.ServiceException finalon purpose: this is the seam through which the session-lock wrap could be lost silently, and losing it surfaces later and elsewhere as aStackOverflowErrorin Vaadin internals. OverridecreateSwingBridgeService(DeploymentConfiguration)instead.- Overrides:
createServletServicein classcom.vaadin.flow.server.VaadinServlet- Throws:
com.vaadin.flow.server.ServiceException
-
createSwingBridgeService
protected SwingBridgeVaadinServlet.SwingBridgeVaadinServletService createSwingBridgeService(com.vaadin.flow.function.DeploymentConfiguration configuration) throws com.vaadin.flow.server.ServiceException The service this servlet runs on, beforeinit(). Override to add your own service behaviour; the return type is what keeps the session-lock wrap in place whatever you return.- Returns:
- a new instance, uninitialized —
createServletService(DeploymentConfiguration)callsinit() - Throws:
com.vaadin.flow.server.ServiceException
-