From c95985ec04b29691be8085505a5c10ead9f7ba8f Mon Sep 17 00:00:00 2001 From: trisberg Date: Thu, 25 Sep 2008 13:57:45 +0000 Subject: [PATCH] BATCH-810: added mainframe incrementer as "db2zos" --- docs/src/site/docbook/reference/execution.xml | 2 +- ...ltDataFieldMaxValueIncrementerFactory.java | 31 ++++++++++--------- ...aFieldMaxValueIncrementerFactoryTests.java | 14 ++++----- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/docs/src/site/docbook/reference/execution.xml b/docs/src/site/docbook/reference/execution.xml index 74b092770..e440570dc 100644 --- a/docs/src/site/docbook/reference/execution.xml +++ b/docs/src/site/docbook/reference/execution.xml @@ -457,7 +457,7 @@ </bean> The databaseType property indicates the type of incrementer that - must be used. Options include: "db2", "derby", "hsql", "mysql", + must be used. Options include: "db2", "db2zos", "derby", "hsql", "mysql", "oracle", and "postgres". diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java index 1ba00bee1..f629e6463 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java @@ -17,15 +17,7 @@ package org.springframework.batch.item.database.support; import javax.sql.DataSource; -import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer; +import org.springframework.jdbc.support.incrementer.*; /** * Default implementation of the {@link DataFieldMaxValueIncrementerFactory} @@ -51,6 +43,8 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV static final String DB_TYPE_DB2 = "db2"; + static final String DB_TYPE_DB2ZOS = "db2zos"; + static final String DB_TYPE_DERBY = "derby"; static final String DB_TYPE_HSQL = "hsql"; @@ -89,6 +83,9 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV if (DB_TYPE_DB2.equals(incrementerType)) { return new DB2SequenceMaxValueIncrementer(dataSource, incrementerName); } + else if (DB_TYPE_DB2ZOS.equals(incrementerType)) { + return new DB2MainframeSequenceMaxValueIncrementer(dataSource, incrementerName); + } else if (DB_TYPE_DERBY.equals(incrementerType)) { return new DerbyMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName); } @@ -115,11 +112,15 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV } public boolean isSupportedIncrementerType(String incrementerType) { - if (!DB_TYPE_DB2.equals(incrementerType) && !DB_TYPE_DERBY.equals(incrementerType) - && !DB_TYPE_HSQL.equals(incrementerType) && !DB_TYPE_MYSQL.equals(incrementerType) - && !DB_TYPE_ORACLE.equals(incrementerType) && !DB_TYPE_POSTGRES.equals(incrementerType) - && !DB_TYPE_SQLSERVER.equals(incrementerType) && !DB_TYPE_SYBASE.equals(incrementerType)) { - + if (!DB_TYPE_DB2.equals(incrementerType) + && !DB_TYPE_DB2ZOS.equals(incrementerType) + && !DB_TYPE_DERBY.equals(incrementerType) + && !DB_TYPE_HSQL.equals(incrementerType) + && !DB_TYPE_MYSQL.equals(incrementerType) + && !DB_TYPE_ORACLE.equals(incrementerType) + && !DB_TYPE_POSTGRES.equals(incrementerType) + && !DB_TYPE_SQLSERVER.equals(incrementerType) + && !DB_TYPE_SYBASE.equals(incrementerType)) { return false; } else { @@ -128,7 +129,7 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV } public String[] getSupportedIncrementerTypes() { - return new String[] { DB_TYPE_DB2, DB_TYPE_DERBY, DB_TYPE_HSQL, DB_TYPE_MYSQL, + return new String[] { DB_TYPE_DB2, DB_TYPE_DB2ZOS, DB_TYPE_DERBY, DB_TYPE_HSQL, DB_TYPE_MYSQL, DB_TYPE_ORACLE, DB_TYPE_POSTGRES, DB_TYPE_SQLSERVER, DB_TYPE_SYBASE }; } } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java index 0c427b87d..7a0286ed8 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java @@ -20,14 +20,7 @@ import javax.sql.DataSource; import junit.framework.TestCase; import org.easymock.MockControl; -import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer; -import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer; +import org.springframework.jdbc.support.incrementer.*; /** * @author Lucas Ward @@ -49,6 +42,7 @@ public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase { public void testSupportedDatabaseType(){ assertTrue(factory.isSupportedIncrementerType("db2")); + assertTrue(factory.isSupportedIncrementerType("db2zos")); assertTrue(factory.isSupportedIncrementerType("mysql")); assertTrue(factory.isSupportedIncrementerType("derby")); assertTrue(factory.isSupportedIncrementerType("oracle")); @@ -86,6 +80,10 @@ public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase { assertTrue(factory.getIncrementer("db2", "NAME") instanceof DB2SequenceMaxValueIncrementer); } + public void testDb2zos(){ + assertTrue(factory.getIncrementer("db2zos", "NAME") instanceof DB2MainframeSequenceMaxValueIncrementer); + } + public void testMysql(){ assertTrue(factory.getIncrementer("mysql", "NAME") instanceof MySQLMaxValueIncrementer); }