001/*
002 * Copyright 2014 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.springframework.batch.sample.jsr352;
017
018import org.apache.commons.logging.Log;
019import org.apache.commons.logging.LogFactory;
020import org.springframework.batch.core.StepContribution;
021import org.springframework.batch.core.scope.context.ChunkContext;
022import org.springframework.batch.core.step.tasklet.Tasklet;
023import org.springframework.batch.repeat.RepeatStatus;
024
025import javax.batch.api.BatchProperty;
026import javax.inject.Inject;
027
028/**
029 * <p>
030 * Sample {@link org.springframework.batch.core.step.tasklet.Tasklet} implementation.
031 * </p>
032 *
033 * @since 3.0
034 * @author Chris Schaefer
035 */
036public class JsrSampleTasklet implements Tasklet {
037        private static final Log LOG = LogFactory.getLog(JsrSampleTasklet.class);
038
039        @Inject
040        @BatchProperty
041        private String remoteServiceURL;
042
043        @Override
044        public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
045                LOG.info("Calling remote service at: " + remoteServiceURL);
046
047                Thread.sleep(2000);
048
049                LOG.info("Remote service call complete");
050
051                return RepeatStatus.FINISHED;
052        }
053}