use of org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngine_impl in project dkpro-lab by dkpro.
the class SimpleClient method start.
/**
* Initialize the UIMA-AS client.
*/
public void start() throws ResourceInitializationException {
uimaAsEngine = new BaseUIMAAsynchronousEngine_impl();
Map<String, Object> clientCtx = new HashMap<String, Object>();
clientCtx.put(UimaAsynchronousEngine.ServerUri, getBrokerUrl());
clientCtx.put(UimaAsynchronousEngine.Endpoint, endpoint);
clientCtx.put(UimaAsynchronousEngine.Timeout, timeout * 1000);
clientCtx.put(UimaAsynchronousEngine.GetMetaTimeout, getmeta_timeout * 1000);
clientCtx.put(UimaAsynchronousEngine.CpcTimeout, cpc_timeout * 1000);
clientCtx.put(UimaAsynchronousEngine.CasPoolSize, casPoolSize);
clientCtx.put(UIMAFramework.CAS_INITIAL_HEAP_SIZE, new Integer(fsHeapSize / 4).toString());
// Add Collection Reader
if (collectionReaderDesc != null) {
uimaAsEngine.setCollectionReader(UIMAFramework.produceCollectionReader(collectionReaderDesc));
}
// Add status listener
// uimaAsEngine.addStatusCallbackListener(new StatusCallbackListenerImpl(ctx));
// Initialize the client
uimaAsEngine.initialize(clientCtx);
log.debug("UIMA AS client started");
}
use of org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngine_impl 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.adapter.jms.client.BaseUIMAAsynchronousEngine_impl 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