com.vaadin.flow.di.
Interface AbstractLookupInitializer
All Known Implementing Classes:
LookupInitializer
, SpringLookupInitializer
, UITestSpringLookupInitializer
SPI for customizing lookup in applications inside Servlet 5.0 containers.
There are two ways of customizing Lookup in various servlet containers:
- Use
AbstractLookupInitializer
SPI via providing an implementation for the framework which doesn't preventLookupServletContainerInitializer
execution. - Completely disable
LookupServletContainerInitializer
and implement own way to set upLookup
and make it available viaVaadinContext.getAttribute(Class)
.
Lookup
creation and initialization
in case when it's not possible to prevent
LookupServletContainerInitializer
execution (any container which
completely supports Servlet 5.0 specification). In this case it's possible to
implement AbstractLookupInitializer
for the framework.
The second case is only possible when a servlet container doesn't run
ServletContainerInitializer
s out of the box (e.g. OSGi or Spring boot
executed as a Jar) at all. Otherwise you may not disable an existing
ServletContainerInitializer
and it will be executed anyway.
This is SPI for Lookup
SPI. The difference is:
Lookup
allows to override services per Web application (by the application developer). For some service interfaces there can be several implementations available inLookup
.AbstractLookupInitializer
allows to override how theLookup
works per framework. The default implementation available if no framework is used. Only one service implementation (excluding the default one) may be available in the web application classpath and it's provided by the developers for the framework support (the main usecase here is Spring add-on).
Since:
Author:
Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionvoid
initialize
(VaadinContext context, Map<Class<?>, Collection<Class<?>>> services, VaadinApplicationInitializationBootstrap bootstrap) Creates a new
Lookup
instance, initializes it and passes it to the providedbootstrap
.
-
Method Details
-
initialize
void initialize(VaadinContext context, Map<Class<?>, Collection<Class<?>>> services, VaadinApplicationInitializationBootstrap bootstrap) throws jakarta.servlet.ServletExceptionCreates a new
Lookup
instance, initializes it and passes it to the providedbootstrap
.The method should creates a new initialized
Lookup
instance. In some cases it's not possible to create the instance right away when the method is called. To be able to support this usecase the method contract doesn't require to return theLookup
instance. Instead the created instance should be passed to the providedbootstrap
consumer once the instance is created and completely initialized. Thebootstrap
will start the application initialization which otherwise is postponed until aLookup
becomes available.The implementation must use the provided
bootstrap
to pass theLookup
instance otherwise the web application based on thisLookupInitializer
will never be bootstrapped.The provided
services
map contains service implementations found in application classpath using@HandlesTypes
annotation declared forLookupServletContainerInitializer
.Parameters:
context
- a Vaadin context to run initialization forservices
- the map of internal services with their implementations found in the application classpathbootstrap
- the web application bootstrapThrows:
jakarta.servlet.ServletException
- if initialization failed
-