代码拉取完成,页面将自动刷新
ONLYOFFICE Docs Integration SDK provides common interfaces and default implementations for integrating ONLYOFFICE Document Server into your own website or application on Java.
SDK consists of 5 main managers and 4 services.
Manager | Description | Default implementation |
---|---|---|
DocumentManager | This manager is used for working with files and document formats. | DefaultDocumentManager (abstract) |
RequestManager | This manager is used to make requests to the ONLYOFFICE Document Server. | DefaultRequestManager |
JwtManager | This manager is used for generating and verifying authorization tokens. | DefaultJwtManager |
SettingsManager | This manager is used to manage integration application settings. | DefaultSettingsManager (abstract) |
UrlManager | This manager is used as a URL provider. | DefaultUrlManager |
Service | Description | Default implementation |
---|---|---|
ConfigService | This configuration generation service is used for opening the document editor. | DefaultConfigService |
CallbackService | This service is used for processing the response of the document server. | DefaultCallbackService |
ConvertService | This service is used for converting documents. | DefaultConvertService |
SettingsValidationService | This service is used for checking document server connection settings. | DefaultSettingsValidationService |
Let's look at the demo example, which shows how the SDK works in a classic Spring web application:
@Override
public String getSetting(final String name) {
return properties.getProperty(name);
}
@Override
public void setSetting(final String name, final String value) {
properties.setProperty(name, value);
}
The full example code can be found here.
@Override
public String getDocumentKey(final String fileId, final boolean embedded) {
return String.valueOf(fileId.hashCode());
}
@Override
public String getDocumentName(final String fileId) {
return "sample.docx";
}
The full example code can be found here.
@Override
public String getFileUrl(final String fileId) {
return getServerUrl() + "/file/download";
}
@Override
public String getCallbackUrl(final String fileId) {
return getServerUrl() + "/callback";
}
The full example code can be found here.
@Bean
public JwtManager jwtManager(final SettingsManager settingsManager) {
return new DefaultJwtManager(settingsManager);
}
@Bean
public RequestManager requestManager(final UrlManager urlManager, final JwtManager jwtManager, final SettingsManager settingsManager) {
return new DefaultRequestManager(urlManager, jwtManager, settingsManager);
}
The full example code can be found here.
@GetMapping("/editor")
public String main(final Model model) throws JsonProcessingException {
Config config = configService.createConfig("1", Mode.EDIT, Type.DESKTOP);
model.addAttribute("config", config);
model.addAttribute("documentServerApiUrl", urlManager.getDocumentServerApiUrl());
return "editor";
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。