Class BrowserlessApplicationContext

java.lang.Object
com.vaadin.browserless.BrowserlessApplicationContext
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
SecuredBrowserlessApplicationContext

public class BrowserlessApplicationContext extends Object implements AutoCloseable
Application-level context for multi-user browserless testing.

Manages a shared VaadinServletService and servlet that are shared across all users and their windows. This models the application level of the Vaadin hierarchy: one application contains multiple user sessions, each with multiple UI instances (browser windows).

Instances of this class are thread-affine: they must be created, used, and closed on the same thread. The active context is held in a ThreadLocal and is not visible to other threads. This class is not safe for concurrent access from multiple threads; driving the same context from parallel test threads is unsupported.

This base class is unsecured: it has no SecurityContextHandler. For multi-user security isolation, configure a handler via BrowserlessApplicationContext.Builder.withSecurityContextHandler(SecurityContextHandler) — the builder transitions to SecuredBrowserlessApplicationContext.Builder and build() returns the typed SecuredBrowserlessApplicationContext, which exposes credential-aware newUser(...) overloads. Framework-specific modules (Spring, Quarkus) provide convenience factory methods for both paths.

 var app = BrowserlessApplicationContext.create(MyView.class);
 var user1 = app.newUser();
 var window1 = user1.newWindow();
 window1.navigate(MyView.class);
 // ...
 app.close();
 
See Also: