public class LookupInitializer extends Object implements AbstractLookupInitializer
AbstractLookupInitializer
.AbstractLookupInitializer
Modifier and Type | Class and Description |
---|---|
protected static class |
LookupInitializer.LookupImpl
Default implementation of
Lookup . |
protected static class |
LookupInitializer.ResourceProviderImpl
Default implementation of
ResourceProvider . |
Modifier and Type | Field and Description |
---|---|
protected static String |
ONE_IMPL_REQUIRED |
protected static String |
SEVERAL_IMPLS |
protected static String |
SPI |
Constructor and Description |
---|
LookupInitializer() |
Modifier and Type | Method and Description |
---|---|
protected Lookup |
createLookup(VaadinContext context,
Map<Class<?>,Collection<Class<?>>> services)
Creates a lookup based on provided
services . |
protected <T> void |
ensureService(Map<Class<?>,Collection<Class<?>>> services,
Class<T> serviceType,
Class<? extends T> serviceImpl)
Ensures that provided
services contain implementation for
serviceType SPI. |
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 . |
protected <T> T |
instantiate(Class<T> serviceClass,
Class<?> implementation)
Instantiates service
implementation type with the given
serviceClass . |
protected static final String SPI
protected static final String ONE_IMPL_REQUIRED
protected static final String SEVERAL_IMPLS
public void initialize(VaadinContext context, Map<Class<?>,Collection<Class<?>>> services, VaadinApplicationInitializationBootstrap bootstrap) throws ServletException
AbstractLookupInitializer
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
.
initialize
in interface AbstractLookupInitializer
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 failedprotected Lookup createLookup(VaadinContext context, Map<Class<?>,Collection<Class<?>>> services)
services
.context
- a Vaadin context to create a lookup forservices
- the service objects mapped to the service type to create a
lookupprotected <T> void ensureService(Map<Class<?>,Collection<Class<?>>> services, Class<T> serviceType, Class<? extends T> serviceImpl)
services
contain implementation for
serviceType
SPI.
The default serviceImpl
implementation will be set as the
service into services
if there is no other services available.
services
- map of internal servicesserviceType
- SPI typeserviceImpl
- the default SPI implementationprotected <T> T instantiate(Class<T> serviceClass, Class<?> implementation)
implementation
type with the given
serviceClass
.T
- service typeserviceClass
- service classimplementation
- service implementation classCopyright © 2023. All rights reserved.