summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-01-17 17:15:44 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-01-17 17:15:44 +0000
commit723cbaf65030ce7bb78a3586ceb3bccd622673aa (patch)
treee94a11a5e4cd545b5affcdb118d167d05ba5cc60 /src
parentcf123c8640a08a66740d9bfb35c8b133da6d3058 (diff)
Patch for bug 1637484 from Matt Tucker: Invalid class names generated for JdbcSupportStrategy
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCSupportStrategy.java20
1 files changed, 15 insertions, 5 deletions
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<JDBCSupportStrategy> clazz =
(Class<JDBCSupportStrategy>) Class.forName(className);