Author: pnedonosko
Date: 2010-02-10 05:31:35 -0500 (Wed, 10 Feb 2010)
New Revision: 1752
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DialectDetecter.java
Log:
EXOJCR-470
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-02-10
10:05:55 UTC (rev 1751)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-02-10
10:31:35 UTC (rev 1752)
@@ -69,6 +69,8 @@
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.sql.Connection;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -280,12 +282,30 @@
try
{
DataSource dataSource = (DataSource)new
InitialContext().lookup(dataSourceName);
- dialect = DialectDetecter.detect(dataSource);
+ if (dataSource == null)
+ {
+ throw new RepositoryException("DataSource (" + dataSourceName +
") can't be null");
+ }
+
+ Connection jdbcConn = null;
+ try
+ {
+ jdbcConn = dataSource.getConnection();
+ dialect = DialectDetecter.detect(jdbcConn.getMetaData());
+ }
+ finally
+ {
+ if (jdbcConn != null && !jdbcConn.isClosed())
+ {
+ jdbcConn.close();
+ }
+ }
}
catch (Exception e)
{
throw new RepositoryException("Error configuring JDBC cache
loader", e);
}
+
// default values, will be overridden with types suitable for concrete data
base.
String blobType = "BLOB";
String charType = "VARCHAR(512)";
@@ -325,12 +345,8 @@
{
blobType = "long byte";
}
- // GENERIC or DB2
- else
- {
- charType = "VARCHAR(512)";
- blobType = "BLOB";
- }
+ // else GENERIC, DB2 etc
+
// set parameters if not defined
if (parameterEntry.getParameterValue(JBOSSCACHE_JDBC_CL_NODE_COLUMN, null) ==
null)
@@ -342,7 +358,6 @@
{
parameterEntry.putParameterValue(JBOSSCACHE_JDBC_CL_FQN_COLUMN, charType);
}
-
}
}
@@ -362,7 +377,8 @@
}
return;
}
- CacheLoaderManager clm = ((CacheSPI<Serializable,
Object>)cache).getComponentRegistry().getComponent(CacheLoaderManager.class);
+ CacheLoaderManager clm =
+ ((CacheSPI<Serializable,
Object>)cache).getComponentRegistry().getComponent(CacheLoaderManager.class);
if (clm == null)
{
log.error("The CacheLoaderManager cannot be found");
@@ -374,7 +390,7 @@
log.error("The CacheLoader cannot be found");
return;
}
-
+
ControllerCacheLoader ccl = new ControllerCacheLoader(currentCL);
List<IndividualCacheLoaderConfig> newConfig = new
ArrayList<IndividualCacheLoaderConfig>(1);
// create CacheLoaderConfig
@@ -386,7 +402,7 @@
cclConfig.setAsync(false);
cclConfig.setIgnoreModifications(false);
CacheLoaderConfig.IndividualCacheLoaderConfig first =
config.getFirstCacheLoaderConfig();
- cclConfig.setPurgeOnStartup(first != null && first.isPurgeOnStartup());
+ cclConfig.setPurgeOnStartup(first != null && first.isPurgeOnStartup());
newConfig.add(cclConfig);
config.setIndividualCacheLoaderConfigs(newConfig);
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2010-02-10
10:05:55 UTC (rev 1751)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2010-02-10
10:31:35 UTC (rev 1752)
@@ -253,6 +253,10 @@
// Dialects
/**
+ * DB_DIALECT_AUTO.
+ */
+ public final static String DB_DIALECT_AUTO = "Auto".intern();
+ /**
* DB_DIALECT_GENERIC.
*/
public final static String DB_DIALECT_GENERIC = "Generic".intern();
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DialectDetecter.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DialectDetecter.java 2010-02-10
10:05:55 UTC (rev 1751)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DialectDetecter.java 2010-02-10
10:31:35 UTC (rev 1752)
@@ -128,35 +128,4 @@
return DBConstants.DB_DIALECT_GENERIC;
}
-
- /**
- * Tries to detect dialect of DataSource
- *
- * @param dataSourceName
- * @return
- * @throws RepositoryException
- */
- public static String detect(DataSource dataSource) throws SQLException
- {
- // if no datasource provided
- if (dataSource == null)
- {
- throw new SQLException("DataSource can't be null");
- }
- // try to detect dialect
- Connection jdbcConn = null;
- try
- {
- jdbcConn = dataSource.getConnection();
- return detect(jdbcConn.getMetaData());
- }
- finally
- {
- if (jdbcConn != null && !jdbcConn.isClosed())
- {
- jdbcConn.close();
- }
- }
-
- }
}