Search in sources :

Example 1 with WebComponentExporterFactory

use of com.vaadin.flow.component.WebComponentExporterFactory in project flow by vaadin.

the class WebComponentExporterUtilsTest method getFactories_notEligibleExportersAreFiltered_factoriesAreReturned.

@Test
public void getFactories_notEligibleExportersAreFiltered_factoriesAreReturned() {
    Set<WebComponentExporterFactory> factories = WebComponentExporterUtils.getFactories(new HashSet<>(Arrays.asList(GoodExporter.class, AbstractExporter.class, PackageLocalExporter.class, NoPublicCtorExporter.class, ExporterFactory.class)));
    Assert.assertEquals(2, factories.size());
    Iterator<WebComponentExporterFactory> iterator = factories.iterator();
    WebComponentExporterFactory factory = iterator.next();
    WebComponentExporterFactory another = iterator.next();
    if (factory instanceof ExporterFactory) {
        assertFactories(factory, another);
    } else {
        assertFactories(another, factory);
    }
}
Also used : WebComponentExporterFactory(com.vaadin.flow.component.WebComponentExporterFactory) DefaultWebComponentExporterFactory(com.vaadin.flow.component.WebComponentExporterFactory.DefaultWebComponentExporterFactory) WebComponentExporterFactory(com.vaadin.flow.component.WebComponentExporterFactory) DefaultWebComponentExporterFactory(com.vaadin.flow.component.WebComponentExporterFactory.DefaultWebComponentExporterFactory) Test(org.junit.Test)

Example 2 with WebComponentExporterFactory

use of com.vaadin.flow.component.WebComponentExporterFactory in project flow by vaadin.

the class WebComponentConfigurationRegistryInitializer method initialize.

@Override
@SuppressWarnings("rawtypes")
public void initialize(Set<Class<?>> classSet, VaadinContext context) throws VaadinInitializerException {
    WebComponentConfigurationRegistry instance = WebComponentConfigurationRegistry.getInstance(context);
    if (classSet == null || classSet.isEmpty()) {
        instance.setConfigurations(Collections.emptySet());
        return;
    }
    try {
        Set<WebComponentExporterFactory> factories = WebComponentExporterUtils.getFactories(classSet);
        Set<WebComponentConfiguration<? extends Component>> configurations = constructConfigurations(factories);
        validateTagNames(configurations);
        validateDistinctTagNames(configurations);
        instance.setConfigurations(configurations);
    } catch (Exception e) {
        throw new VaadinInitializerException(String.format("%s failed to collect %s implementations!", WebComponentConfigurationRegistryInitializer.class.getSimpleName(), WebComponentExporter.class.getSimpleName()), e);
    }
}
Also used : WebComponentConfiguration(com.vaadin.flow.component.webcomponent.WebComponentConfiguration) WebComponentConfigurationRegistry(com.vaadin.flow.server.webcomponent.WebComponentConfigurationRegistry) Component(com.vaadin.flow.component.Component) WebComponentExporter(com.vaadin.flow.component.WebComponentExporter) InvalidCustomElementNameException(com.vaadin.flow.server.InvalidCustomElementNameException) WebComponentExporterFactory(com.vaadin.flow.component.WebComponentExporterFactory)

Aggregations

WebComponentExporterFactory (com.vaadin.flow.component.WebComponentExporterFactory)2 Component (com.vaadin.flow.component.Component)1 WebComponentExporter (com.vaadin.flow.component.WebComponentExporter)1 DefaultWebComponentExporterFactory (com.vaadin.flow.component.WebComponentExporterFactory.DefaultWebComponentExporterFactory)1 WebComponentConfiguration (com.vaadin.flow.component.webcomponent.WebComponentConfiguration)1 InvalidCustomElementNameException (com.vaadin.flow.server.InvalidCustomElementNameException)1 WebComponentConfigurationRegistry (com.vaadin.flow.server.webcomponent.WebComponentConfigurationRegistry)1 Test (org.junit.Test)1