Fixed tomcat shutdown problem (ALF-9574)

* fixes bug https://issues.alfresco.com/jira/browse/ALF-9574
* makes threads in the pool more identifiable (e.g. JobLockService1 instead of pool-1-thread-1)




git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29311 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2011-07-25 14:44:48 +00:00
parent 7063264f54
commit 12a03e1653
2 changed files with 33 additions and 5 deletions

View File

@@ -936,7 +936,7 @@
</bean>
<!-- Clustered (DB) locking Service -->
<bean id="jobLockService" class="org.alfresco.repo.lock.JobLockServiceImpl">
<bean id="jobLockService" class="org.alfresco.repo.lock.JobLockServiceImpl" destroy-method="shutdown">
<property name="retryingTransactionHelper">
<bean class="org.alfresco.repo.transaction.RetryingTransactionHelper">
<property name="transactionService">

View File

@@ -25,13 +25,14 @@ import java.util.concurrent.TimeUnit;
import org.alfresco.repo.domain.locks.LockDAO;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionListenerAdapter;
import org.alfresco.repo.transaction.TransactionalResourceHelper;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.alfresco.util.TraceableThreadFactory;
import org.alfresco.util.VmShutdownListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -68,10 +69,37 @@ public class JobLockServiceImpl implements JobLockService
defaultRetryWait = 20;
defaultRetryCount = 10;
txnListener = new LockTransactionListener();
scheduler = Executors.newScheduledThreadPool(1);
TraceableThreadFactory threadFactory = new TraceableThreadFactory();
threadFactory.setThreadDaemon(false);
threadFactory.setNamePrefix("JobLockService");
scheduler = Executors.newSingleThreadScheduledExecutor(threadFactory);
shutdownListener = new VmShutdownListener("JobLockService");
}
/**
* Lifecycle method. This method should be called when the JobLockService
* is no longer required allowing proper clean up before disposing of the object.
* <p>
* This is mostly used to tell the thread pool to shut itself down
* so as to allow the JVM to terminate.
*/
public void shutdown()
{
if (logger.isInfoEnabled())
{
logger.info("shutting down.");
}
// If we don't tell the thread pool to shutdown, then the JVM won't shutdown.
scheduler.shutdown();
}
/**
* Set the lock DAO
*/