org.jaxws.stub2html.view.freemarker.FilePathFreemarkerWebServiceDisplayEngine Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wsdl2html Show documentation
Show all versions of wsdl2html Show documentation
A java tool to convert wsdl xml to readable doc
package org.jaxws.stub2html.view.freemarker;
import java.io.File;
import java.io.IOException;
import freemarker.template.Template;
/**
*
* @author chenjianjx
*
*/
public class FilePathFreemarkerWebServiceDisplayEngine extends FreemarkerWebServiceDisplayEngine {
private File templateFile;
private FilePathFreemarkerWebServiceDisplayEngine(File templateFile) {
super();
if (!templateFile.exists() || !templateFile.isFile()) {
throw new IllegalArgumentException(templateFile + " doesn't exist or is not a file");
}
setTemplateLoadingDir(templateFile.getParentFile());
this.templateFile = templateFile;
}
private void setTemplateLoadingDir(File parentFile) {
try {
configuration.setDirectoryForTemplateLoading(parentFile);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
public static FilePathFreemarkerWebServiceDisplayEngine createEngine(File templateFile) {
return new FilePathFreemarkerWebServiceDisplayEngine(templateFile);
}
@Override
protected Template getTemplate() {
try {
return configuration.getTemplate(templateFile.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}