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);
}
}
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);
}
}
Aggregations