Skip to content

Commit e5ccdfb

Browse files
committed
Polishing
(cherry picked from commit ce4e795)
1 parent adb54b2 commit e5ccdfb

File tree

14 files changed

+106
-91
lines changed

14 files changed

+106
-91
lines changed

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

Lines changed: 2 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-2015 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.
@@ -200,8 +200,7 @@ private PointcutExpression buildPointcutExpression(ClassLoader classLoader) {
200200
pointcutParameters[i] = parser.createPointcutParameter(
201201
this.pointcutParameterNames[i], this.pointcutParameterTypes[i]);
202202
}
203-
return parser.parsePointcutExpression(
204-
replaceBooleanOperators(getExpression()),
203+
return parser.parsePointcutExpression(replaceBooleanOperators(getExpression()),
205204
this.pointcutDeclarationScope, pointcutParameters);
206205
}
207206

spring-context/src/main/java/org/springframework/cache/Cache.java

Lines changed: 2 additions & 2 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-2015 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,7 +17,7 @@
1717
package org.springframework.cache;
1818

1919
/**
20-
* Interface that defines the common cache operations.
20+
* Interface that defines common cache operations.
2121
*
2222
* <b>Note:</b> Due to the generic use of caching, it is recommended that
2323
* implementations allow storage of <tt>null</tt> values (for example to

spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java

Lines changed: 7 additions & 7 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-2015 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.
@@ -151,13 +151,12 @@
151151
* Indicate whether subclass-based (CGLIB) proxies are to be created as opposed
152152
* to standard Java interface-based proxies. The default is {@code false}. <strong>
153153
* Applicable only if {@link #mode()} is set to {@link AdviceMode#PROXY}</strong>.
154-
*
155154
* <p>Note that setting this attribute to {@code true} will affect <em>all</em>
156-
* Spring-managed beans requiring proxying, not just those marked with
157-
* {@code @Cacheable}. For example, other beans marked with Spring's
158-
* {@code @Transactional} annotation will be upgraded to subclass proxying at the same
159-
* time. This approach has no negative impact in practice unless one is explicitly
160-
* expecting one type of proxy vs another, e.g. in tests.
155+
* Spring-managed beans requiring proxying, not just those marked with {@code @Cacheable}.
156+
* For example, other beans marked with Spring's {@code @Transactional} annotation will
157+
* be upgraded to subclass proxying at the same time. This approach has no negative
158+
* impact in practice unless one is explicitly expecting one type of proxy vs another,
159+
* e.g. in tests.
161160
*/
162161
boolean proxyTargetClass() default false;
163162

@@ -174,4 +173,5 @@
174173
* The default is {@link Ordered#LOWEST_PRECEDENCE}.
175174
*/
176175
int order() default Ordered.LOWEST_PRECEDENCE;
176+
177177
}

spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java

Lines changed: 2 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-2015 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.
@@ -24,7 +24,6 @@
2424
import groovy.lang.Script;
2525
import org.codehaus.groovy.control.CompilationFailedException;
2626

27-
import org.springframework.beans.BeansException;
2827
import org.springframework.beans.factory.BeanClassLoaderAware;
2928
import org.springframework.beans.factory.BeanFactory;
3029
import org.springframework.beans.factory.BeanFactoryAware;
@@ -99,7 +98,7 @@ public GroovyScriptFactory(String scriptSourceLocator, GroovyObjectCustomizer gr
9998
}
10099

101100

