Interface AbstractLookupInitializer
- All Known Implementing Classes:
LookupInitializer,SpringLookupInitializer,UITestSpringLookupInitializer
There are two ways of customizing Lookup in various servlet containers:
- Use
AbstractLookupInitializerSPI via providing an implementation for the framework which doesn't preventLookupServletContainerInitializerexecution. - Completely disable
LookupServletContainerInitializerand implement own way to set upLookupand 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
ServletContainerInitializers 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:
Lookupallows to override services per Web application (by the application developer). For some service interfaces there can be several implementations available inLookup.AbstractLookupInitializerallows to override how theLookupworks 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).
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionvoidinitialize(VaadinContext context, Map<Class<?>, Collection<Class<?>>> services, VaadinApplicationInitializationBootstrap bootstrap) Creates a newLookupinstance, 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 newLookupinstance, initializes it and passes it to the providedbootstrap.The method should creates a new initialized
Lookupinstance. 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 theLookupinstance. Instead the created instance should be passed to the providedbootstrapconsumer once the instance is created and completely initialized. Thebootstrapwill start the application initialization which otherwise is postponed until aLookupbecomes available.The implementation must use the provided
bootstrapto pass theLookupinstance otherwise the web application based on thisLookupInitializerwill never be bootstrapped.The provided
servicesmap contains service implementations found in application classpath using@HandlesTypesannotation 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 bootstrap- Throws:
jakarta.servlet.ServletException- if initialization failed
-