Add JSR-305 annotations to public APIs
(Partially) Resolves BATCH-2688
This commit is contained in:
committed by
Michael Minella
parent
295def2b89
commit
70d0e3c510
@@ -25,7 +25,6 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.repeat.RepeatCallback;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -62,7 +61,6 @@ public abstract class StepContextRepeatCallback implements RepeatCallback {
|
||||
* @see RepeatCallback#doInIteration(RepeatContext)
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public RepeatStatus doInIteration(RepeatContext context) throws Exception {
|
||||
|
||||
// The StepContext has to be the same for all chunks,
|
||||
@@ -109,7 +107,6 @@ public abstract class StepContextRepeatCallback implements RepeatCallback {
|
||||
* @throws Exception implementations can throw an exception if anything goes
|
||||
* wrong
|
||||
*/
|
||||
@Nullable
|
||||
public abstract RepeatStatus doInChunkContext(RepeatContext context, ChunkContext chunkContext) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 the original author or authors.
|
||||
* Copyright 2006-2018 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.
|
||||
@@ -72,6 +72,7 @@ import java.util.concurrent.Semaphore;
|
||||
* @author Robert Kasanicky
|
||||
* @author Michael Minella
|
||||
* @author Will Schipp
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TaskletStep extends AbstractStep {
|
||||
@@ -283,7 +284,7 @@ public class TaskletStep extends AbstractStep {
|
||||
// caller
|
||||
interruptionPolicy.checkInterrupted(stepExecution);
|
||||
|
||||
return result;
|
||||
return result == null ? RepeatStatus.FINISHED : result;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -156,7 +156,6 @@ public class ExecutionContext implements Serializable {
|
||||
* @param key The key to get a value for
|
||||
* @return The <code>String</code> value
|
||||
*/
|
||||
@Nullable
|
||||
public String getString(String key) {
|
||||
|
||||
return (String) readAndValidate(key, String.class);
|
||||
@@ -171,7 +170,6 @@ public class ExecutionContext implements Serializable {
|
||||
* @return The <code>String</code> value if key is represented, specified
|
||||
* default otherwise
|
||||
*/
|
||||
@Nullable
|
||||
public String getString(String key, String defaultString) {
|
||||
if (!containsKey(key)) {
|
||||
return defaultString;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2018 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,22 +22,26 @@ import java.util.List;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Convenience class for accessing {@link ExecutionContext} values from job and
|
||||
* step executions.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.1.4
|
||||
*
|
||||
*/
|
||||
public class ExecutionContextTestUtils {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static <T> T getValueFromJob(JobExecution jobExecution, String key) {
|
||||
return (T) jobExecution.getExecutionContext().get(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T getValueFromStepInJob(JobExecution jobExecution, String stepName, String key) {
|
||||
StepExecution stepExecution = null;
|
||||
List<String> stepNames = new ArrayList<String>();
|
||||
@@ -58,6 +62,7 @@ public class ExecutionContextTestUtils {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static <T> T getValueFromStep(StepExecution stepExecution, String key) {
|
||||
return (T) stepExecution.getExecutionContext().get(key);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2018 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,6 +35,7 @@ import org.springframework.batch.core.step.StepLocator;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -62,6 +63,7 @@ import org.springframework.context.ApplicationContext;
|
||||
* @author Lucas Ward
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.1
|
||||
*/
|
||||
public class JobLauncherTestUtils {
|
||||
@@ -223,7 +225,7 @@ public class JobLauncherTestUtils {
|
||||
* loaded into the Job ExecutionContext prior to launching the step.
|
||||
* @return JobExecution
|
||||
*/
|
||||
public JobExecution launchStep(String stepName, JobParameters jobParameters, ExecutionContext jobExecutionContext) {
|
||||
public JobExecution launchStep(String stepName, JobParameters jobParameters, @Nullable ExecutionContext jobExecutionContext) {
|
||||
if (!(job instanceof StepLocator)) {
|
||||
throw new UnsupportedOperationException("Cannot locate step from a Job that is not a StepLocator: job="
|
||||
+ job.getName() + " does not implement StepLocator");
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
|
||||
Long count = 0L;
|
||||
|
||||
@Override
|
||||
public JobParameters getNext(JobParameters parameters) {
|
||||
public JobParameters getNext(@Nullable JobParameters parameters) {
|
||||
return new JobParameters(Collections.singletonMap("count", new JobParameter(count++)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2018 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,11 +25,14 @@ import java.util.Date;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Provides testing utilities to execute JSR-352 jobs and block until they are complete (since all JSR-352 based jobs
|
||||
* are executed asynchronously).
|
||||
*
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 3.0
|
||||
*/
|
||||
public class JsrTestUtils {
|
||||
@@ -110,6 +113,7 @@ public class JsrTestUtils {
|
||||
return execution;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Metric getMetric(StepExecution stepExecution, Metric.MetricType type) {
|
||||
Metric[] metrics = stepExecution.getMetrics();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2018 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.
|
||||
@@ -40,6 +40,7 @@ import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteExcep
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Utility class for executing steps outside of a {@link Job}. This is useful in
|
||||
@@ -61,6 +62,7 @@ import org.springframework.batch.item.ExecutionContext;
|
||||
*
|
||||
* @author Dan Garrette
|
||||
* @author Lucas Ward
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
* @see SimpleJob
|
||||
*/
|
||||
@@ -100,7 +102,7 @@ public class StepRunner {
|
||||
* loaded into the Job ExecutionContext prior to launching the step.
|
||||
* @return JobExecution
|
||||
*/
|
||||
public JobExecution launchStep(Step step, ExecutionContext jobExecutionContext) {
|
||||
public JobExecution launchStep(Step step, @Nullable ExecutionContext jobExecutionContext) {
|
||||
return this.launchStep(step, this.makeUniqueJobParameters(), jobExecutionContext);
|
||||
}
|
||||
|
||||
@@ -126,7 +128,7 @@ public class StepRunner {
|
||||
* loaded into the Job ExecutionContext prior to launching the step.
|
||||
* @return JobExecution
|
||||
*/
|
||||
public JobExecution launchStep(Step step, JobParameters jobParameters, final ExecutionContext jobExecutionContext) {
|
||||
public JobExecution launchStep(Step step, JobParameters jobParameters, @Nullable final ExecutionContext jobExecutionContext) {
|
||||
//
|
||||
// Create a fake job
|
||||
//
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2018 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* APIs for the configuration of Spring Batch test support.
|
||||
*
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.batch.test.context;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2018 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility classes for batch job/step testing.
|
||||
*
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.batch.test;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
Reference in New Issue
Block a user