//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.io.File;
import org.artofsolving.jodconverter.process.ProcessManager;
import org.artofsolving.jodconverter.process.PureJavaProcessManager;
import org.artofsolving.jodconverter.process.LinuxProcessManager;
import org.artofsolving.jodconverter.process.SigarProcessManager;
import org.artofsolving.jodconverter.util.PlatformUtils;
public class DefaultOfficeManagerConfiguration {
public static final long DEFAULT_RETRY_TIMEOUT = 120000L;
private File officeHome = OfficeUtils.getDefaultOfficeHome();
private OfficeConnectionProtocol connectionProtocol = OfficeConnectionProtocol.SOCKET;
private int[] portNumbers = new int[] { 2002 };
private String[] pipeNames = new String[] { "office" };
private String[] runAsArgs = null;
private File templateProfileDir = null;
private File workDir = new File(System.getProperty("java.io.tmpdir"));
private long taskQueueTimeout = 30000L; // 30 seconds
private long taskExecutionTimeout = 120000L; // 2 minutes
private int maxTasksPerProcess = 200;
private long retryTimeout = DEFAULT_RETRY_TIMEOUT;
private ProcessManager processManager = null; // lazily initialised
public DefaultOfficeManagerConfiguration setOfficeHome(String officeHome) throws NullPointerException, IllegalArgumentException {
checkArgumentNotNull("officeHome", officeHome);
return setOfficeHome(new File(officeHome));
}
public DefaultOfficeManagerConfiguration setOfficeHome(File officeHome) throws NullPointerException, IllegalArgumentException {
checkArgumentNotNull("officeHome", officeHome);
checkArgument("officeHome", officeHome.isDirectory(), "must exist and be a directory");
this.officeHome = officeHome;
return this;
}
public DefaultOfficeManagerConfiguration setConnectionProtocol(OfficeConnectionProtocol connectionProtocol) throws NullPointerException {
checkArgumentNotNull("connectionProtocol", connectionProtocol);
this.connectionProtocol = connectionProtocol;
return this;
}
public DefaultOfficeManagerConfiguration setPortNumber(int portNumber) {
this.portNumbers = new int[] { portNumber };
return this;
}
public DefaultOfficeManagerConfiguration setPortNumbers(int... portNumbers) throws NullPointerException, IllegalArgumentException {
checkArgumentNotNull("portNumbers", portNumbers);
checkArgument("portNumbers", portNumbers.length > 0, "must not be empty");
this.portNumbers = portNumbers;
return this;
}
public DefaultOfficeManagerConfiguration setPipeName(String pipeName) throws NullPointerException {
checkArgumentNotNull("pipeName", pipeName);
this.pipeNames = new String[] { pipeName };
return this;
}
public DefaultOfficeManagerConfiguration setPipeNames(String... pipeNames) throws NullPointerException, IllegalArgumentException {
checkArgumentNotNull("pipeNames", pipeNames);
checkArgument("pipeNames", pipeNames.length > 0, "must not be empty");
this.pipeNames = pipeNames;
return this;
}
public DefaultOfficeManagerConfiguration setRunAsArgs(String... runAsArgs) {
this.runAsArgs = runAsArgs;
return this;
}
public DefaultOfficeManagerConfiguration setTemplateProfileDir(File templateProfileDir) throws IllegalArgumentException {
if (templateProfileDir != null) {
checkArgument("templateProfileDir", templateProfileDir.isDirectory(), "must exist and be a directory");
}
this.templateProfileDir = templateProfileDir;
return this;
}
/**
* Sets the directory where temporary office profiles will be created.
* <p>
* Defaults to the system temporary directory as specified by the <code>java.io.tmpdir</code> system property.
*
* @param workDir
* @return
*/
public DefaultOfficeManagerConfiguration setWorkDir(File workDir) {
checkArgumentNotNull("workDir", workDir);
this.workDir = workDir;
return this;
}
public DefaultOfficeManagerConfiguration setTaskQueueTimeout(long taskQueueTimeout) {
this.taskQueueTimeout = taskQueueTimeout;
return this;
}
public DefaultOfficeManagerConfiguration setTaskExecutionTimeout(long taskExecutionTimeout) {
this.taskExecutionTimeout = taskExecutionTimeout;
return this;
}
public DefaultOfficeManagerConfiguration setMaxTasksPerProcess(int maxTasksPerProcess) {
this.maxTasksPerProcess = maxTasksPerProcess;
return this;
}
/**
* Provide a specific {@link ProcessManager} implementation
* <p>
* The default is to use {@link SigarProcessManager} if sigar.jar is
* available in the classpath, otherwise {@link LinuxProcessManager}
* on Linux and {@link PureJavaProcessManager} on other platforms.
*
* @param processManager
* @return
* @throws NullPointerException
*/
public DefaultOfficeManagerConfiguration setProcessManager(ProcessManager processManager) throws NullPointerException {
checkArgumentNotNull("processManager", processManager);
this.processManager = processManager;
return this;
}
/**
* Retry timeout set in milliseconds. Used for retrying office process calls.
* If not set, it defaults to 2 minutes
*
* @param retryTimeout in milliseconds
* @return
*/
public DefaultOfficeManagerConfiguration setRetryTimeout(long retryTimeout) {
this.retryTimeout = retryTimeout;
return this;
}
public OfficeManager buildOfficeManager() throws IllegalStateException {
if (officeHome == null) {
throw new IllegalStateException("officeHome not set and could not be auto-detected");
} else if (!officeHome.isDirectory()) {
throw new IllegalStateException("officeHome doesn't exist or is not a directory: " + officeHome);
} else if (!OfficeUtils.getOfficeExecutable(officeHome).isFile()) {
throw new IllegalStateException("invalid officeHome: it doesn't contain soffice.bin: " + officeHome);
}
if (templateProfileDir != null && !isValidProfileDir(templateProfileDir)) {
throw new IllegalStateException("templateProfileDir doesn't appear to contain a user profile: " + templateProfileDir);
}
if (!workDir.isDirectory()) {
throw new IllegalStateException("workDir doesn't exist or is not a directory: " + workDir);
}
if (processManager == null) {
processManager = findBestProcessManager();
}
int numInstances = connectionProtocol == OfficeConnectionProtocol.PIPE ? pipeNames.length : portNumbers.length;
UnoUrl[] unoUrls = new UnoUrl[numInstances];
for (int i = 0; i < numInstances; i++) {
unoUrls[i] = (connectionProtocol == OfficeConnectionProtocol.PIPE) ? UnoUrl.pipe(pipeNames[i]) : UnoUrl.socket(portNumbers[i]);
}
return new ProcessPoolOfficeManager(officeHome, unoUrls, runAsArgs, templateProfileDir, workDir, retryTimeout, taskQueueTimeout, taskExecutionTimeout, maxTasksPerProcess, processManager);
}
private ProcessManager findBestProcessManager() {
if (isSigarAvailable()) {
return new SigarProcessManager();
} else if (PlatformUtils.isLinux()) {
LinuxProcessManager processManager = new
没有合适的资源?快使用搜索试试~ 我知道了~
springboot 文件转换PDF多线程
共192个文件
xml:81个
class:56个
java:44个
需积分: 50 48 下载量 39 浏览量
2018-06-28
09:08:06
上传
评论 1
收藏 233KB ZIP 举报
温馨提示
根据网上的资料总结的一个springboot 转换pdf Word文档大小最好2m以下 需要安装OpenOffice.org 3.3 链接:https://pan.baidu.com/s/1onrkhBCNlGLEmf3hPwzXWw 密码:8h5a
资源推荐
资源详情
资源评论
收起资源包目录
springboot 文件转换PDF多线程 (192个子文件)
OfficeProcess.class 9KB
DefaultOfficeManagerConfiguration.class 8KB
ManagedOfficeProcess.class 7KB
OfficeConnection.class 7KB
PooledOfficeManager.class 6KB
Convert.class 6KB
DefaultDocumentFormatRegistry.class 5KB
ProcessPoolOfficeManager.class 5KB
AbstractConversionTask.class 5KB
OfficeUtils.class 4KB
OfficeToPdf.class 4KB
LinuxProcessManager.class 4KB
OfficeDocumentConverter.class 4KB
JsonDocumentFormatRegistry.class 3KB
DocumentFormat.class 3KB
ManagedOfficeProcessSettings.class 3KB
StandardConversionTask.class 3KB
TestController.class 3KB
PooledOfficeManager$2.class 3KB
SimpleDocumentFormatRegistry.class 3KB
SigarProcessManager.class 3KB
ManagedOfficeProcess$6.class 2KB
PooledOfficeManager$1.class 2KB
OfficeConnection$1.class 2KB
ExternalOfficeManagerConfiguration.class 2KB
ExternalOfficeManager.class 2KB
SuspendableThreadPoolExecutor.class 2KB
RunnableThread.class 2KB
OfficeDocumentUtils.class 2KB
OfficeProcess$ExitCodeRetryable.class 2KB
NamedThreadFactory.class 1KB
Retryable.class 1KB
ManagedOfficeProcess$5.class 1KB
UnoUrl.class 1KB
DocumentFamily.class 1KB
OfficeConnectionProtocol.class 1KB
PooledOfficeManagerSettings.class 1KB
PlatformUtils.class 991B
PureJavaProcessManager.class 840B
TemporaryException.class 838B
ManagedOfficeProcess$3.class 833B
ManagedOfficeProcess$4.class 808B
ManagedOfficeProcess$1.class 797B
ManagedOfficeProcess$2.class 796B
ProcessQuery.class 671B
OfficeException.class 656B
DemoApplicationTests.class 622B
OfficeConnectionEvent.class 592B
DocumentFormatRegistry.class 558B
RetryTimeoutException.class 497B
ProcessManager.class 422B
OfficeManager.class 381B
OfficeConnectionEventListener.class 316B
OfficeTask.class 295B
OfficeProcess$1.class 261B
OfficeContext.class 206B
mvnw.cmd 5KB
.gitignore 268B
demo.iml 8KB
jodconverter-core.iml 2KB
maven-wrapper.jar 46KB
DefaultOfficeManagerConfiguration.java 9KB
DefaultDocumentFormatRegistry.java 9KB
OfficeProcess.java 8KB
Convert.java 6KB
ManagedOfficeProcess.java 5KB
OfficeConnection.java 5KB
AbstractConversionTask.java 5KB
PooledOfficeManager.java 4KB
ProcessPoolOfficeManager.java 4KB
OfficeUtils.java 4KB
OfficeToPdf.java 4KB
TestController.java 4KB
OfficeDocumentConverter.java 3KB
JsonDocumentFormatRegistry.java 3KB
LinuxProcessManager.java 3KB
DocumentFormat.java 3KB
ManagedOfficeProcessSettings.java 3KB
ExternalOfficeManager.java 2KB
StandardConversionTask.java 2KB
SigarProcessManager.java 2KB
SimpleDocumentFormatRegistry.java 2KB
UnoUrl.java 2KB
OfficeDocumentUtils.java 2KB
SuspendableThreadPoolExecutor.java 2KB
Retryable.java 2KB
ExternalOfficeManagerConfiguration.java 2KB
PooledOfficeManagerSettings.java 1KB
NamedThreadFactory.java 1KB
PlatformUtils.java 1003B
TemporaryException.java 994B
ProcessManager.java 990B
OfficeManager.java 880B
ProcessQuery.java 865B
OfficeException.java 780B
DocumentFormatRegistry.java 779B
OfficeConnectionEvent.java 747B
PureJavaProcessManager.java 734B
RetryTimeoutException.java 706B
OfficeConnectionEventListener.java 704B
共 192 条
- 1
- 2
资源评论
讴讴酱
- 粉丝: 11
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 31-31.渗透测试SQL注入盲注
- 老板必备实体门店超常规营销获客,218套实体店落地方案解析-课程网盘链接提取码下载 .txt
- 基于Python+Flask+MySQL+SWPU数据库原理开发最流行的外卖订餐系统+源码+开发文档(高分优秀项目)
- ESG的同群效应数据集(2010-2022年).xlsx
- 华为OD机试机考题库Go语言实现36道题(含题目描述、详细解题报告).zip
- 新能源锂电池行业创业的财富方案,锂电池回收高阶课-课程网盘链接提取码下载 .txt
- 30-30.渗透测试SQL注入基础(下)、工具和POST类型(上)
- ssm(老年公寓管理系统)
- TP179-V1.1.2-51单片机蓝牙遥控车.zip
- auto-sqladmin
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功