102-
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
101+
public void setBeanFactory(BeanFactory beanFactory) {
103102
if (beanFactory instanceof ConfigurableListableBeanFactory) {
104103
((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class);
105104
}

spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java

Lines changed: 12 additions & 13 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-2015 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.
@@ -94,7 +94,7 @@
9494
* &lt;property name="message" value="Hello World!"/&gt;
9595
* &lt;/bean&gt;
9696
*
97-
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.bsh.GroovyScriptFactory"&gt;
97+
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory"&gt;
9898
* &lt;constructor-arg value="classpath:mypackage/Messenger.groovy"/&gt;
9999
* &lt;property name="message" value="Hello World!"/&gt;
100100
* &lt;/bean&gt;</pre>
@@ -325,7 +325,7 @@ public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName
325325
if (proxyTargetClass && (language == null || !language.equals("groovy"))) {
326326
throw new BeanDefinitionValidationException(
327327
"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '" +
328-
language + "'");
328+
language + "'");
329329
}
330330
ts.setRefreshCheckDelay(refreshCheckDelay);
331331
return createRefreshableProxy(ts, interfaces, proxyTargetClass);
@@ -346,17 +346,16 @@ public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName
346346
* @param scriptedObjectBeanName the name of the internal scripted object bean
347347
*/
348348
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
349-
350349
// Avoid recreation of the script bean definition in case of a prototype.
351350
synchronized (this.scriptBeanFactory) {
352351
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
353352

354-
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName,
355-
createScriptFactoryBeanDefinition(bd));
356-
ScriptFactory scriptFactory = this.scriptBeanFactory
357-
.getBean(scriptFactoryBeanName, ScriptFactory.class);
358-
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName,
359-
scriptFactory.getScriptSourceLocator());
353+
this.scriptBeanFactory.registerBeanDefinition(
354+
scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd));
355+
ScriptFactory scriptFactory =
356+
this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
357+
ScriptSource scriptSource =
358+
getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
360359
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
361360

362361
Class<?>[] scriptedInterfaces = interfaces;
@@ -365,8 +364,8 @@ protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanNam
365364
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
366365
}
367366

368-
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource,
369-
scriptedInterfaces);
367+
BeanDefinition objectBd = createScriptedObjectBeanDefinition(
368+
bd, scriptFactoryBeanName, scriptSource, scriptedInterfaces);
370369
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
371370
if (refreshCheckDelay >= 0) {
372371
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
@@ -569,7 +568,7 @@ protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces,
569568
proxyFactory.setInterfaces(interfaces);
570569
if (proxyTargetClass) {
571570
classLoader = null; // force use of Class.getClassLoader()
572-
proxyFactory.setProxyTargetClass(proxyTargetClass);
571+
proxyFactory.setProxyTargetClass(true);
573572
}
574573

575574
DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);

spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java

Lines changed: 9 additions & 8 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-2015 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.
@@ -24,7 +24,6 @@
2424
import javax.inject.Named;
2525
import javax.inject.Qualifier;
2626

27-
import static org.junit.Assert.*;
2827
import org.junit.Test;
2928

3029
import org.springframework.aop.scope.ScopedProxyUtils;
@@ -36,6 +35,8 @@
3635
import org.springframework.context.annotation.AnnotationConfigUtils;
3736
import org.springframework.context.support.GenericApplicationContext;
3837

