IN PROGRESS - issue BATCH-7: Remove transaction synchronization and state management from input/output sources (formerly buffering)

http://jira.springframework.org/browse/BATCH-7

Remove GenericStreamContext
This commit is contained in:
dsyer
2008-02-02 15:16:20 +00:00
parent d1ab2086a6
commit 2d1ccb0cc6
30 changed files with 60 additions and 151 deletions

View File

@@ -27,7 +27,6 @@ import org.springframework.batch.io.Skippable;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.reader.AbstractItemStreamItemReader;
import org.springframework.batch.item.stream.GenericStreamContext;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
@@ -180,8 +179,7 @@ public class HibernateCursorItemReader extends AbstractItemStreamItemReader impl
props.setProperty(RESTART_DATA_ROW_NUMBER_KEY, "" + currentProcessedRow);
String skipped = skippedRows.toString();
props.setProperty(SKIPPED_ROWS, skipped.substring(1, skipped.length() - 1));
return new GenericStreamContext(props);
return new StreamContext(props);
}
/**

View File

@@ -33,7 +33,6 @@ import org.springframework.batch.io.support.AbstractTransactionalIoSource;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.KeyedItemReader;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.stream.GenericStreamContext;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataAccessException;
@@ -393,7 +392,7 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen
*/
public StreamContext getStreamContext() {
String skipped = skippedRows.toString();
StreamContext context = new GenericStreamContext();
StreamContext context = new StreamContext();
context.putString(SKIPPED_ROWS, skipped.substring(1, skipped.length() - 1));
context.putLong(CURRENT_PROCESSED_ROW, currentProcessedRow);
context.putLong(SKIP_COUNT, skipCount);

View File

@@ -13,7 +13,6 @@ import java.util.Properties;
import java.util.Map.Entry;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.stream.GenericStreamContext;
import org.springframework.core.CollectionFactory;
import org.springframework.jdbc.core.ColumnMapRowMapper;
import org.springframework.jdbc.core.PreparedStatementSetter;
@@ -60,7 +59,7 @@ public class ColumnMapStreamContextRowMapper extends ColumnMapRowMapper implemen
}
private static class ColumnMapStreamContext extends GenericStreamContext {
private static class ColumnMapStreamContext extends StreamContext {
private final Map keys;

View File

@@ -6,7 +6,6 @@ import java.util.Properties;
import org.springframework.batch.io.driving.DrivingQueryItemReader;
import org.springframework.batch.io.driving.KeyGenerator;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.stream.GenericStreamContext;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.util.Assert;
@@ -48,7 +47,7 @@ public class IbatisKeyGenerator implements KeyGenerator {
Properties props = new Properties();
props.setProperty(RESTART_KEY, key.toString());
return new GenericStreamContext(props);
return new StreamContext(props);
}
/**

View File

@@ -17,12 +17,10 @@ package org.springframework.batch.io.driving.support;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang.ClassUtils;
import org.springframework.batch.io.driving.KeyGenerator;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.stream.GenericStreamContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SingleColumnRowMapper;
@@ -101,12 +99,10 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator {
* @throws IllegalArgumentException if key is null.
*/
public StreamContext getKeyAsStreamContext(Object key) {
Assert.notNull(key, "The key must not be null.");
Properties props = new Properties();
props.setProperty(RESTART_KEY, key.toString());
return new GenericStreamContext(props);
StreamContext context = new StreamContext();
context.putString(RESTART_KEY, key.toString());
return context;
}
/**

View File

@@ -35,7 +35,6 @@ import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.StreamException;
import org.springframework.batch.item.stream.GenericStreamContext;
import org.springframework.batch.item.writer.ItemTransformer;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
@@ -72,7 +71,7 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements
private Resource resource;
private StreamContext streamContext = new GenericStreamContext(new Properties());
private StreamContext streamContext = new StreamContext();
private OutputState state = null;

View File

@@ -41,6 +41,10 @@ public class StreamContext {
map = new HashMap();
}
public StreamContext(Map map) {
this.map = map;
}
public void putString(String key, String value) {
Assert.notNull(value);

View File

@@ -1,40 +0,0 @@
/*
* Copyright 2006-2007 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.
*/
package org.springframework.batch.item.stream;
import java.util.Iterator;
import java.util.Properties;
import java.util.Map.Entry;
import org.springframework.batch.item.StreamContext;
public class GenericStreamContext extends StreamContext {
public GenericStreamContext() {
super();
}
public GenericStreamContext(Properties data) {
super();
if (data != null) {
for (Iterator it = data.entrySet().iterator(); it.hasNext();) {
Entry entry = (Entry) it.next();
putString(entry.getKey().toString(), entry.getValue().toString());
}
}
}
}

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.batch.item.stream;
import java.util.Properties;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.StreamException;
@@ -53,7 +51,7 @@ public class ItemStreamAdapter implements ItemStream {
* @see org.springframework.batch.item.StreamContextProvider#getStreamContext()
*/
public StreamContext getStreamContext() {
return new GenericStreamContext(new Properties());
return new StreamContext();
}
/* (non-Javadoc)

View File

@@ -107,7 +107,7 @@ public class SimpleStreamManager implements StreamManager {
}
}
}
return new GenericStreamContext(result);
return new StreamContext(result);
}
/**

View File

@@ -1,12 +1,9 @@
package org.springframework.batch.item.writer;
import java.util.Properties;
import org.springframework.batch.io.Skippable;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.StreamContext;
import org.springframework.batch.item.stream.GenericStreamContext;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
@@ -60,7 +57,7 @@ public class DelegatingItemWriter implements ItemWriter, Skippable, Initializing
return ((ItemStream) writer).getStreamContext();
}
else {
return new GenericStreamContext(new Properties());
return new StreamContext();
}
}