From bcf4f724addc96c5beed2447ad9423008a3d6da8 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Mon, 9 Jun 2025 12:10:30 +0200 Subject: [PATCH] Deprecate unused APIs Related to #4847 Resolves #4866 --- .../batch/core/configuration/JobFactory.java | 5 +++-- .../batch/core/configuration/JobRegistry.java | 11 ++++++++++- .../batch/core/configuration/ListableJobLocator.java | 7 +++++-- .../AutomaticJobRegistrarBeanPostProcessor.java | 4 +++- .../annotation/EnableBatchProcessing.java | 4 ++++ .../support/AbstractApplicationContextFactory.java | 5 ++++- .../support/ApplicationContextFactory.java | 5 ++++- .../support/ApplicationContextJobFactory.java | 4 +++- .../configuration/support/AutomaticJobRegistrar.java | 4 +++- .../ClasspathXmlApplicationContextsFactoryBean.java | 5 +++-- .../core/configuration/support/DefaultJobLoader.java | 2 ++ .../support/GenericApplicationContextFactory.java | 5 ++++- .../support/JobFactoryRegistrationListener.java | 3 ++- .../batch/core/configuration/support/JobLoader.java | 5 ++++- .../configuration/support/ReferenceJobFactory.java | 6 ++++-- 15 files changed, 58 insertions(+), 17 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobFactory.java index dafe2035f..4512e5544 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2025 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. @@ -21,8 +21,9 @@ import org.springframework.batch.core.Job; * Strategy for creating a single job. * * @author Dave Syer - * + * @author Mahmoud Ben Hassine */ +@Deprecated(since = "6.0", forRemoval = true) public interface JobFactory { /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobRegistry.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobRegistry.java index a2029dee4..c29ce74f4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobRegistry.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobRegistry.java @@ -15,6 +15,8 @@ */ package org.springframework.batch.core.configuration; +import java.util.Collection; + import org.springframework.batch.core.Job; /** @@ -25,7 +27,14 @@ import org.springframework.batch.core.Job; * @author Mahmoud Ben Hassine * */ -public interface JobRegistry extends ListableJobLocator { +public interface JobRegistry extends JobLocator { + + /** + * Provides the currently registered job names. The return value is unmodifiable and + * disconnected from the underlying registry storage. + * @return a collection of String. Empty if none are registered. + */ + Collection getJobNames(); /** * Registers a {@link Job} at runtime. diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/ListableJobLocator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/ListableJobLocator.java index 0fe16eb21..74978678e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/ListableJobLocator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/ListableJobLocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2025 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. @@ -21,8 +21,11 @@ import java.util.Collection; * A listable extension of {@link JobLocator}. * * @author Dave Syer - * + * @author Mahmoud Ben Hassine + * @deprecated since 6.0, scheduled for removal in 6.2 or later. Use {@link JobRegistry} + * instead. */ +@Deprecated(since = "6.0", forRemoval = true) public interface ListableJobLocator extends JobLocator { /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/AutomaticJobRegistrarBeanPostProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/AutomaticJobRegistrarBeanPostProcessor.java index c8db9b731..36d054ffc 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/AutomaticJobRegistrarBeanPostProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/AutomaticJobRegistrarBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2025 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. @@ -30,7 +30,9 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; * * @author Mahmoud Ben Hassine * @since 5.0 + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) class AutomaticJobRegistrarBeanPostProcessor implements BeanFactoryPostProcessor, BeanPostProcessor { private ConfigurableListableBeanFactory beanFactory; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java index 61940215b..cb3829796 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java @@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.annotation; import org.springframework.batch.core.configuration.JobRegistry; import org.springframework.batch.core.configuration.support.ApplicationContextFactory; import org.springframework.batch.core.configuration.support.AutomaticJobRegistrar; +import org.springframework.batch.core.configuration.support.GroupAwareJob; import org.springframework.batch.core.configuration.support.ScopeConfiguration; import org.springframework.batch.core.converter.JobParametersConverter; import org.springframework.batch.core.repository.JobRepository; @@ -156,7 +157,10 @@ public @interface EnableBatchProcessing { * {@link ApplicationContextFactory}. * @return boolean indicating whether the configuration is going to be modularized * into multiple application contexts. Defaults to {@code false}. + * @deprecated since 6.0 in favor of Spring's context hierarchies and + * {@link GroupAwareJob}s. Scheduled for removal in 6.2 or later. */ + @Deprecated(since = "6.0", forRemoval = true) boolean modular() default false; /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java index 471c9de3c..3466e93cd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2023 the original author or authors. + * Copyright 2006-2025 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. @@ -47,7 +47,10 @@ import org.springframework.util.ClassUtils; * every time it is requested. It is lazily initialized and cached. Clients should ensure * that it is closed when it is no longer needed. If a path is not set, the parent is * always returned. + * + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public abstract class AbstractApplicationContextFactory implements ApplicationContextFactory, ApplicationContextAware { private static final Log logger = LogFactory.getLog(AbstractApplicationContextFactory.class); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextFactory.java index 764766197..b8cc1467c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2025 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. @@ -25,7 +25,10 @@ import org.springframework.context.ConfigurableApplicationContext; * primarily useful when creating a new {@link ApplicationContext} for a {@link Job}. * * @author Lucas Ward + * @author Mahmoud Ben Hassine + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public interface ApplicationContextFactory { ConfigurableApplicationContext createApplicationContext(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java index a60c6b961..7ed039e23 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2023 the original author or authors. + * Copyright 2006-2025 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. @@ -26,8 +26,10 @@ import org.springframework.context.ConfigurableApplicationContext; * * @author Dave Syer * @author Mahmoud Ben Hassine + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. * */ +@Deprecated(since = "6.0", forRemoval = true) public class ApplicationContextJobFactory implements JobFactory { private final Job job; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java index c76ee7b9d..a4338c768 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2023 the original author or authors. + * Copyright 2006-2025 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. @@ -42,7 +42,9 @@ import org.springframework.util.Assert; * @author Dave Syer * @author Mahmoud Ben Hassine * @since 2.1 + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public class AutomaticJobRegistrar implements Ordered, SmartLifecycle, ApplicationContextAware, InitializingBean { private final Collection applicationContextFactories = new ArrayList<>(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ClasspathXmlApplicationContextsFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ClasspathXmlApplicationContextsFactoryBean.java index 316c36452..810ffd65f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ClasspathXmlApplicationContextsFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ClasspathXmlApplicationContextsFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2025 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. @@ -35,8 +35,9 @@ import org.springframework.core.io.Resource; * * @author Dave Syer * @author Mahmoud Ben Hassine - * + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public class ClasspathXmlApplicationContextsFactoryBean implements FactoryBean, ApplicationContextAware { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java index aa671e6ef..4593371ac 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java @@ -46,7 +46,9 @@ import org.springframework.util.Assert; * @author Dave Syer * @author Stephane Nicoll * @author Mahmoud Ben Hassine + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public class DefaultJobLoader implements JobLoader, InitializingBean { private static final Log logger = LogFactory.getLog(DefaultJobLoader.class); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GenericApplicationContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GenericApplicationContextFactory.java index b523181ee..0e69248c7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GenericApplicationContextFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GenericApplicationContextFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2023 the original author or authors. + * Copyright 2006-2025 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. @@ -39,7 +39,10 @@ import java.util.List; * the child {@link ApplicationContext} is returned. The child context is not re-created * every time it is requested. It is lazily initialized and cached. Clients should ensure * that it is closed when it is no longer needed. + * + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public class GenericApplicationContextFactory extends AbstractApplicationContextFactory { /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListener.java index 2a2525068..b55ce50e7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListener.java @@ -28,8 +28,9 @@ import org.springframework.batch.core.configuration.JobRegistry; * * @author Dave Syer * @author Mahmoud Ben Hassine - * + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public class JobFactoryRegistrationListener { private final Log logger = LogFactory.getLog(getClass()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobLoader.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobLoader.java index e4821843f..33b0166aa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobLoader.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2025 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. @@ -22,8 +22,11 @@ import org.springframework.batch.core.configuration.DuplicateJobException; /** * @author Dave Syer + * @author Mahmoud Ben Hassine * @since 2.1 + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public interface JobLoader { /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java index 4664448c0..905cddbac 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2023 the original author or authors. + * Copyright 2006-2025 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. @@ -23,8 +23,10 @@ import org.springframework.batch.core.configuration.JobFactory; * {@link Job}. * * @author Dave Syer - * + * @author Mahmoud Ben Hassine + * @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later. */ +@Deprecated(since = "6.0", forRemoval = true) public class ReferenceJobFactory implements JobFactory { private final Job job;