Skip to content

Commit 03179aa

Browse files
committed
Merge pull request #28057 from philwebb
* pr/28057: Polish contribution Provide more control over factory failure handling Allow flexible constructor arguments in factory implementations Closes gh-28057
2 parents ae1956c + da45bd2 commit 03179aa

File tree

7 files changed

+978
-38
lines changed

7 files changed

+978
-38
lines changed

spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java

Lines changed: 457 additions & 36 deletions
Large diffs are not rendered by default.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2002-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.core.io.support;
18+
19+
/**
20+
* Used by {@link SpringFactoriesLoaderTests}.
21+
*
22+
* @author Andy Wilkinson
23+
*/
24+
class ConstructorArgsDummyFactory implements DummyFactory {
25+
26+
private final String string;
27+
28+
public ConstructorArgsDummyFactory(String string) {
29+
this(string, 0);
30+
}
31+
32+
private ConstructorArgsDummyFactory(String string, int reasonCode) {
33+
this.string = string;
34+
}
35+
36+
@Override
37+
public String getString() {
38+
return this.string;
39+
}
40+
41+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2002-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.core.io.support;
18+
19+
/**
20+
* Used by {@link SpringFactoriesLoaderTests}.
21+
*
22+
* @author Madhura Bhave
23+
*/
24+
class MultipleConstructorArgsDummyFactory implements DummyFactory {
25+
26+
private final String string;
27+
28+
private final Integer age;
29+
30+
MultipleConstructorArgsDummyFactory(String string) {
31+
this(string, null);
32+
}
33+
34+
MultipleConstructorArgsDummyFactory(String string, Integer age) {
35+
this.string = string;
36+
this.age = age;
37+
}
38+
39+
40+
@Override
41+
public String getString() {
42+
return this.string + this.age;
43+
}
44+
45+
}

0 commit comments

Comments
 (0)