Author: pnedonosko
Date: 2010-02-10 07:16:57 -0500 (Wed, 10 Feb 2010)
New Revision: 1754
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
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/jdbc/LockJDBCContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-485 auto dialect added
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-02-10
11:55:17 UTC (rev 1753)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-02-10
12:16:57 UTC (rev 1754)
@@ -124,7 +124,7 @@
this.sourceName = sourceNameParam;
String dialect = params.getProperty(PARAM_DIALECT);
- if (dialect == null)
+ if (dialect == null || DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(dialect))
{
Connection conn = null;
try
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
11:55:17 UTC (rev 1753)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-02-10
12:16:57 UTC (rev 1754)
@@ -132,7 +132,7 @@
/**
* Logger
*/
- private final Log log =
ExoLogger.getLogger("jcr.lock.CacheableLockManagerImpl");
+ private final Log LOG =
ExoLogger.getLogger("jcr.lock.CacheableLockManagerImpl");
/**
* Data manager.
@@ -245,6 +245,7 @@
// create cache using custom factory
ExoJBossCacheFactory<Serializable, Object> factory =
new ExoJBossCacheFactory<Serializable, Object>(cfm,
transactionManager);
+
// configure cache loader parameters with correct DB data-types
configureJDBCCacheLoader(config.getLockManager());
@@ -297,7 +298,14 @@
{
if (jdbcConn != null && !jdbcConn.isClosed())
{
- jdbcConn.close();
+ try
+ {
+ jdbcConn.close();
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException("Error of connection close",
e);
+ }
}
}
}
@@ -346,7 +354,6 @@
blobType = "long byte";
}
// else GENERIC, DB2 etc
-
// set parameters if not defined
if (parameterEntry.getParameterValue(JBOSSCACHE_JDBC_CL_NODE_COLUMN, null) ==
null)
@@ -359,6 +366,10 @@
parameterEntry.putParameterValue(JBOSSCACHE_JDBC_CL_FQN_COLUMN, charType);
}
}
+ else
+ {
+ LOG.warn("CacheLoader DataSource " + JBOSSCACHE_JDBC_CL_DATASOURCE +
" is not configured.");
+ }
}
/**
@@ -371,9 +382,9 @@
List<IndividualCacheLoaderConfig> oldConfigs;
if (config == null || (oldConfigs = config.getIndividualCacheLoaderConfigs()) ==
null || oldConfigs.isEmpty())
{
- if (log.isInfoEnabled())
+ if (LOG.isInfoEnabled())
{
- log.info("No cache loader has been defined, thus no need to encapsulate
any cache loader.");
+ LOG.info("No cache loader has been defined, thus no need to encapsulate
any cache loader.");
}
return;
}
@@ -381,13 +392,13 @@
((CacheSPI<Serializable,
Object>)cache).getComponentRegistry().getComponent(CacheLoaderManager.class);
if (clm == null)
{
- log.error("The CacheLoaderManager cannot be found");
+ LOG.error("The CacheLoaderManager cannot be found");
return;
}
CacheLoader currentCL = clm.getCacheLoader();
if (currentCL == null)
{
- log.error("The CacheLoader cannot be found");
+ LOG.error("The CacheLoader cannot be found");
return;
}
@@ -406,9 +417,9 @@
newConfig.add(cclConfig);
config.setIndividualCacheLoaderConfigs(newConfig);
- if (log.isInfoEnabled())
+ if (LOG.isInfoEnabled())
{
- log.info("The configured cache loader has been encapsulated
successfully");
+ LOG.info("The configured cache loader has been encapsulated
successfully");
}
}
@@ -540,7 +551,7 @@
case ExtendedEvent.LOCK :
if (currChangesLog.getSize() < 2)
{
- log.error("Incorrect changes log of type ExtendedEvent.LOCK
size=" + currChangesLog.getSize()
+ LOG.error("Incorrect changes log of type ExtendedEvent.LOCK
size=" + currChangesLog.getSize()
+ "<2 \n" + currChangesLog.dump());
break;
}
@@ -554,13 +565,13 @@
}
else
{
- log.error("Lock must exist in pending locks.");
+ LOG.error("Lock must exist in pending locks.");
}
break;
case ExtendedEvent.UNLOCK :
if (currChangesLog.getSize() < 2)
{
- log.error("Incorrect changes log of type ExtendedEvent.UNLOCK
size=" + currChangesLog.getSize()
+ LOG.error("Incorrect changes log of type ExtendedEvent.UNLOCK
size=" + currChangesLog.getSize()
+ "<2 \n" + currChangesLog.dump());
break;
}
@@ -596,7 +607,7 @@
}
catch (IllegalStateException e)
{
- log.error(e.getLocalizedMessage(), e);
+ LOG.error(e.getLocalizedMessage(), e);
}
}
@@ -610,7 +621,7 @@
}
catch (LockException e)
{
- log.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
}
}
}
@@ -857,7 +868,7 @@
}
catch (NoSuchAlgorithmException e)
{
- log.error("Can't get instanse of MD5 MessageDigest!", e);
+ LOG.error("Can't get instanse of MD5 MessageDigest!", e);
}
return hash;
}
@@ -1030,15 +1041,15 @@
{
//TODO EXOJCR-412, should be refactored in future.
//Skip property not found in DB, because that lock property was removed in other
node of cluster.
- if (log.isDebugEnabled())
+ if (LOG.isDebugEnabled())
{
- log.debug("The propperty was removed in other node of cluster.",
e);
+ LOG.debug("The propperty was removed in other node of cluster.",
e);
}
}
catch (RepositoryException e)
{
- log.error("Error occur during removing lock" +
e.getLocalizedMessage(), e);
+ LOG.error("Error occur during removing lock" +
e.getLocalizedMessage(), e);
}
}
@@ -1094,7 +1105,7 @@
}
catch (Exception e)
{
- log.warn("Cannot suspend the current transaction", e);
+ LOG.warn("Cannot suspend the current transaction", e);
}
}
return action.execute(arg);
@@ -1109,7 +1120,7 @@
}
catch (Exception e)
{
- log.warn("Cannot resume the current transaction", e);
+ LOG.warn("Cannot resume the current transaction", e);
}
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/LockJDBCContainer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/LockJDBCContainer.java 2010-02-10
11:55:17 UTC (rev 1753)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/LockJDBCContainer.java 2010-02-10
12:16:57 UTC (rev 1754)
@@ -72,7 +72,7 @@
jdbcConn = dataSource.getConnection();
// if table not exists, create it
// connection is closed by DB initializer
- initDatabase(dataSourceName, jdbcConn,
DialectDetecter.detect(jdbcConn.getMetaData()));
+ initDatabase(dataSourceName, jdbcConn);
}
catch (SQLException e)
{
@@ -149,11 +149,10 @@
/**
* Creates table in DB if not present
*
- * @param dialect
* @throws IOException
* @throws DBInitializerException
*/
- protected void initDatabase(String dataSource, Connection jdbcConn, String dialect)
throws IOException,
+ protected void initDatabase(String dataSource, Connection jdbcConn) throws
IOException,
DBInitializerException
{
DBInitializer dbInitializer = new DBInitializer(dataSource, jdbcConn,
"/conf/storage/jcr-lock-jdbc.sql");
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-02-10
11:55:17 UTC (rev 1753)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-02-10
12:16:57 UTC (rev 1754)
@@ -235,7 +235,7 @@
this.dbSourceName = null;
LOG.info("Connect to JCR database as user '" + this.dbUserName +
"'");
- if (pDbDialect == DBConstants.DB_DIALECT_GENERIC)
+ if (pDbDialect == DBConstants.DB_DIALECT_GENERIC ||
DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(pDbDialect))
{
// try to detect via JDBC metadata
Connection jdbcConn = null;
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-02-10
11:55:17 UTC (rev 1753)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-02-10
12:16:57 UTC (rev 1754)
@@ -148,7 +148,7 @@
DatabaseMetaData dbMetaData = conn.getMetaData();
String dialect = props.getProperty(JDBC_DIALECT_PARAM);
- if (dialect == null)
+ if (dialect == null ||
DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(dialect))
{
dialect = DialectDetecter.detect(dbMetaData);
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2010-02-10
11:55:17 UTC (rev 1753)
+++
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2010-02-10
12:16:57 UTC (rev 1754)
@@ -175,6 +175,7 @@
<properties-param>
<name>working-conf</name>
<description>working-conf</description>
+ <property name="dialect" value="auto" />
<property name="source-name" value="jdbcjcr"/>
<property name="persister-class-name"
value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister"/>
</properties-param>
Modified:
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-02-10
11:55:17 UTC (rev 1753)
+++
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-02-10
12:16:57 UTC (rev 1754)
@@ -33,6 +33,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr"
/>
+ <property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false"
/>
<property name="max-buffer-size" value="200k"
/>
@@ -45,6 +46,7 @@
<property name="digest-algo"
value="MD5" />
<property name="vcas-type"
value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
<property name="jdbc-source-name"
value="jdbcjcr" />
+ <property name="jdbc-dialect"
value="auto" />
</properties>
<filters>
<filter property-type="Binary" />
@@ -97,6 +99,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr1"
/>
+ <property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false"
/>
<property name="max-buffer-size" value="200k"
/>
@@ -149,6 +152,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr2"
/>
+ <property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false"
/>
<property name="max-buffer-size" value="200k"
/>
@@ -203,6 +207,7 @@
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr3" />
+ <property name="dialect" value="auto"
/>
<property name="multi-db" value="true" />
<property name="update-storage" value="false" />
<property name="max-buffer-size" value="200k" />
@@ -295,6 +300,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name"
value="jdbcjcrtck" />
+ <property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false"
/>
<property name="max-buffer-size" value="200k"
/>
@@ -354,6 +360,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name"
value="jdbcjcr1tck" />
+ <property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false"
/>
<property name="max-buffer-size" value="200k"
/>
@@ -412,6 +419,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name"
value="jdbcjcr2tck" />
+ <property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false"
/>
<property name="max-buffer-size" value="200k"
/>