本文整理汇总了Java中org.alfresco.util.VmShutdownListener类的典型用法代码示例。如果您正苦于以下问题:Java VmShutdownListener类的具体用法?Java VmShutdownListener怎么用?Java VmShutdownListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VmShutdownListener类属于org.alfresco.util包,在下文中一共展示了VmShutdownListener类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JobLockServiceImpl
import org.alfresco.util.VmShutdownListener; //导入依赖的package包/类
public JobLockServiceImpl()
{
defaultRetryWait = 20;
defaultRetryCount = 10;
txnListener = new LockTransactionListener();
TraceableThreadFactory threadFactory = new TraceableThreadFactory();
threadFactory.setThreadDaemon(false);
threadFactory.setNamePrefix("JobLockService");
scheduler = Executors.newSingleThreadScheduledExecutor(threadFactory);
shutdownListener = new VmShutdownListener("JobLockService");
}
示例2: getArchivedNodesWorkProvider
import org.alfresco.util.VmShutdownListener; //导入依赖的package包/类
/**
* @return Returns a work provider for batch processing
*
* @since 3.3.4
*/
private BatchProcessWorkProvider<NodeRef> getArchivedNodesWorkProvider(final StoreRef originalStoreRef, final String lockToken)
{
return new BatchProcessWorkProvider<NodeRef>()
{
private VmShutdownListener vmShutdownLister = new VmShutdownListener("getArchivedNodesWorkProvider");
private List<NodeRef> nodeRefs;
private boolean done;
private synchronized List<NodeRef> getNodeRefs()
{
if (nodeRefs == null)
{
nodeRefs = getArchivedNodes(originalStoreRef);
}
return nodeRefs;
}
/**
* @return Returns 0, always
*/
public synchronized int getTotalEstimatedWorkSize()
{
return 0;
}
public synchronized Collection<NodeRef> getNextWork()
{
if (vmShutdownLister.isVmShuttingDown())
{
return Collections.emptyList();
}
// Make sure we still have the lock
try
{
// TODO: Replace with joblock callback mechanism that provides shutdown hints
jobLockService.refreshLock(lockToken, LOCK_QNAME, LOCK_TTL);
}
catch (LockAcquisitionException e)
{
// This is OK. We don't have the lock so just quit
return Collections.emptyList();
}
if (done)
{
return Collections.emptyList();
}
else
{
done = true;
return getNodeRefs();
}
}
};
}