| 1 | /* |
| 2 | * Copyright 2006-2013 the original author or authors. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.springframework.batch.item; |
| 17 | |
| 18 | import org.springframework.batch.item.util.ExecutionContextUserSupport; |
| 19 | |
| 20 | /** |
| 21 | * Empty method implementation of {@link ItemStream}. |
| 22 | * |
| 23 | * @author Dave Syer |
| 24 | * @author Dean de Bree |
| 25 | * |
| 26 | */ |
| 27 | public abstract class ItemStreamSupport implements ItemStream { |
| 28 | |
| 29 | private final ExecutionContextUserSupport executionContextUserSupport = new ExecutionContextUserSupport(); |
| 30 | |
| 31 | /** |
| 32 | * No-op. |
| 33 | * @see org.springframework.batch.item.ItemStream#close() |
| 34 | */ |
| 35 | @Override |
| 36 | public void close() { |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * No-op. |
| 41 | * @see org.springframework.batch.item.ItemStream#open(ExecutionContext) |
| 42 | */ |
| 43 | @Override |
| 44 | public void open(ExecutionContext executionContext) { |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Return empty {@link ExecutionContext}. |
| 49 | * @see org.springframework.batch.item.ItemStream#update(ExecutionContext) |
| 50 | */ |
| 51 | @Override |
| 52 | public void update(ExecutionContext executionContext) { |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * The name of the component which will be used as a stem for keys in the |
| 57 | * {@link ExecutionContext}. Subclasses should provide a default value, e.g. |
| 58 | * the short form of the class name. |
| 59 | * |
| 60 | * @param name the name for the component |
| 61 | */ |
| 62 | public void setName(String name) { |
| 63 | this.setExecutionContextName(name); |
| 64 | } |
| 65 | |
| 66 | protected void setExecutionContextName(String name) { |
| 67 | executionContextUserSupport.setName(name); |
| 68 | } |
| 69 | |
| 70 | public String getExecutionContextKey(String key) { |
| 71 | return executionContextUserSupport.getKey(key); |
| 72 | } |
| 73 | |
| 74 | } |