use of org.apache.uima.resourceSpecifier.factory.UimaASPrimitiveDeploymentDescriptor in project dkpro-lab by dkpro.
the class UimaAsExecutionEngine method initializeService.
protected void initializeService() throws Exception {
// Create Asynchronous Engine API
uimaAsEngine = new BaseUIMAAsynchronousEngine_impl();
// Save the AED to a file because UIMA-AS cannot have an AED direclty embedded in its
// descriptor
AnalysisEngineDescription topDescriptor = configuration.getAnalysisEngineDescription(ctx);
ResourceMetaData topMetaData = topDescriptor.getMetaData();
File topDescriptorFile = File.createTempFile(getClass().getSimpleName(), ".xml");
topDescriptorFile.deleteOnExit();
try (OutputStream os = new FileOutputStream(topDescriptorFile)) {
topDescriptor.toXML(os);
}
// Create service descriptor
ServiceContext context = new ServiceContextImpl(topMetaData.getName(), topMetaData.getDescription(), topDescriptorFile.getAbsolutePath(), endpoint, brokerUrl);
UimaASPrimitiveDeploymentDescriptor dd = DeploymentDescriptorFactory.createPrimitiveDeploymentDescriptor(context);
// Store service descriptor also to a temporary file
File deploymentDescriptionFile = File.createTempFile(getClass().getSimpleName(), ".xml");
deploymentDescriptionFile.deleteOnExit();
dd.save(deploymentDescriptionFile);
Map<String, Object> serviceCtx = new HashMap<String, Object>();
serviceCtx.put(UimaAsynchronousEngine.DD2SpringXsltFilePath, getUrlAsFile(getClass().getResource("/uima-as/dd2spring.xsl"), true).getAbsolutePath());
serviceCtx.put(UimaAsynchronousEngine.SaxonClasspath, getClass().getResource("/uima-as/saxon8.jar").toString());
serviceId = uimaAsEngine.deploy(deploymentDescriptionFile.getAbsolutePath(), serviceCtx);
ctx.message("Deployed experiment as UIMA-AS service: [" + serviceId + "]");
}
use of org.apache.uima.resourceSpecifier.factory.UimaASPrimitiveDeploymentDescriptor in project dkpro-lab by dkpro.
the class SimpleService method start.
/**
* Initialize the UIMA-AS client.
*/
public void start() throws ResourceInitializationException {
uimaAsEngine = new BaseUIMAAsynchronousEngine_impl();
Map<String, Object> serviceCtx = new HashMap<String, Object>();
File deploymentDescriptionFile;
try {
// Save the AED to a file because UIMA-AS cannot have an AED direclty embedded in its
// descriptor
ResourceMetaData topMetaData = aeDesc.getMetaData();
File topDescriptorFile = File.createTempFile(getClass().getSimpleName(), ".xml");
topDescriptorFile.deleteOnExit();
try (OutputStream os = new FileOutputStream(topDescriptorFile)) {
aeDesc.toXML(os);
} catch (SAXException e) {
throw new ResourceInitializationException(e);
}
// Create service descriptor
ServiceContext context = new ServiceContextImpl(topMetaData.getName(), topMetaData.getDescription(), topDescriptorFile.getAbsolutePath(), endpoint, getBrokerUrl());
UimaASPrimitiveDeploymentDescriptor dd = DeploymentDescriptorFactory.createPrimitiveDeploymentDescriptor(context);
deploymentDescriptionFile = File.createTempFile(getClass().getSimpleName(), ".xml");
deploymentDescriptionFile.deleteOnExit();
try {
dd.save(deploymentDescriptionFile);
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
serviceCtx.put(UimaAsynchronousEngine.DD2SpringXsltFilePath, getUrlAsFile(getClass().getResource("/uima-as/dd2spring.xsl"), true).getAbsolutePath());
serviceCtx.put(UimaAsynchronousEngine.SaxonClasspath, getClass().getResource("/uima-as/saxon8.jar").toString());
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
try {
serviceId = uimaAsEngine.deploy(deploymentDescriptionFile.getAbsolutePath(), serviceCtx);
log.debug("UIMA AS service deployed: [" + serviceId + "]");
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
}
Aggregations