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 */
016package org.springframework.batch.item;
017
018import org.springframework.batch.item.util.ExecutionContextUserSupport;
019
020/**
021 * Empty method implementation of {@link ItemStream}.
022 *
023 * @author Dave Syer
024 * @author Dean de Bree
025 *
026 */
027public abstract class ItemStreamSupport implements ItemStream {
028
029        private final ExecutionContextUserSupport executionContextUserSupport = new ExecutionContextUserSupport();
030
031        /**
032         * No-op.
033         * @see org.springframework.batch.item.ItemStream#close()
034         */
035        @Override
036        public void close() {
037        }
038
039        /**
040         * No-op.
041         * @see org.springframework.batch.item.ItemStream#open(ExecutionContext)
042         */
043        @Override
044        public void open(ExecutionContext executionContext) {
045        }
046
047        /**
048         * Return empty {@link ExecutionContext}.
049         * @see org.springframework.batch.item.ItemStream#update(ExecutionContext)
050         */
051        @Override
052        public void update(ExecutionContext executionContext) {
053        }
054        
055        /**
056         * The name of the component which will be used as a stem for keys in the
057         * {@link ExecutionContext}. Subclasses should provide a default value, e.g.
058         * the short form of the class name.
059         * 
060         * @param name the name for the component
061         */
062        public void setName(String name) {
063                this.setExecutionContextName(name);
064        }
065
066        protected void setExecutionContextName(String name) {
067                executionContextUserSupport.setName(name);
068        }
069
070        public String getExecutionContextKey(String key) {
071                return executionContextUserSupport.getKey(key);
072        }
073
074}