• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java BatchProcessWorkerAdaptor类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.alfresco.repo.batch.BatchProcessor.BatchProcessWorkerAdaptor的典型用法代码示例。如果您正苦于以下问题:Java BatchProcessWorkerAdaptor类的具体用法?Java BatchProcessWorkerAdaptor怎么用?Java BatchProcessWorkerAdaptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

BatchProcessWorkerAdaptor类属于org.alfresco.repo.batch.BatchProcessor包,在下文中一共展示了BatchProcessWorkerAdaptor类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

点赞 2

import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorkerAdaptor; //导入依赖的package包/类
@Override
protected int execute() throws ToolException
{
    // Used for ability to be final and have a set
    final AtomicInteger status = new AtomicInteger(0);

    BatchProcessWorker<User> worker = new BatchProcessWorkerAdaptor<User>()
    {
        public void process(final User user) throws Throwable
        {
            RunAsWork<Void> runAsWork = new RunAsWork<Void>()
            {
                @Override
                public Void doWork() throws Exception
                {
                    try
                    {
                        renameUser(user.getOldUsername(), user.getNewUsername());
                    }
                    catch (Throwable t)
                    {
                        status.set(handleError(t));
                    }
                    return null;
                }
            };
            AuthenticationUtil.runAs(runAsWork, context.getUsername());
        }
    };
    
    // Use 2 threads, 20 User objects per transaction. Log every 100 entries.
    BatchProcessor<User> processor = new BatchProcessor<User>(
            "HomeFolderProviderSynchronizer",
            getServiceRegistry().getTransactionService().getRetryingTransactionHelper(),
            new WorkProvider(context),
            2, 20,
            null,
            logger, 100);
    processor.process(worker, true);

    return status.get();
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:43,
代码来源:RenameUser.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)