Interface AbstractLookupInitializer

  • All Known Implementing Classes:
    LookupInitializer

    public interface AbstractLookupInitializer
    SPI for customizing lookup in applications inside Servlet 3.0 containers.

    There are two ways of customizing Lookup in various servlet containers:

    The first case allows to customize 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 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:

    • 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).
    Since:
    Author:
    Vaadin Ltd
    • Method Detail

      • initialize

        void initialize​(VaadinContext context,
                        Map<Class<?>,​Collection<Class<?>>> services,
                        VaadinApplicationInitializationBootstrap bootstrap)
                 throws javax.servlet.ServletException
        Creates a new 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.

        Parameters:
        context - a Vaadin context to run initialization for
        services - the map of internal services with their implementations found in the application classpath
        bootstrap - the web application bootstrap
        Throws:
        javax.servlet.ServletException - if initialization failed