mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Mark applicable Scope's methods as default
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
committed by
Juergen Hoeller
parent
88257f7dfd
commit
410a9ce108
@@ -130,7 +130,9 @@ public interface Scope {
|
||||
* @return the corresponding object, or {@code null} if none found
|
||||
* @throws IllegalStateException if the underlying scope is not currently active
|
||||
*/
|
||||
@Nullable Object resolveContextualObject(String key);
|
||||
default @Nullable Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the <em>conversation ID</em> for the current underlying scope, if any.
|
||||
@@ -147,6 +149,8 @@ public interface Scope {
|
||||
* conversation ID for the current scope
|
||||
* @throws IllegalStateException if the underlying scope is not currently active
|
||||
*/
|
||||
@Nullable String getConversationId();
|
||||
default @Nullable String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,14 +44,4 @@ class NoOpScope implements Scope {
|
||||
public void registerDestructionCallback(String name, Runnable callback) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-5
@@ -83,11 +83,6 @@ public class SimpleThreadScope implements Scope {
|
||||
"Consider using RequestScope in a web environment.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return Thread.currentThread().getName();
|
||||
|
||||
-9
@@ -353,11 +353,6 @@ class ScopingTests {
|
||||
return beans.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDestructionCallback(String name, Runnable callback) {
|
||||
throw new IllegalStateException("Not supposed to be called");
|
||||
@@ -368,10 +363,6 @@ class ScopingTests {
|
||||
return beans.remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-10
@@ -83,16 +83,6 @@ class Spr10744Tests {
|
||||
@Override
|
||||
public void registerDestructionCallback(String name, Runnable callback) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
-10
@@ -1090,16 +1090,6 @@ class AnnotationDrivenEventListenerTests {
|
||||
@Override
|
||||
public void registerDestructionCallback(String name, Runnable callback) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
-4
@@ -94,10 +94,6 @@ class ApplicationContextExpressionTests {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
ac.getBeanFactory().setConversionService(new DefaultConversionService());
|
||||
|
||||
-10
@@ -1214,21 +1214,11 @@ class TestScope implements Scope {
|
||||
public void registerDestructionCallback(String name, Runnable callback) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String name, ObjectFactory<?> objectFactory) {
|
||||
instanceCount++;
|
||||
return objectFactory.getObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveContextualObject(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class BirthdayCardSender {
|
||||
|
||||
-10
@@ -68,20 +68,10 @@ public class SimpleMapScope implements Scope, Serializable {
|
||||
this.callbacks.add(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
for (Runnable runnable : this.callbacks) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-5
@@ -70,11 +70,6 @@ public class SimpSessionScope implements Scope {
|
||||
SimpAttributesContextHolder.currentAttributes().registerDestructionCallback(name, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return SimpAttributesContextHolder.currentAttributes().getSessionId();
|
||||
|
||||
-5
@@ -81,11 +81,6 @@ public class SimpleTransactionScope implements Scope {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getConversationId() {
|
||||
return TransactionSynchronizationManager.getCurrentTransactionName();
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.web.context.request;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Request-backed {@link org.springframework.beans.factory.config.Scope}
|
||||
* implementation.
|
||||
@@ -44,13 +42,4 @@ public class RequestScope extends AbstractRequestAttributesScope {
|
||||
return RequestAttributes.SCOPE_REQUEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* There is no conversation id concept for a request, so this method
|
||||
* returns {@code null}.
|
||||
*/
|
||||
@Override
|
||||
public @Nullable String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-11
@@ -96,17 +96,6 @@ public class ServletContextScope implements Scope, DisposableBean {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Invoke all registered destruction callbacks.
|
||||
* To be called on ServletContext shutdown.
|
||||
|
||||
Reference in New Issue
Block a user