Skip to content

Commit

Permalink
fix: get all executor beans instead of one bean via getBean (#701)
Browse files Browse the repository at this point in the history
fixes #697
# Conflicts:
#	vaadin-spring/src/main/java/com/vaadin/flow/spring/VaadinServletContextInitializer.java
#	vaadin-spring/src/test/java/com/vaadin/flow/spring/VaadinServletContextInitializerTest.java
  • Loading branch information
Denis committed Dec 9, 2020
1 parent 0382ac4 commit 4bc879c
Showing 1 changed file with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.util.stream.Stream;

import com.googlecode.gentyref.GenericTypeReflector;
import com.vaadin.flow.server.startup.ServletDeployer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
Expand Down Expand Up @@ -81,6 +80,7 @@
import com.vaadin.flow.server.startup.ApplicationRouteRegistry;
import com.vaadin.flow.server.startup.ClassLoaderAwareServletContainerInitializer;
import com.vaadin.flow.server.startup.DevModeInitializer;
import com.vaadin.flow.server.startup.ServletDeployer;
import com.vaadin.flow.server.startup.ServletVerifier;
import com.vaadin.flow.server.startup.WebComponentConfigurationRegistryInitializer;
import com.vaadin.flow.server.startup.WebComponentExporterAwareValidator;
Expand Down Expand Up @@ -117,7 +117,7 @@ public class VaadinServletContextInitializer
"org/aspectj", "org/bouncycastle", "org/dom4j", "org/easymock",
"org/eclipse/persistence", "org/hamcrest", "org/hibernate",
"org/javassist", "org/jboss", "org/jsoup", "org/seleniumhq",
"org/slf4j", "org/atmosphere", "org/springframework",
"org/slf4j", "org/atmosphere", "org/springframework",
"org/webjars/bowergithub", "org/yaml",

"java/", "javax/", "javafx/", "com/sun/", "oracle/deploy",
Expand All @@ -127,9 +127,9 @@ public class VaadinServletContextInitializer

"com/intellij/", "org/jetbrains").collect(Collectors.toList());

/**
* Packages that should be scanned by default and can't be overriden by
* a custom list.
/**
* Packages that should be scanned by default and can't be overriden by a
* custom list.
*/
private static final List<String> DEFAULT_SCAN_ONLY = Stream
.of(Component.class.getPackage().getName(),
Expand Down Expand Up @@ -345,8 +345,12 @@ public void contextInitialized(ServletContextEvent event) {
|| !config.enableDevServer()) {
return;
}
config.getInitParameters().put(Executor.class,
appContext.getBean(TaskExecutor.class));
Map<String, TaskExecutor> executors = appContext
.getBeansOfType(TaskExecutor.class);
if (!executors.isEmpty()) {
config.getInitParameters().put(Executor.class,
executors.values().iterator().next());
}

Set<String> basePackages;
if (isScanOnlySet()) {
Expand Down Expand Up @@ -377,8 +381,10 @@ public void contextInitialized(ServletContextEvent event) {
throw new RuntimeException(
"Unable to initialize Vaadin DevModeHandler", e);
}
// to make sure the user knows the application is ready, show notification to the user
ServletDeployer.logAppStartupToConsole(event.getServletContext(), true);
// to make sure the user knows the application is ready, show
// notification to the user
ServletDeployer.logAppStartupToConsole(event.getServletContext(),
true);
}

@Override
Expand Down Expand Up @@ -412,8 +418,7 @@ private void collectDevModeTypes(
}

private boolean isScanOnlySet() {
return customScanOnly != null
&& !customScanOnly.isEmpty();
return customScanOnly != null && !customScanOnly.isEmpty();
}
}

Expand Down Expand Up @@ -632,10 +637,9 @@ private static class CustomResourceLoader

private final PrefixTree scanNever = new PrefixTree(DEFAULT_SCAN_NEVER);

private final PrefixTree scanAlways = new PrefixTree(
DEFAULT_SCAN_ONLY.stream()
.map(packageName -> packageName.replace('.', '/'))
.collect(Collectors.toList()));
private final PrefixTree scanAlways = new PrefixTree(DEFAULT_SCAN_ONLY
.stream().map(packageName -> packageName.replace('.', '/'))
.collect(Collectors.toList()));

public CustomResourceLoader(ResourceLoader resourceLoader,
List<String> addedScanNever) {
Expand Down Expand Up @@ -712,8 +716,7 @@ private Resource[] collectResources(String locationPattern)
}

private boolean shouldPathBeScanned(String path) {
return scanAlways.hasPrefix(path)
|| !scanNever.hasPrefix(path);
return scanAlways.hasPrefix(path) || !scanNever.hasPrefix(path);
}
}

Expand Down

0 comments on commit 4bc879c

Please sign in to comment.