Search in sources :

Example 1 with LookupInitializer

use of com.vaadin.flow.di.LookupInitializer in project flow by vaadin.

the class LookupServletContainerInitializer method getLookupInitializer.

private AbstractLookupInitializer getLookupInitializer(Map<Class<?>, Collection<Class<?>>> services) throws ServletException {
    Collection<Class<?>> initializers = services.remove(AbstractLookupInitializer.class);
    if (initializers == null) {
        initializers = Collections.emptyList();
    } else {
        initializers.remove(LookupInitializer.class);
    }
    AbstractLookupInitializer initializer;
    if (initializers.isEmpty()) {
        initializer = new LookupInitializer();
    } else if (initializers.size() > 1) {
        throw new ServletException("Several implementation of " + AbstractLookupInitializer.class.getSimpleName() + " are found in the claspath: " + initializers);
    } else {
        initializer = AbstractLookupInitializer.class.cast(ReflectTools.createInstance(initializers.iterator().next()));
    }
    return initializer;
}
Also used : ServletException(javax.servlet.ServletException) AbstractLookupInitializer(com.vaadin.flow.di.AbstractLookupInitializer) AbstractLookupInitializer(com.vaadin.flow.di.AbstractLookupInitializer) LookupInitializer(com.vaadin.flow.di.LookupInitializer)

Aggregations

AbstractLookupInitializer (com.vaadin.flow.di.AbstractLookupInitializer)1 LookupInitializer (com.vaadin.flow.di.LookupInitializer)1 ServletException (javax.servlet.ServletException)1