Skip to content

Commit a3ddee2

Browse files
committed
Mark applicable Scope's methods as default
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
1 parent 19ce8c3 commit a3ddee2

File tree

13 files changed

+6
-102
lines changed

13 files changed

+6
-102
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public interface Scope {
130130
* @return the corresponding object, or {@code null} if none found
131131
* @throws IllegalStateException if the underlying scope is not currently active
132132
*/
133-
@Nullable Object resolveContextualObject(String key);
133+
default @Nullable Object resolveContextualObject(String key) {
134+
return null;
135+
}
134136

135137
/**
136138
* Return the <em>conversation ID</em> for the current underlying scope, if any.
@@ -147,6 +149,8 @@ public interface Scope {
147149
* conversation ID for the current scope
148150
* @throws IllegalStateException if the underlying scope is not currently active
149151
*/
150-
@Nullable String getConversationId();
152+
default @Nullable String getConversationId() {
153+
return null;
154+
}
151155

152156
}

spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,4 @@ public Object remove(String name) {
4444
public void registerDestructionCallback(String name, Runnable callback) {
4545
}
4646

47-
@Override
48-
public Object resolveContextualObject(String key) {
49-
return null;
50-
}
51-
52-
@Override
53-
public String getConversationId() {
54-
return null;
55-
}
56-
5747
}

spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ public void registerDestructionCallback(String name, Runnable callback) {
8383
"Consider using RequestScope in a web environment.");
8484
}
8585

86-
@Override
87-
public @Nullable Object resolveContextualObject(String key) {
88-
return null;
89-
}
90-
9186
@Override
9287
public String getConversationId() {
9388
return Thread.currentThread().getName();

spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,6 @@ public Object get(String name, ObjectFactory<?> objectFactory) {
353353
return beans.get(name);
354354
}
355355

356-
@Override
357-
public String getConversationId() {
358-
return null;
359-
}
360-
361356
@Override
362357
public void registerDestructionCallback(String name, Runnable callback) {
363358
throw new IllegalStateException("Not supposed to be called");
@@ -368,10 +363,6 @@ public Object remove(String name) {
368363
return beans.remove(name);
369364
}
370365

371-
@Override
372-
public Object resolveContextualObject(String key) {
373-
return null;
374-
}
375366
}
376367

377368
}

spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,6 @@ public Object remove(String name) {
8383
@Override
8484
public void registerDestructionCallback(String name, Runnable callback) {
8585
}
86-
87-
@Override
88-
public Object resolveContextualObject(String key) {
89-
return null;
90-
}
91-
92-
@Override
93-
public String getConversationId() {
94-
return null;
95-
}
9686
}
9787

9888

spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,16 +1090,6 @@ public Object remove(String name) {
10901090
@Override
10911091
public void registerDestructionCallback(String name, Runnable callback) {
10921092
}
1093-
1094-
@Override
1095-
public Object resolveContextualObject(String key) {
1096-
return null;
1097-
}
1098-
1099-
@Override
1100-
public String getConversationId() {
1101-
return null;
1102-
}
11031093
}
11041094

11051095

spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ public Object resolveContextualObject(String key) {
9494
return null;
9595
}
9696
}
97-
@Override
98-
public String getConversationId() {
99-
return null;
100-
}
10197
});
10298

10399
ac.getBeanFactory().setConversionService(new DefaultConversionService());

spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,21 +1214,11 @@ public Object remove(String name) {
12141214
public void registerDestructionCallback(String name, Runnable callback) {
12151215
}
12161216

1217-
@Override
1218-
public String getConversationId() {
1219-
return null;
1220-
}
1221-
12221217
@Override
12231218
public Object get(String name, ObjectFactory<?> objectFactory) {
12241219
instanceCount++;
12251220
return objectFactory.getObject();
12261221
}
1227-
1228-
@Override
1229-
public Object resolveContextualObject(String s) {
1230-
return null;
1231-
}
12321222
}
12331223

12341224
class BirthdayCardSender {

spring-context/src/testFixtures/java/org/springframework/context/testfixture/SimpleMapScope.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,10 @@ public void registerDestructionCallback(String name, Runnable callback) {
6868
this.callbacks.add(callback);
6969
}
7070

71-
@Override
72-
public Object resolveContextualObject(String key) {
73-
return null;
74-
}
75-
7671
public void close() {
7772
for (Runnable runnable : this.callbacks) {
7873
runnable.run();
7974
}
8075
}
8176

82-
@Override
83-
public String getConversationId() {
84-
return null;
85-
}
86-
8777
}

spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ public void registerDestructionCallback(String name, Runnable callback) {
7070
SimpAttributesContextHolder.currentAttributes().registerDestructionCallback(name, callback);
7171
}
7272

73-
@Override
74-
public @Nullable Object resolveContextualObject(String key) {
75-
return null;
76-
}
77-
7873
@Override
7974
public String getConversationId() {
8075
return SimpAttributesContextHolder.currentAttributes().getSessionId();

spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ public void registerDestructionCallback(String name, Runnable callback) {
8181
}
8282
}
8383

84-
@Override
85-
public @Nullable Object resolveContextualObject(String key) {
86-
return null;
87-
}
88-
8984
@Override
9085
public @Nullable String getConversationId() {
9186
return TransactionSynchronizationManager.getCurrentTransactionName();

spring-web/src/main/java/org/springframework/web/context/request/RequestScope.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.web.context.request;
1818

19-
import org.jspecify.annotations.Nullable;
20-
2119
/**
2220
* Request-backed {@link org.springframework.beans.factory.config.Scope}
2321
* implementation.
@@ -44,13 +42,4 @@ protected int getScope() {
4442
return RequestAttributes.SCOPE_REQUEST;
4543
}
4644

47-
/**
48-
* There is no conversation id concept for a request, so this method
49-
* returns {@code null}.
50-
*/
51-
@Override
52-
public @Nullable String getConversationId() {
53-
return null;
54-
}
55-
5645
}

spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,6 @@ public void registerDestructionCallback(String name, Runnable callback) {
9696
}
9797
}
9898

99-
@Override
100-
public @Nullable Object resolveContextualObject(String key) {
101-
return null;
102-
}
103-
104-
@Override
105-
public @Nullable String getConversationId() {
106-
return null;
107-
}
108-
109-
11099
/**
111100
* Invoke all registered destruction callbacks.
112101
* To be called on ServletContext shutdown.

0 commit comments

Comments
 (0)