Browse Source

Polishing

pull/1946/head
Juergen Hoeller 6 years ago
parent
commit
0e3f23eeb7
  1. 2
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
  2. 18
      spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java
  3. 14
      spring-beans/src/main/java/org/springframework/beans/factory/support/InstantiationStrategy.java
  4. 9
      spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java
  5. 6
      spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java
  6. 8
      spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java
  7. 2
      spring-core/src/main/java/org/springframework/util/xml/StaxStreamXMLReader.java
  8. 30
      spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java

2
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

@ -252,7 +252,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean @@ -252,7 +252,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
}
catch (NoSuchBeanDefinitionException ex) {
throw new BeanCreationException(beanName,
"Cannot apply @Lookup to beans without corresponding bean definition");
"Cannot apply @Lookup to beans without corresponding bean definition");
}
}
});

18
spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java

@ -107,8 +107,8 @@ class ConstructorResolver { @@ -107,8 +107,8 @@ class ConstructorResolver {
* or {@code null} if none (-> use constructor argument values from bean definition)
* @return a BeanWrapper for the new instance
*/
public BeanWrapper autowireConstructor(final String beanName, final RootBeanDefinition mbd,
@Nullable Constructor<?>[] chosenCtors, @Nullable final Object[] explicitArgs) {
public BeanWrapper autowireConstructor(String beanName, RootBeanDefinition mbd,
@Nullable Constructor<?>[] chosenCtors, @Nullable Object[] explicitArgs) {
BeanWrapperImpl bw = new BeanWrapperImpl();
this.beanFactory.initBeanWrapper(bw);
@ -326,7 +326,7 @@ class ConstructorResolver { @@ -326,7 +326,7 @@ class ConstructorResolver {
* the {@link RootBeanDefinition#isNonPublicAccessAllowed()} flag.
* Called as the starting point for factory method determination.
*/
private Method[] getCandidateMethods(final Class<?> factoryClass, final RootBeanDefinition mbd) {
private Method[] getCandidateMethods(Class<?> factoryClass, RootBeanDefinition mbd) {
if (System.getSecurityManager() != null) {
return AccessController.doPrivileged((PrivilegedAction<Method[]>) () ->
(mbd.isNonPublicAccessAllowed() ?
@ -354,7 +354,7 @@ class ConstructorResolver { @@ -354,7 +354,7 @@ class ConstructorResolver {
* @return a BeanWrapper for the new instance
*/
public BeanWrapper instantiateUsingFactoryMethod(
final String beanName, final RootBeanDefinition mbd, @Nullable final Object[] explicitArgs) {
String beanName, RootBeanDefinition mbd, @Nullable Object[] explicitArgs) {
BeanWrapperImpl bw = new BeanWrapperImpl();
this.beanFactory.initBeanWrapper(bw);
@ -417,13 +417,13 @@ class ConstructorResolver { @@ -417,13 +417,13 @@ class ConstructorResolver {
factoryClass = ClassUtils.getUserClass(factoryClass);
Method[] rawCandidates = getCandidateMethods(factoryClass, mbd);
List<Method> candidateSet = new ArrayList<>();
List<Method> candidateList = new ArrayList<>();
for (Method candidate : rawCandidates) {
if (Modifier.isStatic(candidate.getModifiers()) == isStatic && mbd.isFactoryMethod(candidate)) {
candidateSet.add(candidate);
candidateList.add(candidate);
}
}
Method[] candidates = candidateSet.toArray(new Method[0]);
Method[] candidates = candidateList.toArray(new Method[0]);
AutowireUtils.sortFactoryMethods(candidates);
ConstructorArgumentValues resolvedValues = null;
@ -456,7 +456,7 @@ class ConstructorResolver { @@ -456,7 +456,7 @@ class ConstructorResolver {
if (paramTypes.length >= minNrOfArgs) {
ArgumentsHolder argsHolder;
if (explicitArgs != null){
if (explicitArgs != null) {
// Explicit arguments given -> arguments length must match exactly.
if (paramTypes.length != explicitArgs.length) {
continue;
@ -529,7 +529,7 @@ class ConstructorResolver { @@ -529,7 +529,7 @@ class ConstructorResolver {
argTypes.add(arg != null ? arg.getClass().getSimpleName() : "null");
}
}
else if (resolvedValues != null){
else if (resolvedValues != null) {
Set<ValueHolder> valueHolders = new LinkedHashSet<>(resolvedValues.getArgumentCount());
valueHolders.addAll(resolvedValues.getIndexedArgumentValues().values());
valueHolders.addAll(resolvedValues.getGenericArgumentValues());

14
spring-beans/src/main/java/org/springframework/beans/factory/support/InstantiationStrategy.java

@ -1,5 +1,5 @@ @@ -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.
@ -38,8 +38,8 @@ public interface InstantiationStrategy { @@ -38,8 +38,8 @@ public interface InstantiationStrategy {
/**
* Return an instance of the bean with the given name in this factory.
* @param bd the bean definition
* @param beanName the name of the bean when it's created in this context.
* The name can be {@code null} if we're autowiring a bean which doesn't
* @param beanName the name of the bean when it is created in this context.
* The name can be {@code null} if we are autowiring a bean which doesn't
* belong to the factory.
* @param owner the owning BeanFactory
* @return a bean instance for this bean definition
@ -52,8 +52,8 @@ public interface InstantiationStrategy { @@ -52,8 +52,8 @@ public interface InstantiationStrategy {
* Return an instance of the bean with the given name in this factory,
* creating it via the given constructor.
* @param bd the bean definition
* @param beanName the name of the bean when it's created in this context.
* The name can be {@code null} if we're autowiring a bean which doesn't
* @param beanName the name of the bean when it is created in this context.
* The name can be {@code null} if we are autowiring a bean which doesn't
* belong to the factory.
* @param owner the owning BeanFactory
* @param ctor the constructor to use
@ -68,8 +68,8 @@ public interface InstantiationStrategy { @@ -68,8 +68,8 @@ public interface InstantiationStrategy {
* Return an instance of the bean with the given name in this factory,
* creating it via the given factory method.
* @param bd the bean definition
* @param beanName the name of the bean when it's created in this context.
* The name can be {@code null} if we're autowiring a bean which doesn't
* @param beanName the name of the bean when it is created in this context.
* The name can be {@code null} if we are autowiring a bean which doesn't
* belong to the factory.
* @param owner the owning BeanFactory
* @param factoryBean the factory bean instance to call the factory method on,

9
spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java vendored

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.cache.jcache;
import java.util.concurrent.Callable;
import javax.cache.Cache;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
@ -37,14 +38,14 @@ import org.springframework.util.Assert; @@ -37,14 +38,14 @@ import org.springframework.util.Assert;
*/
public class JCacheCache extends AbstractValueAdaptingCache {
private final javax.cache.Cache<Object, Object> cache;
private final Cache<Object, Object> cache;
/**
* Create an {@link org.springframework.cache.jcache.JCacheCache} instance.
* @param jcache backing JCache Cache instance
*/
public JCacheCache(javax.cache.Cache<Object, Object> jcache) {
public JCacheCache(Cache<Object, Object> jcache) {
this(jcache, true);
}
@ -53,7 +54,7 @@ public class JCacheCache extends AbstractValueAdaptingCache { @@ -53,7 +54,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
* @param jcache backing JCache Cache instance
* @param allowNullValues whether to accept and convert null values for this cache
*/
public JCacheCache(javax.cache.Cache<Object, Object> jcache, boolean allowNullValues) {
public JCacheCache(Cache<Object, Object> jcache, boolean allowNullValues) {
super(allowNullValues);
Assert.notNull(jcache, "Cache must not be null");
this.cache = jcache;
@ -66,7 +67,7 @@ public class JCacheCache extends AbstractValueAdaptingCache { @@ -66,7 +67,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
}
@Override
public final javax.cache.Cache<Object, Object> getNativeCache() {
public final Cache<Object, Object> getNativeCache() {
return this.cache;
}

6
spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java vendored

@ -39,7 +39,7 @@ import org.springframework.util.Assert; @@ -39,7 +39,7 @@ import org.springframework.util.Assert;
public class JCacheCacheManager extends AbstractTransactionSupportingCacheManager {
@Nullable
private javax.cache.CacheManager cacheManager;
private CacheManager cacheManager;
private boolean allowNullValues = true;
@ -63,7 +63,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage @@ -63,7 +63,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage
/**
* Set the backing JCache {@link javax.cache.CacheManager}.
*/
public void setCacheManager(@Nullable javax.cache.CacheManager cacheManager) {
public void setCacheManager(@Nullable CacheManager cacheManager) {
this.cacheManager = cacheManager;
}
@ -71,7 +71,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage @@ -71,7 +71,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage
* Return the backing JCache {@link javax.cache.CacheManager}.
*/
@Nullable
public javax.cache.CacheManager getCacheManager() {
public CacheManager getCacheManager() {
return this.cacheManager;
}

8
spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java vendored

@ -1,5 +1,5 @@ @@ -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.
@ -62,7 +62,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -62,7 +62,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
}
@Nullable
protected Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) {
private Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) {
Collection<CacheOperation> ops = parseCacheAnnotations(cachingConfig, ae, false);
if (ops != null && ops.size() > 1 && ae.getAnnotations().length > 0) {
// More than one operation found -> local declarations override interface-declared ones...
@ -88,6 +88,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -88,6 +88,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parseCacheableAnnotation(ae, cachingConfig, cacheable));
}
}
Collection<CacheEvict> evicts = (localOnly ? AnnotatedElementUtils.getAllMergedAnnotations(ae, CacheEvict.class) :
AnnotatedElementUtils.findAllMergedAnnotations(ae, CacheEvict.class));
if (!evicts.isEmpty()) {
@ -96,6 +97,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -96,6 +97,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parseEvictAnnotation(ae, cachingConfig, evict));
}
}
Collection<CachePut> puts = (localOnly ? AnnotatedElementUtils.getAllMergedAnnotations(ae, CachePut.class) :
AnnotatedElementUtils.findAllMergedAnnotations(ae, CachePut.class));
if (!puts.isEmpty()) {
@ -104,6 +106,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -104,6 +106,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parsePutAnnotation(ae, cachingConfig, put));
}
}
Collection<Caching> cachings = (localOnly ? AnnotatedElementUtils.getAllMergedAnnotations(ae, Caching.class) :
AnnotatedElementUtils.findAllMergedAnnotations(ae, Caching.class));
if (!cachings.isEmpty()) {
@ -313,7 +316,6 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -313,7 +316,6 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
builder.setCacheManager(this.cacheManager);
}
}
}
}

2
spring-core/src/main/java/org/springframework/util/xml/StaxStreamXMLReader.java

@ -243,7 +243,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader { @@ -243,7 +243,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
private void handleDtd() throws SAXException {
if (getLexicalHandler() != null) {
javax.xml.stream.Location location = this.reader.getLocation();
Location location = this.reader.getLocation();
getLexicalHandler().startDTD(null, location.getPublicId(), location.getSystemId());
}
if (getLexicalHandler() != null) {

30
spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java

@ -47,17 +47,19 @@ import org.springframework.util.MimeTypeUtils; @@ -47,17 +47,19 @@ import org.springframework.util.MimeTypeUtils;
import org.springframework.util.xml.StaxUtils;
/**
* Decodes a {@link DataBuffer} stream into a stream of {@link XMLEvent}s.
* That is, given the following XML:
* Decodes a {@link DataBuffer} stream into a stream of {@link XMLEvent XMLEvents}.
*
* <pre>{@code
* <root>
* <child>foo</child>
* <child>bar</child>
* </root>}
* <p>Given the following XML:
*
* <pre class="code">
* &lt;root>
* &lt;child&gt;foo&lt;/child&gt;
* &lt;child&gt;bar&lt;/child&gt;
* &lt;/root&gt;
* </pre>
*
* this method with result in a flux with the following events:
* this decoder will produce a {@link Flux} with the following events:
*
* <ol>
* <li>{@link javax.xml.stream.events.StartDocument}</li>
* <li>{@link javax.xml.stream.events.StartElement} {@code root}</li>
@ -70,8 +72,8 @@ import org.springframework.util.xml.StaxUtils; @@ -70,8 +72,8 @@ import org.springframework.util.xml.StaxUtils;
* <li>{@link javax.xml.stream.events.EndElement} {@code root}</li>
* </ol>
*
* Note that this decoder is not registered by default but used internally
* by other decoders who are there by default.
* <p>Note that this decoder is not registered by default but is used internally
* by other decoders which are registered by default.
*
* @author Arjen Poutsma
* @since 5.0
@ -97,7 +99,7 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> { @@ -97,7 +99,7 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
Flux<DataBuffer> flux = Flux.from(inputStream);
if (useAalto) {
if (this.useAalto) {
AaltoDataBufferToXmlEvent aaltoMapper = new AaltoDataBufferToXmlEvent();
return flux.flatMap(aaltoMapper)
.doFinally(signalType -> aaltoMapper.endOfInput());
@ -135,15 +137,15 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> { @@ -135,15 +137,15 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
@Override
public Publisher<? extends XMLEvent> apply(DataBuffer dataBuffer) {
try {
streamReader.getInputFeeder().feedInput(dataBuffer.asByteBuffer());
this.streamReader.getInputFeeder().feedInput(dataBuffer.asByteBuffer());
List<XMLEvent> events = new ArrayList<>();
while (true) {
if (streamReader.next() == AsyncXMLStreamReader.EVENT_INCOMPLETE) {
if (this.streamReader.next() == AsyncXMLStreamReader.EVENT_INCOMPLETE) {
// no more events with what currently has been fed to the reader
break;
}
else {
XMLEvent event = eventAllocator.allocate(streamReader);
XMLEvent event = this.eventAllocator.allocate(this.streamReader);
events.add(event);
if (event.isEndDocument()) {
break;

Loading…
Cancel
Save