Package com.vaadin.browserless
Class SpringBrowserlessApplicationContext
java.lang.Object
com.vaadin.browserless.SpringBrowserlessApplicationContext
Factory for creating a Spring-integrated
BrowserlessApplicationContext.
Wires a Spring-aware servlet and the
BrowserlessTestSpringLookupInitializer so the test context can reach
Spring beans and lifecycle. Three entry points are provided:
create(Routes, ApplicationContext)— returns the unsecuredBrowserlessApplicationContext.createSecured(Routes, ApplicationContext)— returns the credential-typedSecuredBrowserlessApplicationContext; requires Spring Security on the classpath.builder(Routes, ApplicationContext)— returns a pre-wiredBrowserlessApplicationContext.Builderfor full customization (e.g. plugging in a different security handler).
var app = SpringBrowserlessApplicationContext.createSecured(routes,
springCtx);
var admin = app.newUser("admin", "ADMIN");
var window = admin.newWindow();
window.navigate(ProtectedView.class);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.vaadin.browserless.BrowserlessApplicationContext.Builderbuilder(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext) Creates a Spring-pre-wired builder.static com.vaadin.browserless.BrowserlessApplicationContext.Builderbuilder(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext, com.vaadin.browserless.internal.UIFactory uiFactory) Creates a Spring-pre-wired builder with a custom UI factory.static com.vaadin.browserless.BrowserlessApplicationContextcreate(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext) Creates an unsecured Spring-integrated application context.static com.vaadin.browserless.BrowserlessApplicationContextcreate(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext, com.vaadin.browserless.internal.UIFactory uiFactory) Creates an unsecured Spring-integrated application context with a custom UI factory.static com.vaadin.browserless.SecuredBrowserlessApplicationContext<org.springframework.security.core.Authentication> createSecured(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext) Creates a Spring-integrated application context with Spring Security wiring.static com.vaadin.browserless.SecuredBrowserlessApplicationContext<org.springframework.security.core.Authentication> createSecured(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext, com.vaadin.browserless.internal.UIFactory uiFactory) Creates a secured Spring-integrated application context with a custom UI factory.
-
Method Details
-
builder
public static com.vaadin.browserless.BrowserlessApplicationContext.Builder builder(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext) Creates a Spring-pre-wired builder. The builder has the Spring servlet, the lookup initializer and the lookup-initializer close hook configured; callers can chain additional customizations before callingBrowserlessApplicationContext.Builder.build().- Parameters:
routes- the discovered routesapplicationContext- the Spring application context- Returns:
- a pre-wired builder
-
builder
public static com.vaadin.browserless.BrowserlessApplicationContext.Builder builder(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext, com.vaadin.browserless.internal.UIFactory uiFactory) Creates a Spring-pre-wired builder with a custom UI factory.- Parameters:
routes- the discovered routesapplicationContext- the Spring application contextuiFactory- the UI factory- Returns:
- a pre-wired builder
-
create
public static com.vaadin.browserless.BrowserlessApplicationContext create(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext) Creates an unsecured Spring-integrated application context.- Parameters:
routes- the discovered routesapplicationContext- the Spring application context- Returns:
- a new unsecured application context configured for Spring
-
create
public static com.vaadin.browserless.BrowserlessApplicationContext create(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext, com.vaadin.browserless.internal.UIFactory uiFactory) Creates an unsecured Spring-integrated application context with a custom UI factory.- Parameters:
routes- the discovered routesapplicationContext- the Spring application contextuiFactory- the UI factory- Returns:
- a new unsecured application context configured for Spring
-
createSecured
public static com.vaadin.browserless.SecuredBrowserlessApplicationContext<org.springframework.security.core.Authentication> createSecured(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext) Creates a Spring-integrated application context with Spring Security wiring. Requires Spring Security on the classpath; throws otherwise.- Parameters:
routes- the discovered routesapplicationContext- the Spring application context- Returns:
- a new secured application context configured for Spring Security
- Throws:
IllegalStateException- if Spring Security is not on the classpath
-
createSecured
public static com.vaadin.browserless.SecuredBrowserlessApplicationContext<org.springframework.security.core.Authentication> createSecured(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext applicationContext, com.vaadin.browserless.internal.UIFactory uiFactory) Creates a secured Spring-integrated application context with a custom UI factory. Requires Spring Security on the classpath; throws otherwise.- Parameters:
routes- the discovered routesapplicationContext- the Spring application contextuiFactory- the UI factory- Returns:
- a new secured application context configured for Spring Security
- Throws:
IllegalStateException- if Spring Security is not on the classpath
-