提交 130f4102 编写于 作者: J Juergen Hoeller

Polishing

上级 5c20c976
......@@ -697,7 +697,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
ReflectionUtils.makeAccessible(method);
method.invoke(bean, arguments);
}
catch (InvocationTargetException ex){
catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
}
......
/*
* Copyright 2002-2009 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.
......@@ -55,7 +55,7 @@ public class BeanExpressionContext {
if (this.beanFactory.containsBean(key)) {
return this.beanFactory.getBean(key);
}
else if (this.scope != null){
else if (this.scope != null) {
return this.scope.resolveContextualObject(key);
}
else {
......
/*
* Copyright 2002-2012 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.
......@@ -115,7 +115,7 @@ public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigu
*/
protected String resolvePlaceholder(String path, String key, Preferences preferences) {
if (path != null) {
// Do not create the node if it does not exist...
// Do not create the node if it does not exist...
try {
if (preferences.nodeExists(path)) {
return preferences.node(path).get(key, null);
......
/*
* Copyright 2002-2013 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.
......@@ -64,6 +64,9 @@ import org.springframework.beans.factory.BeanInitializationException;
*/
public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
/**
* The default bean name separator.
*/
public static final String DEFAULT_BEAN_NAME_SEPARATOR = ".";
......@@ -72,7 +75,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
private boolean ignoreInvalidKeys = false;
/**
* Contains names of beans that have overrides
* Contains names of beans that have overrides.
*/
private final Set<String> beanNames = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16));
......@@ -129,7 +132,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
"': expected 'beanName" + this.beanNameSeparator + "property'");
}
String beanName = key.substring(0, separatorIndex);
String beanProperty = key.substring(separatorIndex+1);
String beanProperty = key.substring(separatorIndex + 1);
this.beanNames.add(beanName);
applyPropertyValue(factory, beanName, beanProperty, value);
if (logger.isDebugEnabled()) {
......@@ -144,12 +147,14 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
BeanDefinition bd = factory.getBeanDefinition(beanName);
while (bd.getOriginatingBeanDefinition() != null) {
BeanDefinition bdToUse = bd;
while (bd != null) {
bdToUse = bd;
bd = bd.getOriginatingBeanDefinition();
}
PropertyValue pv = new PropertyValue(property, value);
pv.setOptional(this.ignoreInvalidKeys);
bd.getPropertyValues().addPropertyValue(pv);
bdToUse.getPropertyValues().addPropertyValue(pv);
}
......@@ -157,8 +162,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
* Were there overrides for this bean?
* Only valid after processing has occurred at least once.
* @param beanName name of the bean to query status for
* @return whether there were property overrides for
* the named bean
* @return whether there were property overrides for the named bean
*/
public boolean hasPropertyOverridesFor(String beanName) {
return this.beanNames.contains(beanName);
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
......@@ -955,7 +955,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
return null;
}
Object instance = null;
Object instance;
try {
// Mark this bean as currently in creation, even if just partially.
beforePrototypeCreation(beanName);
......@@ -1068,7 +1068,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
"Bean class isn't public, and non-public access not allowed: " + beanClass.getName());
}
if (mbd.getFactoryMethodName() != null) {
if (mbd.getFactoryMethodName() != null) {
return instantiateUsingFactoryMethod(beanName, mbd, args);
}
......@@ -1092,11 +1092,10 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
}
// Need to determine the constructor...
// Candidate constructors for autowiring?
Constructor<?>[] ctors = determineConstructorsFromBeanPostProcessors(beanClass, beanName);
if (ctors != null ||
mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR ||
mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) {
if (ctors != null || mbd.getResolvedAutowireMode() == AUTOWIRE_CONSTRUCTOR ||
mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) {
return autowireConstructor(beanName, mbd, ctors, args);
}
......
......@@ -574,7 +574,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
*/
@Override
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException{
throws NoSuchBeanDefinitionException {
A ann = null;
Class<?> beanType = getType(beanName);
......
/*
* Copyright 2002-2013 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.
......@@ -88,7 +88,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
public static final String SEPARATOR = ".";
/**
* Special key to distinguish {@code owner.(class)=com.myapp.MyClass}-
* Special key to distinguish {@code owner.(class)=com.myapp.MyClass}.
*/
public static final String CLASS_KEY = "(class)";
......@@ -300,10 +300,10 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
/**
* Register bean definitions contained in a Map,
* using all property keys (i.e. not filtering by prefix).
* @param map Map: name -> property (String or Object). Property values
* will be strings if coming from a Properties file etc. Property names
* Register bean definitions contained in a Map, using all property keys (i.e. not
* filtering by prefix).
* @param map a map of {@code name} to {@code property} (String or Object). Property
* values will be strings if coming from a Properties file etc. Property names
* (keys) <b>must</b> be Strings. Class keys must be Strings.
* @return the number of bean definitions found
* @throws BeansException in case of loading or parsing errors
......@@ -316,8 +316,8 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
/**
* Register bean definitions contained in a Map.
* Ignore ineligible properties.
* @param map Map name -> property (String or Object). Property values
* will be strings if coming from a Properties file etc. Property names
* @param map a map of {@code name} to {@code property} (String or Object). Property
* values will be strings if coming from a Properties file etc. Property names
* (keys) <b>must</b> be Strings. Class keys must be Strings.
* @param prefix a filter within the keys in the map: e.g. 'beans.'
* (can be empty or {@code null})
......@@ -331,9 +331,9 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
/**
* Register bean definitions contained in a Map.
* Ignore ineligible properties.
* @param map Map name -> property (String or Object). Property values
* will be strings if coming from a Properties file etc. Property names
* (keys) <b>must</b> be strings. Class keys must be Strings.
* @param map a map of {@code name} to {@code property} (String or Object). Property
* values will be strings if coming from a Properties file etc. Property names
* (keys) <b>must</b> be Strings. Class keys must be Strings.
* @param prefix a filter within the keys in the map: e.g. 'beans.'
* (can be empty or {@code null})
* @param resourceDescription description of the resource that the
......@@ -393,9 +393,9 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
/**
* Get all property values, given a prefix (which will be stripped)
* and add the bean they define to the factory with the given name
* and add the bean they define to the factory with the given name.
* @param beanName name of the bean to define
* @param map Map containing string pairs
* @param map a Map containing string pairs
* @param prefix prefix of each entry, which will be stripped
* @param resourceDescription description of the resource that the
* Map came from (for logging purposes)
......@@ -502,7 +502,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
* Reads the value of the entry. Correctly interprets bean references for
* values that are prefixed with an asterisk.
*/
private Object readValue(Map.Entry<? ,?> entry) {
private Object readValue(Map.Entry<?, ?> entry) {
Object val = entry.getValue();
if (val instanceof String) {
String strVal = (String) val;
......
......@@ -351,7 +351,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
@Override
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException{
throws NoSuchBeanDefinitionException {
Class<?> beanType = getType(beanName);
return (beanType != null ? AnnotationUtils.findAnnotation(beanType, annotationType) : null);
......
......@@ -43,12 +43,12 @@ import org.springframework.util.CollectionUtils;
*
* <p>The format of {@code META-INF/spring.schemas} is a properties file where each line
* should be of the form {@code systemId=schema-location} where {@code schema-location}
* should also be a schema file in the classpath. Since systemId is commonly a URL,
* one must be careful to escape any ':' characters which are treated as delimiters
* should also be a schema file in the classpath. Since {@code systemId} is commonly a
* URL, one must be careful to escape any ':' characters which are treated as delimiters
* in properties files.
*
* <p>The pattern for the mapping files can be overidden using the
* {@link #PluggableSchemaResolver(ClassLoader, String)} constructor
* <p>The pattern for the mapping files can be overridden using the
* {@link #PluggableSchemaResolver(ClassLoader, String)} constructor.
*
* @author Rob Harrop
* @author Juergen Hoeller
......
/*
* Copyright 2002-2014 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.
......@@ -116,7 +116,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
"Constructor argument '" + argName + "' specifies a negative index", attr);
}
if (cvs.hasIndexedArgumentValue(index)){
if (cvs.hasIndexedArgumentValue(index)) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
" Only one approach may be used per argument.", attr);
......@@ -128,7 +128,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
// no escaping -> ctr name
else {
String name = Conventions.attributeNameToPropertyName(argName);
if (containsArgWithName(name, cvs)){
if (containsArgWithName(name, cvs)) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
" Only one approach may be used per argument.", attr);
......
/*
* Copyright 2002-2012 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.
......@@ -26,7 +26,7 @@ package org.springframework.core;
public interface AttributeAccessor {
/**
* Set the attribute defined by {@code name} to the supplied {@code value}.
* Set the attribute defined by {@code name} to the supplied {@code value}.
* If {@code value} is {@code null}, the attribute is {@link #removeAttribute removed}.
* <p>In general, users should take care to prevent overlaps with other
* metadata attributes by using fully-qualified names, perhaps using
......
......@@ -709,10 +709,12 @@ public abstract class ClassUtils {
* @param interfaces the interfaces to merge
* @param classLoader the ClassLoader to create the composite Class in
* @return the merged interface as Class
* @throws IllegalArgumentException if the specified interfaces expose
* conflicting method signatures (or a similar constraint is violated)
* @see java.lang.reflect.Proxy#getProxyClass
*/
public static Class<?> createCompositeInterface(Class<?>[] interfaces, ClassLoader classLoader) {
Assert.notEmpty(interfaces, "Interfaces must not be empty");
Assert.notEmpty(interfaces, "Interface array must not be empty");
return Proxy.getProxyClass(classLoader, interfaces);
}
......
/*
* 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.
......@@ -38,7 +38,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
*/
public void updateMessageDigest(MessageDigest messageDigest) throws IOException {
int data;
while ((data = read()) != -1){
while ((data = read()) != -1) {
messageDigest.update((byte) data);
}
}
......@@ -54,7 +54,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
public void updateMessageDigest(MessageDigest messageDigest, int len) throws IOException {
int data;
int bytesRead = 0;
while (bytesRead < len && (data = read()) != -1){
while (bytesRead < len && (data = read()) != -1) {
messageDigest.update((byte) data);
bytesRead++;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册