public interface AbstractLookupInitializer
There are two ways of customizing Lookup in various servlet containers:
AbstractLookupInitializer
SPI via providing an implementation
for the framework which doesn't prevent
LookupServletContainerInitializer
execution.
LookupServletContainerInitializer
and
implement own way to set up Lookup
and make it available via
VaadinContext.getAttribute(Class)
.
Lookup
creation and initialization
in case when it's not possible to prevent
LookupServletContainerInitializer
execution (any container which
completely supports Servlet 3.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 in Lookup
.
AbstractLookupInitializer
allows to override how the
Lookup
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).
Modifier and Type | Method and Description |
---|---|
void |
initialize(VaadinContext context,
Map<Class<?>,Collection<Class<?>>> services,
VaadinApplicationInitializationBootstrap bootstrap)
Creates a new
Lookup instance, initializes it and passes it to
the provided bootstrap . |
void initialize(VaadinContext context, Map<Class<?>,Collection<Class<?>>> services, VaadinApplicationInitializationBootstrap bootstrap) throws ServletException
Lookup
instance, initializes it and passes it to
the provided bootstrap
.
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 the Lookup
instance. Instead the
created instance should be passed to the provided bootstrap
consumer once the instance is created and completely initialized. The
bootstrap
will start the application initialization which
otherwise is postponed until a Lookup
becomes available.
The implementation must use the provided bootstrap
to pass the
Lookup
instance otherwise the web application based on this
LookupInitializer
will never be bootstrapped.
The provided services
map contains service implementations found
in application classpath using @HandlesTypes
annotation declared
for LookupServletContainerInitializer
.
context
- a Vaadin context to run initialization forservices
- the map of internal services with their implementations found
in the application classpathbootstrap
- the web application bootstrapServletException
- if initialization failedCopyright © 2023. All rights reserved.