我想通过网络使用“GATE”。然后我决定在 GATE Embedded 的帮助下在 java 中创建一个 SOAP Web 服务。
但是对于同一个文档和保存的管道,当 GATE Embedded 作为 Java Web 服务运行时,我有不同的运行时持续时间。相同的代码在作为 Java 应用程序项目运行时具有恒定的运行时间。
在 Web 服务中,每次执行后运行时间都会增加,直到出现超时错误。
有没有人有这样的经历?
这是我的代码:
@WebService(serviceName = "GateWS")
public class GateWS {
@WebMethod(operationName = "gateengineapi")
public String gateengineapi(@WebParam(name = "PipelineNumber") String PipelineNumber, @WebParam(name = "Documents") String Docs) throws Exception {
try {
System.setProperty("gate.home", "C:\\GATE\\");
System.setProperty("shell.path", "C:\\cygwin2\\bin\\sh.exe");
Gate.init();
File GateHome = Gate.getGateHome();
File FrenchGapp = new File(GateHome, PipelineNumber);
CorpusController FrenchController;
FrenchController = (CorpusController) PersistenceManager.loadObjectFromFile(FrenchGapp);
Corpus corpus = Factory.newCorpus("BatchProcessApp Corpus");
FrenchController.setCorpus(corpus);
File docFile = new File(GateHome, Docs);
Document doc = Factory.newDocument(docFile.toURL(), "utf-8");
corpus.add(doc);
FrenchController.execute();
String docXMLString = null;
docXMLString = doc.toXml();
String outputFileName = doc.getName() + ".out.xml";
File outputFile = new File(docFile.getParentFile(), outputFileName);
FileOutputStream fos = new FileOutputStream(outputFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
OutputStreamWriter out;
out = new OutputStreamWriter(bos, "utf-8");
out.write(docXMLString);
out.close();
gate.Factory.deleteResource(doc);
return outputFileName;
} catch (Exception ex) {
return "ERROR: -> " + ex.getMessage();
}
}
}
我非常感谢您能提供的任何帮助。