Merged up to HEAD.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3129 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-06-16 19:18:30 +00:00
parent 936f6d7021
commit 7f79a2a498
118 changed files with 14354 additions and 843 deletions

View File

@@ -24,9 +24,8 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.node.db.NodeDaoService;
import org.alfresco.repo.node.integrity.IntegrityChecker;
import org.alfresco.repo.search.impl.lucene.LuceneIndexerAndSearcherFactory;
import org.alfresco.repo.search.impl.lucene.LuceneIndexerAndSearcher;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.util.GUID;
import org.apache.commons.logging.Log;
@@ -106,8 +105,8 @@ public abstract class AlfrescoTransactionSupport
{
TransactionSynchronizationImpl synch = getSynchronization();
Set<NodeDaoService> services = synch.getNodeDaoServices();
for (NodeDaoService service : services)
Set<TransactionalDao> services = synch.getDaoServices();
for (TransactionalDao service : services)
{
if (service.isDirty())
{
@@ -195,20 +194,20 @@ public abstract class AlfrescoTransactionSupport
* This method can be called repeatedly as long as the service being bound
* implements <tt>equals</tt> and <tt>hashCode</tt>.
*
* @param nodeDaoService
* @param daoService
*/
public static void bindNodeDaoService(NodeDaoService nodeDaoService)
public static void bindDaoService(TransactionalDao daoService)
{
// get transaction-local synchronization
TransactionSynchronizationImpl synch = getSynchronization();
// bind the service in
boolean bound = synch.getNodeDaoServices().add(nodeDaoService);
boolean bound = synch.getDaoServices().add(daoService);
// done
if (logger.isDebugEnabled())
{
logBoundService(nodeDaoService, bound);
logBoundService(daoService, bound);
}
}
@@ -250,7 +249,7 @@ public abstract class AlfrescoTransactionSupport
* @param indexerAndSearcher the Lucene indexer to perform transaction completion
* tasks on
*/
public static void bindLucene(LuceneIndexerAndSearcherFactory indexerAndSearcher)
public static void bindLucene(LuceneIndexerAndSearcher indexerAndSearcher)
{
// get transaction-local synchronization
TransactionSynchronizationImpl synch = getSynchronization();
@@ -320,7 +319,7 @@ public abstract class AlfrescoTransactionSupport
* <p>
* The flush may include:
* <ul>
* <li>{@link NodeDaoService#flush()}</li>
* <li>{@link TransactionalDao#flush()}</li>
* <li>{@link RuleService#executePendingRules()}</li>
* <li>{@link IntegrityChecker#checkIntegrity()}</li>
* </ul>
@@ -424,9 +423,9 @@ public abstract class AlfrescoTransactionSupport
private static class TransactionSynchronizationImpl extends TransactionSynchronizationAdapter
{
private final String txnId;
private final Set<NodeDaoService> nodeDaoServices;
private final Set<TransactionalDao> daoServices;
private final Set<IntegrityChecker> integrityCheckers;
private final Set<LuceneIndexerAndSearcherFactory> lucenes;
private final Set<LuceneIndexerAndSearcher> lucenes;
private final Set<TransactionListener> listeners;
private final Map<Object, Object> resources;
@@ -438,9 +437,9 @@ public abstract class AlfrescoTransactionSupport
public TransactionSynchronizationImpl(String txnId)
{
this.txnId = txnId;
nodeDaoServices = new HashSet<NodeDaoService>(3);
daoServices = new HashSet<TransactionalDao>(3);
integrityCheckers = new HashSet<IntegrityChecker>(3);
lucenes = new HashSet<LuceneIndexerAndSearcherFactory>(3);
lucenes = new HashSet<LuceneIndexerAndSearcher>(3);
listeners = new HashSet<TransactionListener>(5);
resources = new HashMap<Object, Object>(17);
}
@@ -451,12 +450,12 @@ public abstract class AlfrescoTransactionSupport
}
/**
* @return Returns a set of <tt>NodeDaoService</tt> instances that will be called
* @return Returns a set of <tt>TransactionalDao</tt> instances that will be called
* during end-of-transaction processing
*/
public Set<NodeDaoService> getNodeDaoServices()
public Set<TransactionalDao> getDaoServices()
{
return nodeDaoServices;
return daoServices;
}
/**
@@ -472,7 +471,7 @@ public abstract class AlfrescoTransactionSupport
* @return Returns a set of <tt>LuceneIndexerAndSearcherFactory</tt> that will be called
* during end-of-transaction processing
*/
public Set<LuceneIndexerAndSearcherFactory> getLucenes()
public Set<LuceneIndexerAndSearcher> getLucenes()
{
return lucenes;
}
@@ -499,7 +498,7 @@ public abstract class AlfrescoTransactionSupport
StringBuilder sb = new StringBuilder(50);
sb.append("TransactionSychronizationImpl")
.append("[ txnId=").append(txnId)
.append(", node service=").append(nodeDaoServices.size())
.append(", daos=").append(daoServices.size())
.append(", integrity=").append(integrityCheckers.size())
.append(", indexers=").append(lucenes.size())
.append(", resources=").append(resources)
@@ -524,9 +523,9 @@ public abstract class AlfrescoTransactionSupport
listener.flush();
}
// flush changes
for (NodeDaoService nodeDaoServices : getNodeDaoServices())
for (TransactionalDao daoService : getDaoServices())
{
nodeDaoServices.flush();
daoService.flush();
}
}
@@ -589,7 +588,7 @@ public abstract class AlfrescoTransactionSupport
// flush
flush();
// prepare the indexes
for (LuceneIndexerAndSearcherFactory lucene : lucenes)
for (LuceneIndexerAndSearcher lucene : lucenes)
{
lucene.prepare();
}
@@ -630,7 +629,7 @@ public abstract class AlfrescoTransactionSupport
}
// commit/rollback Lucene
for (LuceneIndexerAndSearcherFactory lucene : lucenes)
for (LuceneIndexerAndSearcher lucene : lucenes)
{
try
{

View File

@@ -0,0 +1,26 @@
package org.alfresco.repo.transaction;
/**
* Contract for a DAO to interact with a transaction.
*
* @author davidc
*/
public interface TransactionalDao
{
/**
* Allows the dao to flush any consuming resources. This mechanism is
* used primarily during long-lived transactions to ensure that system resources
* are not used up.
* <p>
* This method must not be used for implementing business logic.
*/
void flush();
/**
* Are there any pending changes which must be synchronized with the store?
*
* @return true => changes are pending
*/
public boolean isDirty();
}

View File

@@ -17,7 +17,6 @@
package org.alfresco.repo.transaction;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.node.db.NodeDaoService;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.beans.factory.InitializingBean;
@@ -31,16 +30,16 @@ import org.springframework.beans.factory.InitializingBean;
*
* @author Derek Hulley
*/
public class NodeDaoServiceTransactionInterceptor implements MethodInterceptor, InitializingBean
public class TransactionalDaoInterceptor implements MethodInterceptor, InitializingBean
{
private NodeDaoService nodeDaoService;
private TransactionalDao daoService;
/**
* @param nodeDaoService the <tt>NodeDaoService</tt> to register
* @param daoService the <tt>NodeDaoService</tt> to register
*/
public void setNodeDaoService(NodeDaoService nodeDaoService)
public void setDaoService(TransactionalDao daoService)
{
this.nodeDaoService = nodeDaoService;
this.daoService = daoService;
}
/**
@@ -48,15 +47,15 @@ public class NodeDaoServiceTransactionInterceptor implements MethodInterceptor,
*/
public void afterPropertiesSet() throws Exception
{
if (nodeDaoService == null)
if (daoService == null)
{
throw new AlfrescoRuntimeException("NodeDaoService is required: " + this);
throw new AlfrescoRuntimeException("TransactionalDao is required: " + this);
}
}
public Object invoke(MethodInvocation invocation) throws Throwable
{
AlfrescoTransactionSupport.bindNodeDaoService(nodeDaoService);
AlfrescoTransactionSupport.bindDaoService(daoService);
// propogate the call
return invocation.proceed();
}