Polishing

This commit is contained in:
Juergen Hoeller
2018-08-09 00:49:54 +02:00
parent 688ef9ad46
commit f3184a0878
13 changed files with 164 additions and 154 deletions

View File

@@ -131,9 +131,14 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
Collection<CacheOperation> annOps = provider.getCacheOperations(annotationParser);
if (annOps != null) {
if (ops == null) {
ops = new ArrayList<>();
ops = annOps;
}
else {
Collection<CacheOperation> combined = new ArrayList<>(ops.size() + annOps.size());
combined.addAll(ops);
combined.addAll(annOps);
ops = combined;
}
ops.addAll(annOps);
}
}
return ops;

View File

@@ -155,7 +155,7 @@ public class AnnotationConfigUtils {
}
}
Set<BeanDefinitionHolder> beanDefs = new LinkedHashSet<>(4);
Set<BeanDefinitionHolder> beanDefs = new LinkedHashSet<>(8);
if (!registry.containsBeanDefinition(CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME)) {
RootBeanDefinition def = new RootBeanDefinition(ConfigurationClassPostProcessor.class);
@@ -202,6 +202,7 @@ public class AnnotationConfigUtils {
def.setSource(source);
beanDefs.add(registerPostProcessor(registry, def, EVENT_LISTENER_PROCESSOR_BEAN_NAME));
}
if (!registry.containsBeanDefinition(EVENT_LISTENER_FACTORY_BEAN_NAME)) {
RootBeanDefinition def = new RootBeanDefinition(DefaultEventListenerFactory.class);
def.setSource(source);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import org.springframework.core.Ordered;
/**
* Default {@link EventListenerFactory} implementation that supports the
* regular {@link EventListener} annotation.
*
* <p>Used as "catch-all" implementation by default.
*
* @author Stephane Nicoll
@@ -33,15 +34,17 @@ public class DefaultEventListenerFactory implements EventListenerFactory, Ordere
private int order = LOWEST_PRECEDENCE;
@Override
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
public boolean supportsMethod(Method method) {
return true;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,8 +45,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
/**
* Register {@link EventListener} annotated method as individual {@link ApplicationListener}
* instances.
* Registers {@link EventListener} methods as individual {@link ApplicationListener} instances.
*
* @author Stephane Nicoll
* @author Juergen Hoeller