This commit is contained in:
Yanming Zhou 2025-04-23 23:40:50 +02:00 committed by GitHub
commit 826c956068
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 19 additions and 115 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -130,7 +130,9 @@ public interface Scope {
* @return the corresponding object, or {@code null} if none found * @return the corresponding object, or {@code null} if none found
* @throws IllegalStateException if the underlying scope is not currently active * @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. * 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 * conversation ID for the current scope
* @throws IllegalStateException if the underlying scope is not currently active * @throws IllegalStateException if the underlying scope is not currently active
*/ */
@Nullable String getConversationId(); default @Nullable String getConversationId() {
return null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,14 +44,4 @@ class NoOpScope implements Scope {
public void registerDestructionCallback(String name, Runnable callback) { public void registerDestructionCallback(String name, Runnable callback) {
} }
@Override
public Object resolveContextualObject(String key) {
return null;
}
@Override
public String getConversationId() {
return null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -83,11 +83,6 @@ public class SimpleThreadScope implements Scope {
"Consider using RequestScope in a web environment."); "Consider using RequestScope in a web environment.");
} }
@Override
public @Nullable Object resolveContextualObject(String key) {
return null;
}
@Override @Override
public String getConversationId() { public String getConversationId() {
return Thread.currentThread().getName(); return Thread.currentThread().getName();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2024 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -353,11 +353,6 @@ class ScopingTests {
return beans.get(name); return beans.get(name);
} }
@Override
public String getConversationId() {
return null;
}
@Override @Override
public void registerDestructionCallback(String name, Runnable callback) { public void registerDestructionCallback(String name, Runnable callback) {
throw new IllegalStateException("Not supposed to be called"); throw new IllegalStateException("Not supposed to be called");
@ -368,10 +363,6 @@ class ScopingTests {
return beans.remove(name); return beans.remove(name);
} }
@Override
public Object resolveContextualObject(String key) {
return null;
}
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2024 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -83,16 +83,6 @@ class Spr10744Tests {
@Override @Override
public void registerDestructionCallback(String name, Runnable callback) { public void registerDestructionCallback(String name, Runnable callback) {
} }
@Override
public Object resolveContextualObject(String key) {
return null;
}
@Override
public String getConversationId() {
return null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2024 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -1090,16 +1090,6 @@ class AnnotationDrivenEventListenerTests {
@Override @Override
public void registerDestructionCallback(String name, Runnable callback) { public void registerDestructionCallback(String name, Runnable callback) {
} }
@Override
public Object resolveContextualObject(String key) {
return null;
}
@Override
public String getConversationId() {
return null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2024 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -94,10 +94,6 @@ class ApplicationContextExpressionTests {
return null; return null;
} }
} }
@Override
public String getConversationId() {
return null;
}
}); });
ac.getBeanFactory().setConversionService(new DefaultConversionService()); ac.getBeanFactory().setConversionService(new DefaultConversionService());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2024 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -1214,21 +1214,11 @@ class TestScope implements Scope {
public void registerDestructionCallback(String name, Runnable callback) { public void registerDestructionCallback(String name, Runnable callback) {
} }
@Override
public String getConversationId() {
return null;
}
@Override @Override
public Object get(String name, ObjectFactory<?> objectFactory) { public Object get(String name, ObjectFactory<?> objectFactory) {
instanceCount++; instanceCount++;
return objectFactory.getObject(); return objectFactory.getObject();
} }
@Override
public Object resolveContextualObject(String s) {
return null;
}
} }
class BirthdayCardSender { class BirthdayCardSender {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -68,20 +68,10 @@ public class SimpleMapScope implements Scope, Serializable {
this.callbacks.add(callback); this.callbacks.add(callback);
} }
@Override
public Object resolveContextualObject(String key) {
return null;
}
public void close() { public void close() {
for (Runnable runnable : this.callbacks) { for (Runnable runnable : this.callbacks) {
runnable.run(); runnable.run();
} }
} }
@Override
public String getConversationId() {
return null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -70,11 +70,6 @@ public class SimpSessionScope implements Scope {
SimpAttributesContextHolder.currentAttributes().registerDestructionCallback(name, callback); SimpAttributesContextHolder.currentAttributes().registerDestructionCallback(name, callback);
} }
@Override
public @Nullable Object resolveContextualObject(String key) {
return null;
}
@Override @Override
public String getConversationId() { public String getConversationId() {
return SimpAttributesContextHolder.currentAttributes().getSessionId(); return SimpAttributesContextHolder.currentAttributes().getSessionId();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -81,11 +81,6 @@ public class SimpleTransactionScope implements Scope {
} }
} }
@Override
public @Nullable Object resolveContextualObject(String key) {
return null;
}
@Override @Override
public @Nullable String getConversationId() { public @Nullable String getConversationId() {
return TransactionSynchronizationManager.getCurrentTransactionName(); return TransactionSynchronizationManager.getCurrentTransactionName();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
package org.springframework.web.context.request; package org.springframework.web.context.request;
import org.jspecify.annotations.Nullable;
/** /**
* Request-backed {@link org.springframework.beans.factory.config.Scope} * Request-backed {@link org.springframework.beans.factory.config.Scope}
* implementation. * implementation.
@ -44,13 +42,4 @@ public class RequestScope extends AbstractRequestAttributesScope {
return RequestAttributes.SCOPE_REQUEST; 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;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -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. * Invoke all registered destruction callbacks.
* To be called on ServletContext shutdown. * To be called on ServletContext shutdown.