Skip to content

Commit c752ba5

Browse files
committed
Polishing
1 parent 12978b8 commit c752ba5

File tree

28 files changed

+226
-231
lines changed

28 files changed

+226
-231
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import org.springframework.aop.PointcutAdvisor;
2323
import org.springframework.core.Ordered;
2424
import org.springframework.util.Assert;
25-
import org.springframework.util.ObjectUtils;
2625

2726
/**
2827
* AspectJPointcutAdvisor that adapts an {@link AbstractAspectJAdvice}
@@ -51,11 +50,11 @@ public AspectJPointcutAdvisor(AbstractAspectJAdvice advice) {
5150
this.pointcut = advice.buildSafePointcut();
5251
}
5352

53+
5454
public void setOrder(int order) {
5555
this.order = order;
5656
}
5757

58-
5958
@Override
6059
public boolean isPerInstance() {
6160
return true;
@@ -91,12 +90,12 @@ public boolean equals(Object other) {
9190
return false;
9291
}
9392
AspectJPointcutAdvisor otherAdvisor = (AspectJPointcutAdvisor) other;
94-
return (ObjectUtils.nullSafeEquals(this.advice, otherAdvisor.advice));
93+
return this.advice.equals(otherAdvisor.advice);
9594
}
9695

9796
@Override
9897
public int hashCode() {
99-
return AspectJPointcutAdvisor.class.hashCode();
98+
return AspectJPointcutAdvisor.class.hashCode() * 29 + this.advice.hashCode();
10099
}
101100

102101
}

spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
2121
import org.springframework.beans.factory.BeanFactoryAware;
2222
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
2323
import org.springframework.core.Ordered;
24+
import org.springframework.util.Assert;
2425
import org.springframework.util.ClassUtils;
25-
import org.springframework.util.StringUtils;
2626

2727
/**
2828
* Implementation of {@link AspectInstanceFactory} that locates the aspect from the
@@ -50,9 +50,7 @@ public void setAspectBeanName(String aspectBeanName) {
5050
@Override
5151
public void setBeanFactory(BeanFactory beanFactory) {
5252
this.beanFactory = beanFactory;
53-
if (!StringUtils.hasText(this.aspectBeanName)) {
54-
throw new IllegalArgumentException("'aspectBeanName' is required");
55-
}
53+
Assert.notNull(this.aspectBeanName, "'aspectBeanName' is required");
5654
}
5755

5856

spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -89,7 +89,7 @@ public static BeanDefinitionHolder createScopedProxy(BeanDefinitionHolder defini
8989
}
9090

9191
/**
92-
* Generates the bean name that is used within the scoped proxy to reference the target bean.
92+
* Generate the bean name that is used within the scoped proxy to reference the target bean.
9393
* @param originalBeanName the original name of bean
9494
* @return the generated bean to be used to reference the target bean
9595
*/

spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,8 +76,7 @@ private void findInnerBeanDefinitionsAndBeanReferences(BeanDefinition beanDefini
7676
List<BeanDefinition> innerBeans = new ArrayList<BeanDefinition>();
7777
List<BeanReference> references = new ArrayList<BeanReference>();
7878
PropertyValues propertyValues = beanDefinition.getPropertyValues();
79-
for (int i = 0; i < propertyValues.getPropertyValues().length; i++) {
80-
PropertyValue propertyValue = propertyValues.getPropertyValues()[i];
79+
for (PropertyValue propertyValue : propertyValues.getPropertyValues()) {
8180
Object value = propertyValue.getValue();
8281
if (value instanceof BeanDefinitionHolder) {
8382
innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition());

spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,15 +54,15 @@ public void setCacheManager(CacheManager cacheManager) {
5454
}
5555

5656
/**
57-
* Return the {@link CacheManager} that this instance use.
57+
* Return the {@link CacheManager} that this instance uses.
5858
*/
5959
public CacheManager getCacheManager() {
6060
return this.cacheManager;
6161
}
6262

6363
@Override
6464
public void afterPropertiesSet() {
65-
Assert.notNull(this.cacheManager, "CacheManager must not be null");
65+
Assert.notNull(this.cacheManager, "CacheManager is required");
6666
}
6767

6868

@@ -75,7 +75,7 @@ public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext
7575
else {
7676
Collection<Cache> result = new ArrayList<Cache>();
7777
for (String cacheName : cacheNames) {
78-
Cache cache = this.cacheManager.getCache(cacheName);
78+
Cache cache = getCacheManager().getCache(cacheName);
7979
if (cache == null) {
8080
throw new IllegalArgumentException("Cannot find cache named '" +
8181
cacheName + "' for " + context.getOperation());
@@ -91,7 +91,7 @@ public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext
9191
* <p>It is acceptable to return {@code null} to indicate that no cache could
9292
* be resolved for this invocation.
9393
* @param context the context of the particular invocation
94-
* @return the cache name(s) to resolve or {@code null} if no cache should be resolved
94+
* @return the cache name(s) to resolve, or {@code null} if no cache should be resolved
9595
*/
9696
protected abstract Collection<String> getCacheNames(CacheOperationInvocationContext<?> context);
9797

spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.cache.interceptor;
1818

19-
2019
import java.util.ArrayList;
2120
import java.util.Arrays;
2221
import java.util.Collection;
@@ -34,13 +33,15 @@ public class NamedCacheResolver extends AbstractCacheResolver {
3433

3534
private Collection<String> cacheNames;
3635

36+
37+
public NamedCacheResolver() {
38+
}
39+
3740
public NamedCacheResolver(CacheManager cacheManager, String... cacheNames) {
3841
super(cacheManager);
3942
this.cacheNames = new ArrayList<String>(Arrays.asList(cacheNames));
4043
}
4144

42-
public NamedCacheResolver() {
43-
}
4445

4546
/**
4647
* Set the cache name(s) that this resolver should use.

spring-context/src/main/java/org/springframework/cache/support/SimpleCacheManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.cache.support;
1818

1919
import java.util.Collection;
20+
import java.util.Collections;
2021

2122
import org.springframework.cache.Cache;
2223

@@ -29,7 +30,7 @@
2930
*/
3031
public class SimpleCacheManager extends AbstractCacheManager {
3132

32-
private Collection<? extends Cache> caches;
33+
private Collection<? extends Cache> caches = Collections.emptySet();
3334

3435

3536
/**

spring-context/src/main/java/org/springframework/jndi/TypeMismatchNamingException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,7 +51,9 @@ public TypeMismatchNamingException(String jndiName, Class<?> requiredType, Class
5151
/**
5252
* Construct a new TypeMismatchNamingException.
5353
* @param explanation the explanation text
54+
* @deprecated as of Spring Framework 4.3.10
5455
*/
56+
@Deprecated
5557
public TypeMismatchNamingException(String explanation) {
5658
super(explanation);
5759
}

spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,8 +49,8 @@ public class ScopedProxyTests {
4949
private static final ClassPathResource OVERRIDE_CONTEXT = new ClassPathResource(CLASSNAME + "-override.xml", CLASS);
5050
private static final ClassPathResource TESTBEAN_CONTEXT = new ClassPathResource(CLASSNAME + "-testbean.xml", CLASS);
5151

52-
/* SPR-2108 */
53-
@Test
52+
53+
@Test // SPR-2108
5454
public void testProxyAssignable() throws Exception {
5555
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
5656
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);

spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
77

88
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean" scope="request">
9-
<aop:scoped-proxy proxy-target-class="false"/>
10-
<property name="age" value="99"/>
11-
</bean>
9+
<aop:scoped-proxy proxy-target-class="false"/>
10+
<property name="age" value="99"/>
11+
</bean>
1212

13-
<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
14-
<property name="properties">
15-
<map>
16-
<entry key="testBean.sex" value="male"/>
17-
</map>
18-
</property>
19-
</bean>
13+
<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
14+
<property name="properties">
15+
<map>
16+
<entry key="testBean.sex" value="male"/>
17+
</map>
18+
</property>
19+
</bean>
2020

2121
</beans>

0 commit comments

Comments
 (0)