@Override
  public void afterPropertiesSet() throws Exception {
    System.out.println("******************");
    // 启动libreoffice进程 Windows平台需要启动,linux不需要启动
    if (PlatformUtils.isWindows()) {
      String command =
          "cmd /c soffice --headless --accept=\"socket,host=127.0.0.1,port=8100;urp\" --nofirststartwizard";
      Runtime runtime = Runtime.getRuntime();
      runtime.exec(command);
    }

    officeManager = configuration.buildOfficeManager();
    converter = new OfficeDocumentConverter(officeManager);
    customDocumentFormatRegistry = (SimpleDocumentFormatRegistry) converter.getFormatRegistry();

    /*
     * // TODO:这里可以增加OpenOffice支持的文件类型 异常json
     * customDocumentFormatRegistry.addFormat(new
     * DocumentFormat("OpenOffice.org 1.0 Template", "sxd",
     * "application/vnd.sun.xml.draw"));
     * customDocumentFormatRegistry.addFormat(new
     * DocumentFormat("OpenOffice.org 1.0 Template", "odf",
     * "application/vnd.oasis.opendocument.formula"));
     */
    DocumentFormat txt = new DocumentFormat("Java", "java", "text/plain");
    txt.setInputFamily(DocumentFamily.TEXT);
    Map<String, Object> txtLoadAndStoreProperties = new LinkedHashMap<String, Object>();
    txtLoadAndStoreProperties.put("FilterName", "Text (encoded)");
    txtLoadAndStoreProperties.put("FilterOptions", "utf8");
    txt.setLoadProperties(txtLoadAndStoreProperties);
    txt.setStoreProperties(DocumentFamily.TEXT, txtLoadAndStoreProperties);
    customDocumentFormatRegistry.addFormat(txt);

    // 添加wps格式
    customDocumentFormatRegistry.addFormat(
        new DocumentFormat("wps文字", "wps", "application/msword")); // wps文字
    customDocumentFormatRegistry.addFormat(
        new DocumentFormat("wps表格", "et", "application/msword")); // wps表格
    customDocumentFormatRegistry.addFormat(
        new DocumentFormat("wps演示", "dps", "application/msword")); // wps演示
    // 启动officeManager,保持在Bean的生命周期中一直在启动状态
    officeManager.start();
  }
 @Override
 public boolean isSupportByMediaType(String mediaType) {
   return customDocumentFormatRegistry.getFormatByMediaType(mediaType) != null;
 }
 @Override
 public boolean isSupportByExtension(String extension) {
   return customDocumentFormatRegistry.getFormatByExtension(extension) != null;
 }