From 723cbaf65030ce7bb78a3586ceb3bccd622673aa Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Wed, 17 Jan 2007 17:15:44 +0000 Subject: Patch for bug 1637484 from Matt Tucker: Invalid class names generated for JdbcSupportStrategy --- pom.xml | 6 ++++++ .../carbonado/repo/jdbc/JDBCSupportStrategy.java | 20 +++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 05a9eff..ec4ae4e 100644 --- a/pom.xml +++ b/pom.xml @@ -87,6 +87,12 @@ + + + Matt Tucker + + + org.cojen diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCSupportStrategy.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCSupportStrategy.java index b5d900a..f9ca221 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCSupportStrategy.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCSupportStrategy.java @@ -41,19 +41,29 @@ import com.amazon.carbonado.spi.SequenceValueProducer; * Allows database product specific features to be abstracted. * * @author Brian S O'Neill + * @author bcastill + * @author Matt Tucker */ class JDBCSupportStrategy { private static final int BLOB_BUFFER_SIZE = 4000; private static final int CLOB_BUFFER_SIZE = 2000; + /** + * Create a strategy based on the name of the database product. + * If one can't be found by product name the default will be used. + */ + @SuppressWarnings("unchecked") static JDBCSupportStrategy createStrategy(JDBCRepository repo) { - String databaseProductName = repo.getDatabaseProductName(); + String databaseProductName = repo.getDatabaseProductName().trim(); if (databaseProductName != null && databaseProductName.length() > 0) { + String strategyName = Character.toUpperCase(databaseProductName.charAt(0)) + + databaseProductName.substring(1).toLowerCase(); + if (strategyName.indexOf(' ') > 0) { + strategyName = strategyName.substring(0, strategyName.indexOf(' ')); + } + strategyName = strategyName.replaceAll("[^A-Za-z0-9]", ""); String className = - "com.amazon.carbonado.repo.jdbc." + - Character.toUpperCase(databaseProductName.charAt(0)) + - databaseProductName.substring(1).toLowerCase() + - "SupportStrategy"; + "com.amazon.carbonado.repo.jdbc." + strategyName + "SupportStrategy"; try { Class clazz = (Class) Class.forName(className); -- cgit v1.2.3