BATCH-810: added mainframe incrementer as "db2zos"

This commit is contained in:
trisberg
2008-09-25 13:57:45 +00:00
parent 06707281fd
commit c95985ec04
3 changed files with 23 additions and 24 deletions

View File

@@ -457,7 +457,7 @@
&lt;/bean&gt;</programlisting>
<para>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".</para>
</section>

View File

@@ -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 };
}
}

View File

@@ -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);
}