Class LookupInitializer
- java.lang.Object
-
- com.vaadin.flow.di.LookupInitializer
-
- All Implemented Interfaces:
AbstractLookupInitializer
public class LookupInitializer extends Object implements AbstractLookupInitializer
Default implementation ofAbstractLookupInitializer.- Since:
- Author:
- Vaadin Ltd
- See Also:
AbstractLookupInitializer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classLookupInitializer.AppShellPredicateImplDefault implementation ofAppShellPredicate.protected static classLookupInitializer.LookupImplDefault implementation ofLookup.protected static classLookupInitializer.ResourceProviderImplDefault implementation ofResourceProvider.
-
Field Summary
Fields Modifier and Type Field Description protected static StringONE_IMPL_REQUIREDprotected static StringSEVERAL_IMPLSprotected static StringSPI
-
Constructor Summary
Constructors Constructor Description LookupInitializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LookupcreateLookup(VaadinContext context, Map<Class<?>,Collection<Class<?>>> services)Creates a lookup based on providedservices.protected <T> voidensureService(Map<Class<?>,Collection<Class<?>>> services, Class<T> serviceType, Class<? extends T> serviceImpl)Ensures that providedservicescontain implementation forserviceTypeSPI.voidinitialize(VaadinContext context, Map<Class<?>,Collection<Class<?>>> services, VaadinApplicationInitializationBootstrap bootstrap)Creates a newLookupinstance, initializes it and passes it to the providedbootstrap.protected <T> Tinstantiate(Class<T> serviceClass, Class<?> implementation)Instantiates serviceimplementationtype with the givenserviceClass.
-
-
-
Field Detail
-
SPI
protected static final String SPI
- See Also:
- Constant Field Values
-
ONE_IMPL_REQUIRED
protected static final String ONE_IMPL_REQUIRED
- See Also:
- Constant Field Values
-
SEVERAL_IMPLS
protected static final String SEVERAL_IMPLS
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(VaadinContext context, Map<Class<?>,Collection<Class<?>>> services, VaadinApplicationInitializationBootstrap bootstrap) throws javax.servlet.ServletException
Description copied from interface:AbstractLookupInitializerCreates 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.- Specified by:
initializein interfaceAbstractLookupInitializer- 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:
javax.servlet.ServletException- if initialization failed
-
createLookup
protected Lookup createLookup(VaadinContext context, Map<Class<?>,Collection<Class<?>>> services)
Creates a lookup based on providedservices.- Parameters:
context- a Vaadin context to create a lookup forservices- the service objects mapped to the service type to create a lookup- Returns:
- the lookup instance created with provided services
-
ensureService
protected <T> void ensureService(Map<Class<?>,Collection<Class<?>>> services, Class<T> serviceType, Class<? extends T> serviceImpl)
Ensures that providedservicescontain implementation forserviceTypeSPI.The default
serviceImplimplementation will be set as the service intoservicesif there is no other services available.- Parameters:
services- map of internal servicesserviceType- SPI typeserviceImpl- the default SPI implementation
-
instantiate
protected <T> T instantiate(Class<T> serviceClass, Class<?> implementation)
Instantiates serviceimplementationtype with the givenserviceClass.- Type Parameters:
T- service type- Parameters:
serviceClass- service classimplementation- service implementation class- Returns:
- an instantiated service implementation object
-
-