Search in sources :

Example 1 with CustomElementRegistry

use of com.vaadin.flow.server.startup.CustomElementRegistry in project flow by vaadin.

the class VaadinServletContextInitializer method onStartup.

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    // Verify servlet version also for SpringBoot.
    ServletVerifier.verifyServletVersion();
    RouteRegistry registry = RouteRegistry.getInstance(servletContext);
    // has done its job already, skip the custom routes search
    if (!registry.navigationTargetsInitialized()) {
        /*
             * Don't rely on RouteRegistry.isInitialized() negative return value
             * here because it's not known whether RouteRegistryInitializer has
             * been executed already or not (the order is undefined). Postpone
             * this to the end of context initialization cycle. At this point
             * RouteRegistry is either initialized or it's not initialized
             * because an RouteRegistryInitializer has not been executed (end
             * never will).
             */
        servletContext.addListener(new RouteServletContextListener());
    }
    if (!registry.errorNavigationTargetsInitialized()) {
        // Same thing: don't rely on hasNavigationTargets() negative return
        // value
        servletContext.addListener(new ErrorParameterServletContextListener());
    }
    CustomElementRegistry elementRegistry = CustomElementRegistry.getInstance();
    if (!elementRegistry.isInitialized()) {
        // Same thing: don't rely on isInitialized() negative return value
        servletContext.addListener(new CustomElementServletContextListener());
    }
    servletContext.addListener(new AnnotationValidatorServletContextListener());
}
Also used : RouteRegistry(com.vaadin.flow.server.startup.RouteRegistry) CustomElementRegistry(com.vaadin.flow.server.startup.CustomElementRegistry)

Example 2 with CustomElementRegistry

use of com.vaadin.flow.server.startup.CustomElementRegistry in project flow by vaadin.

the class CustomElementMappingView method addKeyIfRegistered.

private void addKeyIfRegistered(Class<? extends PolymerTemplate<?>> clazz) {
    String tagName = clazz.getAnnotation(Tag.class).value();
    CustomElementRegistry registry = CustomElementRegistry.getInstance();
    if (registry.isRegisteredCustomElement(tagName) && registry.getRegisteredCustomElement(tagName).equals(clazz)) {
        addKey(tagName);
    }
}
Also used : CustomElementRegistry(com.vaadin.flow.server.startup.CustomElementRegistry) Tag(com.vaadin.flow.component.Tag)

Aggregations

CustomElementRegistry (com.vaadin.flow.server.startup.CustomElementRegistry)2 Tag (com.vaadin.flow.component.Tag)1 RouteRegistry (com.vaadin.flow.server.startup.RouteRegistry)1