001/*
002 * Copyright 2006-2013 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 */
016
017package org.springframework.batch.core.repository.dao;
018
019import java.util.Collection;
020
021import org.springframework.batch.core.JobExecution;
022import org.springframework.batch.core.StepExecution;
023import org.springframework.batch.item.ExecutionContext;
024
025/**
026 * DAO interface for persisting and retrieving {@link ExecutionContext}s.
027 * 
028 * @author Robert Kasanicky
029 * @author David Turanski
030 */
031public interface ExecutionContextDao {
032
033        /**
034         * @param jobExecution {@link JobExecution} instance that contains the context.
035         * @return execution context associated with the given jobExecution
036         */
037        ExecutionContext getExecutionContext(JobExecution jobExecution);
038
039        /**
040         * @param stepExecution {@link StepExecution} instance that contains the context.
041         * @return execution context associated with the given stepExecution
042         */
043        ExecutionContext getExecutionContext(StepExecution stepExecution);
044
045        /**
046         * Persist the execution context associated with the given jobExecution,
047         * persistent entry for the context should not exist yet.
048         *
049         * @param jobExecution {@link JobExecution} instance that contains the context.
050         */
051        void saveExecutionContext(final JobExecution jobExecution);
052
053        /**
054         * Persist the execution context associated with the given stepExecution,
055         * persistent entry for the context should not exist yet.
056         *
057         * @param stepExecution {@link StepExecution} instance that contains the context.
058         */
059        void saveExecutionContext(final StepExecution stepExecution);
060
061        /**
062         * Persist the execution context associated with each stepExecution in a given collection,
063         * persistent entry for the context should not exist yet.
064         *
065         * @param stepExecutions a collection of {@link StepExecution}s that contain
066         * the contexts.
067         */
068        void saveExecutionContexts(final Collection<StepExecution> stepExecutions);
069
070        /**
071         * Persist the updates of execution context associated with the given
072         * jobExecution. Persistent entry should already exist for this context.
073         *
074         * @param jobExecution {@link JobExecution} instance that contains the context.
075         */
076        void updateExecutionContext(final JobExecution jobExecution);
077
078        /**
079         * Persist the updates of execution context associated with the given
080         * stepExecution. Persistent entry should already exist for this context.
081         *
082         * @param stepExecution {@link StepExecution} instance that contains the context.
083         */
084        void updateExecutionContext(final StepExecution stepExecution);
085}