Skip to content

Commit 0babc1f

Browse files
committed
Polishing
1 parent 95a84bb commit 0babc1f

File tree

11 files changed

+176
-126
lines changed

11 files changed

+176
-126
lines changed

spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -958,6 +958,7 @@ private PropertyTokenHolder getPropertyNameTokens(String propertyName) {
958958
return tokens;
959959
}
960960

961+
961962
@Override
962963
public String toString() {
963964
StringBuilder sb = new StringBuilder(getClass().getName());

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ public void overrideFrom(BeanDefinition other) {
352352

353353
/**
354354
* Apply the provided default values to this bean.
355-
* @param defaults the defaults to apply
355+
* @param defaults the default settings to apply
356+
* @since 2.5
356357
*/
357358
public void applyDefaults(BeanDefinitionDefaults defaults) {
358359
setLazyInit(defaults.isLazyInit());
@@ -515,6 +516,7 @@ public void setLazyInit(boolean lazyInit) {
515516
/**
516517
* Return whether this bean should be lazily initialized, i.e. not
517518
* eagerly instantiated on startup. Only applicable to a singleton bean.
519+
* @return whether to apply lazy-init semantics ({@code false} by default)
518520
*/
519521
@Override
520522
public boolean isLazyInit() {
@@ -523,8 +525,9 @@ public boolean isLazyInit() {
523525

524526
/**
525527
* Set the autowire mode. This determines whether any automagical detection
526-
* and setting of bean references will happen. Default is AUTOWIRE_NO,
527-
* which means there's no autowire.
528+
* and setting of bean references will happen. Default is AUTOWIRE_NO
529+
* which means there won't be convention-based autowiring by name or type
530+
* (however, there may still be explicit annotation-driven autowiring).
528531
* @param autowireMode the autowire mode to set.
529532
* Must be one of the constants defined in this class.
530533
* @see #AUTOWIRE_NO

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

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -23,60 +23,102 @@
2323
* A simple holder for {@code BeanDefinition} property defaults.
2424
*
2525
* @author Mark Fisher
26+
* @author Juergen Hoeller
2627
* @since 2.5
2728
*/
2829
public class BeanDefinitionDefaults {
2930

3031
private boolean lazyInit;
3132

32-
private int dependencyCheck = AbstractBeanDefinition.DEPENDENCY_CHECK_NONE;
33-
3433
private int autowireMode = AbstractBeanDefinition.AUTOWIRE_NO;
3534

35+
private int dependencyCheck = AbstractBeanDefinition.DEPENDENCY_CHECK_NONE;
36+
3637
@Nullable
3738
private String initMethodName;
3839

3940
@Nullable
4041
private String destroyMethodName;
4142

4243

44+
/**
45+
* Set whether beans should be lazily initialized by default.
46+
* <p>If {@code false}, the bean will get instantiated on startup by bean
47+
* factories that perform eager initialization of singletons.
48+
*/
4349
public void setLazyInit(boolean lazyInit) {
4450
this.lazyInit = lazyInit;
4551
}
4652

53+
/**
54+
* Return whether beans should be lazily initialized by default, i.e. not
55+
* eagerly instantiated on startup. Only applicable to singleton beans.
56+
* @return whether to apply lazy-init semantics ({@code false} by default)
57+
*/
4758
public boolean isLazyInit() {
4859
return this.lazyInit;
4960
}
5061

51-
public void setDependencyCheck(int dependencyCheck) {
52-
this.dependencyCheck = dependencyCheck;
53-
}
54-
55-
public int getDependencyCheck() {
56-
return this.dependencyCheck;
57-
}
58-
62+
/**
63+
* Set the autowire mode. This determines whether any automagical detection
64+
* and setting of bean references will happen. Default is AUTOWIRE_NO
65+
* which means there won't be convention-based autowiring by name or type
66+
* (however, there may still be explicit annotation-driven autowiring).
67+
* @param autowireMode the autowire mode to set.
68+
* Must be one of the constants defined in {@link AbstractBeanDefinition}.
69+
*/
5970
public void setAutowireMode(int autowireMode) {
6071
this.autowireMode = autowireMode;
6172
}
6273

74+
/**
75+
* Return the default autowire mode.
76+
*/
6377
public int getAutowireMode() {
6478
return this.autowireMode;
6579
}
6680

81+
/**
82+
* Set the dependency check code.
83+
* @param dependencyCheck the code to set.
84+
* Must be one of the constants defined in {@link AbstractBeanDefinition}.
85+
*/
86+
public void setDependencyCheck(int dependencyCheck) {
87+
this.dependencyCheck = dependencyCheck;
88+
}
89+
90+
/**
91+
* Return the default dependency check code.
92+
*/
93+
public int getDependencyCheck() {
94+
return this.dependencyCheck;
95+
}
96+
97+
/**
98+
* Set the name of the default initializer method.
99+
*/
67100
public void setInitMethodName(@Nullable String initMethodName) {
68101
this.initMethodName = (StringUtils.hasText(initMethodName) ? initMethodName : null);
69102
}
70103

104+
/**
105+
* Return the name of the default initializer method.
106+
*/
71107
@Nullable
72108
public String getInitMethodName() {
73109
return this.initMethodName;
74110
}
75111

112+
/**
113+
* Set the name of the default destroy method.
114+
*/
76115
public void setDestroyMethodName(@Nullable String destroyMethodName) {
77116
this.destroyMethodName = (StringUtils.hasText(destroyMethodName) ? destroyMethodName : null);
78117
}
79118

119+
/**
120+
* Return the name of the default destroy method.
121+
*/
80122
@Nullable
81123
public String getDestroyMethodName() {
82124
return this.destroyMethodName;

spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public DocumentDefaultsDefinition getDefaults() {
377377
*/
378378
public BeanDefinitionDefaults getBeanDefinitionDefaults() {
379379
BeanDefinitionDefaults bdd = new BeanDefinitionDefaults();
380-
bdd.setLazyInit("TRUE".equalsIgnoreCase(this.defaults.getLazyInit()));
380+
bdd.setLazyInit(TRUE_VALUE.equalsIgnoreCase(this.defaults.getLazyInit()));
381381
bdd.setAutowireMode(getAutowireMode(DEFAULT_VALUE));
382382
bdd.setInitMethodName(this.defaults.getInitMethod());
383383
bdd.setDestroyMethodName(this.defaults.getDestroyMethod());

spring-core/src/main/java/org/springframework/core/log/LogFormatUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -82,8 +82,9 @@ public static String formatValue(@Nullable Object value, boolean limitLength) {
8282
*/
8383
public static void traceDebug(Log logger, Function<Boolean, String> messageFactory) {
8484
if (logger.isDebugEnabled()) {
85-
String logMessage = messageFactory.apply(logger.isTraceEnabled());
86-
if (logger.isTraceEnabled()) {
85+
boolean traceEnabled = logger.isTraceEnabled();
86+
String logMessage = messageFactory.apply(traceEnabled);
87+
if (traceEnabled) {
8788
logger.trace(logMessage);
8889
}
8990
else {

spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java

Lines changed: 6 additions & 6 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-2019 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.
@@ -33,12 +33,12 @@
3333
public class BeanPropertySqlParameterSourceTests {
3434

3535
@Test(expected = IllegalArgumentException.class)
36-
public void withNullBeanPassedToCtor() throws Exception {
36+
public void withNullBeanPassedToCtor() {
3737
new BeanPropertySqlParameterSource(null);
3838
}
3939

4040
@Test(expected = IllegalArgumentException.class)
41-
public void getValueWhereTheUnderlyingBeanHasNoSuchProperty() throws Exception {
41+
public void getValueWhereTheUnderlyingBeanHasNoSuchProperty() {
4242
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(new TestBean());
4343
source.getValue("thisPropertyDoesNotExist");
4444
}
@@ -65,19 +65,19 @@ public void successfulPropertyAccessWithOverriddenSqlType() {
6565
}
6666

6767
@Test
68-
public void hasValueWhereTheUnderlyingBeanHasNoSuchProperty() throws Exception {
68+
public void hasValueWhereTheUnderlyingBeanHasNoSuchProperty() {
6969
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(new TestBean());
7070
assertFalse(source.hasValue("thisPropertyDoesNotExist"));
7171
}
7272

7373
@Test(expected = IllegalArgumentException.class)
74-
public void getValueWhereTheUnderlyingBeanPropertyIsNotReadable() throws Exception {
74+
public void getValueWhereTheUnderlyingBeanPropertyIsNotReadable() {
7575
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(new NoReadableProperties());
7676
source.getValue("noOp");
7777
}
7878

7979
@Test
80-
public void hasValueWhereTheUnderlyingBeanPropertyIsNotReadable() throws Exception {
80+
public void hasValueWhereTheUnderlyingBeanPropertyIsNotReadable() {
8181
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(new NoReadableProperties());
8282
assertFalse(source.hasValue("noOp"));
8383
}

spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2006 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -29,18 +29,18 @@
2929
public class MapSqlParameterSourceTests {
3030

3131
@Test
32-
public void nullParameterValuesPassedToCtorIsOk() throws Exception {
32+
public void nullParameterValuesPassedToCtorIsOk() {
3333
new MapSqlParameterSource(null);
3434
}
3535

3636
@Test(expected = IllegalArgumentException.class)
37-
public void getValueChokesIfParameterIsNotPresent() throws Exception {
37+
public void getValueChokesIfParameterIsNotPresent() {
3838
MapSqlParameterSource source = new MapSqlParameterSource();
3939
source.getValue("pechorin was right!");
4040
}
4141

4242
@Test
43-
public void sqlParameterValueRegistersSqlType() throws Exception {
43+
public void sqlParameterValueRegistersSqlType() {
4444
MapSqlParameterSource msps = new MapSqlParameterSource("FOO", new SqlParameterValue(2, "Foo"));
4545
assertEquals("Correct SQL Type not registered", 2, msps.getSqlType("FOO"));
4646
MapSqlParameterSource msps2 = new MapSqlParameterSource();

0 commit comments

Comments
 (0)