Skip to content

Commit f949461

Browse files
committed
Polishing
(cherry picked from commit a8741dd)
1 parent 9a39a25 commit f949461

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/DefaultAdvisorAutoProxyCreator.java

Lines changed: 15 additions & 14 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-2016 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.
@@ -19,15 +19,16 @@
1919
import org.springframework.beans.factory.BeanNameAware;
2020

2121
/**
22-
* BeanPostProcessor implementation that creates AOP proxies based on all candidate
23-
* Advisors in the current BeanFactory. This class is completely generic; it contains
24-
* no special code to handle any particular aspects, such as pooling aspects.
22+
* {@code BeanPostProcessor} implementation that creates AOP proxies based on all
23+
* candidate {@code Advisor}s in the current {@code BeanFactory}. This class is
24+
* completely generic; it contains no special code to handle any particular aspects,
25+
* such as pooling aspects.
2526
*
2627
* <p>It's possible to filter out advisors - for example, to use multiple post processors
27-
* of this type in the same factory - by setting the {@code usePrefix} property
28-
* to true, in which case only advisors beginning with the DefaultAdvisorAutoProxyCreator's
29-
* bean name followed by a dot (like "aapc.") will be used. This default prefix can be
30-
* changed from the bean name by setting the {@code advisorBeanNamePrefix} property.
28+
* of this type in the same factory - by setting the {@code usePrefix} property to true,
29+
* in which case only advisors beginning with the DefaultAdvisorAutoProxyCreator's bean
30+
* name followed by a dot (like "aapc.") will be used. This default prefix can be changed
31+
* from the bean name by setting the {@code advisorBeanNamePrefix} property.
3132
* The separator (.) will also be used in this case.
3233
*
3334
* @author Rod Johnson
@@ -40,22 +41,22 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea
4041
public final static String SEPARATOR = ".";
4142

4243

43-
private boolean usePrefix;
44+
private boolean usePrefix = false;
4445

4546
private String advisorBeanNamePrefix;
4647

4748

4849
/**
49-
* Set whether to exclude advisors with a certain prefix
50-
* in the bean name.
50+
* Set whether to only include advisors with a certain prefix in the bean name.
51+
* <p>Default is {@code false}, including all beans of type {@code Advisor}.
52+
* @see #setAdvisorBeanNamePrefix
5153
*/
5254
public void setUsePrefix(boolean usePrefix) {
5355
this.usePrefix = usePrefix;
5456
}
5557

5658
/**
57-
* Return whether to exclude advisors with a certain prefix
58-
* in the bean name.
59+
* Return whether to only include advisors with a certain prefix in the bean name.
5960
*/
6061
public boolean isUsePrefix() {
6162
return this.usePrefix;
@@ -89,7 +90,7 @@ public void setBeanName(String name) {
8990

9091

9192
/**
92-
* Consider Advisor beans with the specified prefix as eligible, if activated.
93+
* Consider {@code Advisor} beans with the specified prefix as eligible, if activated.
9394
* @see #setUsePrefix
9495
* @see #setAdvisorBeanNamePrefix
9596
*/

spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.TimeZone;
2828

2929
import org.springframework.format.Formatter;
30-
import org.springframework.format.annotation.DateTimeFormat;
3130
import org.springframework.format.annotation.DateTimeFormat.ISO;
3231
import org.springframework.util.StringUtils;
3332

@@ -43,10 +42,12 @@
4342
*/
4443
public class DateFormatter implements Formatter<Date> {
4544

45+
private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
46+
4647
private static final Map<ISO, String> ISO_PATTERNS;
4748

4849
static {
49-
Map<ISO, String> formats = new HashMap<DateTimeFormat.ISO, String>(4);
50+
Map<ISO, String> formats = new HashMap<ISO, String>(4);
5051
formats.put(ISO.DATE, "yyyy-MM-dd");
5152
formats.put(ISO.TIME, "HH:mm:ss.SSSZ");
5253
formats.put(ISO.DATE_TIME, "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
@@ -176,7 +177,7 @@ private DateFormat createDateFormat(Locale locale) {
176177
throw new IllegalStateException("Unsupported ISO format " + this.iso);
177178
}
178179
SimpleDateFormat format = new SimpleDateFormat(pattern);
179-
format.setTimeZone(TimeZone.getTimeZone("UTC"));
180+
format.setTimeZone(UTC);
180181
return format;
181182
}
182183
if (StringUtils.hasLength(this.stylePattern)) {

spring-context/src/main/java/org/springframework/format/datetime/DateFormatterRegistrar.java

Lines changed: 10 additions & 7 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-2016 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.
@@ -26,14 +26,17 @@
2626
import org.springframework.util.Assert;
2727

2828
/**
29-
* Configures Date formatting for use with Spring.
29+
* Configures basic date formatting for use with Spring, primarily for
30+
* {@link org.springframework.format.annotation.DateTimeFormat} declarations.
31+
* Applies to fields of type {@link Date}, {@link Calendar} and {@code long}.
3032
*
3133
* <p>Designed for direct instantiation but also exposes the static
32-
* {@link #addDateConverters(ConverterRegistry)} utility method for ad hoc use
33-
* against any {@code ConverterRegistry} instance.
34+
* {@link #addDateConverters(ConverterRegistry)} utility method for
35+
* ad-hoc use against any {@code ConverterRegistry} instance.
3436
*
3537
* @author Phillip Webb
3638
* @since 3.2
39+
* @see org.springframework.format.datetime.standard.DateTimeFormatterRegistrar
3740
* @see org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar
3841
* @see FormatterRegistrar#registerFormatters
3942
*/
@@ -43,9 +46,9 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
4346

4447

4548
/**
46-
* Set the date formatter to register. If not specified no formatter is registered.
47-
* This method can be used if global formatter configuration is required.
48-
* @param dateFormatter the date formatter
49+
* Set a global date formatter to register.
50+
* <p>If not specified, no general formatter for non-annotated
51+
* {@link Date} and {@link Calendar} fields will be registered.
4952
*/
5053
public void setFormatter(DateFormatter dateFormatter) {
5154
Assert.notNull(dateFormatter, "DateFormatter must not be null");

spring-context/src/main/java/org/springframework/format/datetime/DateTimeFormatAnnotationFormatterFactory.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
import org.springframework.format.annotation.DateTimeFormat;
3131

3232
/**
33-
* Formats fields annotated with the {@link DateTimeFormat} annotation using
34-
* a {@link DateFormatter}.
33+
* Formats fields annotated with the {@link DateTimeFormat} annotation using a {@link DateFormatter}.
3534
*
3635
* @author Phillip Webb
3736
* @since 3.2
@@ -40,7 +39,6 @@
4039
public class DateTimeFormatAnnotationFormatterFactory extends EmbeddedValueResolutionSupport
4140
implements AnnotationFormatterFactory<DateTimeFormat> {
4241

43-
4442
private static final Set<Class<?>> FIELD_TYPES;
4543

4644
static {

0 commit comments

Comments
 (0)