38+
import static org.junit.Assert.*;
39+
3940
/**
4041
* Integration tests for handling JSR-303 {@link javax.inject.Qualifier} annotations.
4142
*
@@ -666,27 +667,27 @@ public QualifiedPerson(String name) {
666667
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
667668
@Retention(RetentionPolicy.RUNTIME)
668669
@Qualifier
669-
public static @interface TestQualifier {
670+
public @interface TestQualifier {
670671
}
671672

672673

673674
@Target(ElementType.FIELD)
674675
@Retention(RetentionPolicy.RUNTIME)
675676
@Qualifier
676-
public static @interface TestQualifierWithDefaultValue {
677+
public @interface TestQualifierWithDefaultValue {
677678

678-
public abstract String value() default "default";
679+
String value() default "default";
679680
}
680681

681682

682683
@Target(ElementType.FIELD)
683684
@Retention(RetentionPolicy.RUNTIME)
684685
@Qualifier
685-
public static @interface TestQualifierWithMultipleAttributes {
686+
public @interface TestQualifierWithMultipleAttributes {
686687

687-
public abstract String value() default "default";
688+
String value() default "default";
688689

689-
public abstract int number();
690+
int number();
690691
}
691692

692693
}

spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public static Field findField(Class<?> clazz, String name, Class<?> type) {
9191
while (!Object.class.equals(searchType) && searchType != null) {
9292
Field[] fields = searchType.getDeclaredFields();
9393
for (Field field : fields) {
94-
if ((name == null || name.equals(field.getName())) && (type == null || type.equals(field.getType()))) {
94+
if ((name == null || name.equals(field.getName())) &&
95+
(type == null || type.equals(field.getType()))) {
9596
return field;
9697
}
9798
}
@@ -424,7 +425,8 @@ public static boolean isCglibRenamedMethod(Method renamedMethod) {
424425
* @see java.lang.reflect.Field#setAccessible
425426
*/
426427
public static void makeAccessible(Field field) {
427-
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
428+
if ((!Modifier.isPublic(field.getModifiers()) ||
429+
!Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
428430
Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
429431
field.setAccessible(true);
430432
}

spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.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-2015 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.
@@ -165,11 +165,11 @@ public void getGenericsOnArrayFromParamCannotBeResolved() throws Exception {
165165
public void getGenericsOnArrayFromReturnCannotBeResolved() throws Exception {
166166
// SPR-11044
167167
Class<?> resolved = GenericTypeResolver.resolveReturnType(
168-
WithArrayBase.class.getDeclaredMethod("array", Object[].class),
169-
WithArray.class);
168+
WithArrayBase.class.getDeclaredMethod("array", Object[].class), WithArray.class);
170169
assertThat(resolved, equalTo((Class) Object[].class));
171170
}
172171

172+
173173
public interface MyInterfaceType<T> {
174174
}
175175

spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java

Lines changed: 13 additions & 13 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-2015 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.
@@ -20,7 +20,6 @@
2020
import java.sql.SQLException;
2121
import java.util.Arrays;
2222
import java.util.List;
23-
2423
import javax.sql.DataSource;
2524

2625
import org.apache.commons.logging.Log;
@@ -32,16 +31,14 @@
3231
import org.springframework.jdbc.support.MetaDataAccessException;
3332

3433
/**
35-
* Factory used to create a {@link CallMetaDataProvider} implementation based on the type of databse being used.
34+
* Factory used to create a {@link CallMetaDataProvider} implementation
35+
* based on the type of database being used.
3636
*
3737
* @author Thomas Risberg
3838
* @since 2.5
3939
*/
4040
public class CallMetaDataProviderFactory {
4141

42-
/** Logger */
43-
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
44-
4542
/** List of supported database products for procedure calls */
4643
public static final List<String> supportedDatabaseProductsForProcedures = Arrays.asList(
4744
"Apache Derby",
@@ -52,6 +49,7 @@ public class CallMetaDataProviderFactory {
5249
"PostgreSQL",
5350
"Sybase"
5451
);
52+
5553
/** List of supported database products for function calls */
5654
public static final List<String> supportedDatabaseProductsForFunctions = Arrays.asList(
5755
"MySQL",
@@ -60,10 +58,13 @@ public class CallMetaDataProviderFactory {
6058
"PostgreSQL"
6159
);
6260

61+
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
62+
63+
6364
/**
64-
* Create a CallMetaDataProvider based on the database metedata
65-
* @param dataSource used to retrieve metedata
66-
* @param context the class that holds configuration and metedata
65+
* Create a CallMetaDataProvider based on the database metadata
66+
* @param dataSource used to retrieve metadata
67+
* @param context the class that holds configuration and metadata
6768
* @return instance of the CallMetaDataProvider implementation to be used
6869
*/
6970
static public CallMetaDataProvider createMetaDataProvider(DataSource dataSource, final CallMetaDataContext context) {
@@ -124,17 +125,16 @@ else if ("Microsoft SQL Server".equals(databaseProductName)) {
124125
}
125126
provider.initializeWithMetaData(databaseMetaData);
126127
if (accessProcedureColumnMetaData) {
127-
provider.initializeWithProcedureColumnMetaData(
128-
databaseMetaData, context.getCatalogName(), context.getSchemaName(), context.getProcedureName());
128+
provider.initializeWithProcedureColumnMetaData(databaseMetaData,
129+
context.getCatalogName(), context.getSchemaName(), context.getProcedureName());
129130
}
130131
return provider;
131132
}
132133
});
133134
}
134135
catch (MetaDataAccessException ex) {
135-
throw new DataAccessResourceFailureException("Error retreiving database metadata", ex);
136+
throw new DataAccessResourceFailureException("Error retrieving database metadata", ex);
136137
}
137-
138138
}
139139

140140
}

0 commit comments

Comments
 (0)