From 8391f07728efafff58deeaee57d25819a9ec9844 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 9 Jan 2025 13:34:20 -0500 Subject: [PATCH] Remove `@Deprecated` classes --- ...ervationPropagationChannelInterceptor.java | 88 ------------------- .../expression/ControlBusMethodFilter.java | 69 --------------- .../jsr223/PythonScriptExecutor.java | 75 ---------------- 3 files changed, 232 deletions(-) delete mode 100644 spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ObservationPropagationChannelInterceptor.java delete mode 100644 spring-integration-core/src/main/java/org/springframework/integration/expression/ControlBusMethodFilter.java delete mode 100644 spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutor.java diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ObservationPropagationChannelInterceptor.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ObservationPropagationChannelInterceptor.java deleted file mode 100644 index 97f32885fa..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ObservationPropagationChannelInterceptor.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.channel.interceptor; - -import io.micrometer.common.lang.Nullable; -import io.micrometer.observation.Observation; -import io.micrometer.observation.ObservationRegistry; - -import org.springframework.aop.support.AopUtils; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageHandler; -import org.springframework.util.Assert; - -/** - * The {@link org.springframework.messaging.support.ExecutorChannelInterceptor} - * implementation responsible for an {@link Observation} propagation from one message - * flow's thread to another through the {@link MessageChannel}s involved in the flow. - * Opens a new {@link Observation.Scope} on another thread and cleans up it in the end. - *

- * NOTE: This interceptor is proven to be wrong since an existing observation usually is closed - * on the sender side before the message is consumed on the receiver side. - * Therefore, it is better to have a {@code sender} observation on this channel, - * and then {@code receiver} observation on a subscriber for this channel. - * This way a tracing information is stored into message headers passing this channel. - * Such an approach also eliminate a problem with persistent message channels where - * an {@link Observation} is not serializable to be stored into database as a part of the message. - * - * @author Artem Bilan - * - * @since 6.0 - * - * @deprecated since 6.1.7 for removal in 6.4 in favor of enabling observation on the channel and its consumer. - */ -@Deprecated(since = "6.1.7", forRemoval = true) -public class ObservationPropagationChannelInterceptor extends ThreadStatePropagationChannelInterceptor { - - private final ThreadLocal scopes = new ThreadLocal<>(); - - private final ObservationRegistry observationRegistry; - - public ObservationPropagationChannelInterceptor(ObservationRegistry observationRegistry) { - Assert.notNull(observationRegistry, "'observationRegistry' must noty be null"); - this.observationRegistry = observationRegistry; - } - - @Override - @Nullable - protected Observation obtainPropagatingContext(Message message, MessageChannel channel) { - if (!DirectChannel.class.isAssignableFrom(AopUtils.getTargetClass(channel))) { - return this.observationRegistry.getCurrentObservation(); - } - return null; - } - - @Override - protected void populatePropagatedContext(@Nullable Observation state, Message message, MessageChannel channel) { - if (state != null) { - Observation.Scope scope = state.openScope(); - this.scopes.set(scope); - } - } - - @Override - public void afterMessageHandled(Message message, MessageChannel channel, MessageHandler handler, Exception ex) { - Observation.Scope scope = this.scopes.get(); - if (scope != null && scope.equals(this.observationRegistry.getCurrentObservationScope())) { - scope.close(); - this.scopes.remove(); - } - } - -} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/ControlBusMethodFilter.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/ControlBusMethodFilter.java deleted file mode 100644 index 1a8f8dd41a..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/expression/ControlBusMethodFilter.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2014-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.expression; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import org.springframework.context.Lifecycle; -import org.springframework.expression.MethodFilter; -import org.springframework.integration.core.Pausable; -import org.springframework.jmx.export.annotation.ManagedAttribute; -import org.springframework.jmx.export.annotation.ManagedOperation; -import org.springframework.util.CustomizableThreadCreator; -import org.springframework.util.ReflectionUtils; - -/** - * SpEL {@link MethodFilter} to restrict method invocations to: - *

- * This class isn't designed for target applications and typically is used from {@code ExpressionControlBusFactoryBean}. - * - * @author Mark Fisher - * @author Artem Bilan - * @author Gary Russell - * - * @since 4.0 - * - * @deprecated in favor of {@link org.springframework.integration.support.management.ControlBusMethodFilter} - */ -@Deprecated(since = "6.4", forRemoval = true) -public class ControlBusMethodFilter implements MethodFilter { - - private static final ReflectionUtils.MethodFilter CONTROL_BUS_METHOD_FILTER = - new org.springframework.integration.support.management.ControlBusMethodFilter(); - - @Override - public List filter(List methods) { - List supportedMethods = new ArrayList<>(); - for (Method method : methods) { - if (accept(method)) { - supportedMethods.add(method); - } - } - return supportedMethods; - } - - private boolean accept(Method method) { - return CONTROL_BUS_METHOD_FILTER.matches(method); - } - -} diff --git a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutor.java b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutor.java deleted file mode 100644 index cb0b463fa0..0000000000 --- a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutor.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2002-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.scripting.jsr223; - -import javax.script.Bindings; -import javax.script.ScriptEngine; - -/** - * A {@link org.springframework.integration.scripting.ScriptExecutor} - * that implements special handling required for Python to - * emulate behavior similar to other JSR223 scripting languages. - *

- * Script evaluation using the Jython implementation results in a null return - * value for normal variable expressions such as x=2. As a work around, it is - * necessary to get the value of 'x' explicitly following the script evaluation. This - * class performs simple parsing on the last line of the script to obtain the variable - * name, if any, and return its value. - * - * @author David Turanski - * @author Gary Russell - * @author Artem Bilan - * - * @since 2.1 - * - * @deprecated in favor of {@link org.springframework.integration.scripting.PolyglotScriptExecutor} - * with a {@code python} language argument. - */ -@Deprecated(forRemoval = true, since = "6.4") -public class PythonScriptExecutor extends AbstractScriptExecutor { - - public PythonScriptExecutor() { - super("python"); - } - - @Override - protected Object postProcess(Object result, ScriptEngine scriptEngine, String script, Bindings bindings) { - Object newResult = result; - if (newResult == null) { - String returnVariableName = PythonVariableParser.parseReturnVariable(script); - if (bindings != null) { - newResult = bindings.get(returnVariableName); - } - if (newResult == null) { - newResult = scriptEngine.get(returnVariableName); - } - } - return newResult; - } - - public static class PythonVariableParser { - - public static String parseReturnVariable(String script) { - String[] lines = script.trim().split("\n"); - String lastLine = lines[lines.length - 1]; - String[] tokens = lastLine.split("="); - return tokens[0].trim(); - } - - } - -}