Author: pnedonosko
Date: 2009-11-24 10:28:15 -0500 (Tue, 24 Nov 2009)
New Revision: 832
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-201: loader cleanup; rely on JDBC storage impl
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-24
15:28:04 UTC (rev 831)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-24
15:28:15 UTC (rev 832)
@@ -62,8 +62,7 @@
/**
* Storage connections involved in transactions.
*/
- protected Map<Object, WorkspaceStorageConnection> transactions =
- new ConcurrentHashMap<Object, WorkspaceStorageConnection>();
+ protected Map<Object, JDBCStorageConnection> transactions = new
ConcurrentHashMap<Object, JDBCStorageConnection>();
private IndividualCacheLoaderConfig config;
@@ -93,12 +92,12 @@
* Apply all Modifications to JDBC database, but don't commite them.
*
* @param modifications List if Modification
- * @param conn WorkspaceStorageConnection
+ * @param conn JDBCStorageConnection
* @throws RepositoryException if error
*/
- protected void apply(WorkspaceStorageConnection conn, List<Modification>
modifications) throws RepositoryException
+ protected void apply(List<Modification> modifications, JDBCStorageConnection
conn) throws RepositoryException
{
- // Prepare modifications list.
+ // TODO Prepare modifications list.
// Will be added oldValueData to modification for UPDATE.
//prepareModifications(modifications);
@@ -119,7 +118,7 @@
}
break;
case PUT_KEY_VALUE :
- doUpdate(m, (JDBCStorageConnection)conn);
+ doUpdate(m, conn);
break;
case REMOVE_DATA :
if (LOG.isDebugEnabled())
@@ -134,16 +133,7 @@
}
break;
case REMOVE_NODE :
-
- // if (m.getFqn().get(0).equals(JBossCacheStorage.REFS))
- // {
- // removeReference((JDBCStorageConnection)conn, m);
- // }
- // else
- // {
- doRemove(m, (JDBCStorageConnection)conn);
- // }
-
+ doRemove(m, conn);
break;
case MOVE :
if (LOG.isDebugEnabled())
@@ -167,20 +157,21 @@
LOG.debug("Modifications list size = " + modifications.size());
}
- WorkspaceStorageConnection conn = dataContainer.openConnection();
+ JDBCStorageConnection conn =
(JDBCStorageConnection)dataContainer.openConnection();
+
try
{
- apply(conn, modifications);
+ apply(modifications, conn);
conn.commit();
}
catch (RepositoryException e)
{
- LOG.error("RepositoryException: ", e); // TODO don't catch
+ LOG.error("RepositoryException: ", e); // TODO don't catch, but be
sure it will be thrown to JCR
throw new RepositoryException(e);
}
catch (IllegalStateException e)
{
- LOG.error("IllegalStateException: ", e); // TODO don't catch
+ LOG.error("IllegalStateException: ", e); // TODO don't catch, but
be sure it will be thrown to JCR
throw new IllegalStateException(e);
}
finally
@@ -195,11 +186,10 @@
/**
* Remove NodeData or PropertyData.
*
- * @param modification
- * @param conn
- * @param identifier
- * @throws IllegalStateException
- * @throws RepositoryException
+ * @param modification Modification
+ * @param conn JDBCStorageConnection
+ * @throws IllegalStateException if connection closed
+ * @throws RepositoryException if error occurs
*/
private void doRemove(Modification modification, JDBCStorageConnection conn) throws
IllegalStateException,
RepositoryException
@@ -225,12 +215,13 @@
/**
* Performs ADD to NodeData and PropertyData.
- * @param modification
- * @param conn
- * @throws IllegalStateException
- * @throws RepositoryException
+ *
+ * @param modification Modification
+ * @param conn JDBCStorageConnection
+ * @throws IllegalStateException if connection closed
+ * @throws RepositoryException if error occurs
*/
- private void doAdd(Modification modification, WorkspaceStorageConnection conn) throws
IllegalStateException,
+ private void doAdd(Modification modification, JDBCStorageConnection conn) throws
IllegalStateException,
RepositoryException
{
if (modification.getValue() instanceof NodeData)
@@ -253,12 +244,11 @@
* Performs UPDATE to NodeData or PropertyData.
*
* @param modification Modification
- * @param conn WorkspaceStorageConnection
+ * @param conn JDBCStorageConnection
* @throws IllegalStateException if connection closed
* @throws RepositoryException if error occurs
*/
- private void doUpdate(Modification m, JDBCStorageConnection conn) throws
IllegalStateException,
- RepositoryException
+ private void doUpdate(Modification m, JDBCStorageConnection conn) throws
IllegalStateException, RepositoryException
{
if (m.getFqn().size() == 2 && m.getValue() instanceof TransientItemData)
{
@@ -272,7 +262,6 @@
|| (item.getState() & TransientItemData.TRANSITIVE_MIXIN_UPDATED) == 0)
{
if (conn.itemExists((String)m.getFqn().get(1), item.isNode()))
- //if (isUpdate(m, (JDBCStorageConnection)conn))
{
// update if it's non transitive update
if (item.isNode())
@@ -297,7 +286,6 @@
}
}
}
-
}
/**
@@ -693,23 +681,23 @@
{
if (onePhase)
{
- final WorkspaceStorageConnection conn = dataContainer.openConnection();
- apply(conn, modifications);
+ final JDBCStorageConnection conn =
(JDBCStorageConnection)dataContainer.openConnection();
+ apply(modifications, conn);
conn.commit(); // same immediately
}
else
{
- final WorkspaceStorageConnection exconn = transactions.remove(tx);
+ final JDBCStorageConnection exconn = transactions.remove(tx);
if (exconn != null)
{
// apply in existed connection associated with tx
- apply(exconn, modifications);
+ apply(modifications, exconn);
}
else
{
// open new tx conn, apply in it, save the conn
- final WorkspaceStorageConnection conn = dataContainer.openConnection();
- apply(conn, modifications);
+ final JDBCStorageConnection conn =
(JDBCStorageConnection)dataContainer.openConnection();
+ apply(modifications, conn);
transactions.put(tx, conn);
}
}