private CpeCasProcessor addCasProcessor(String aCasProcessorName)
throws ResourceConfigurationException {
CpeCasProcessor newProcessor = null;
try {
if (!isUniqueName(aCasProcessorName)) {
throw new ResourceConfigurationException(new Exception(CpmLocalizedMessage
.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_EXP_duplicate_name__WARNING", new Object[] {
Thread.currentThread().getName(), aCasProcessorName })));
}
int index = getCpeDescriptor().getCpeCasProcessors().getAllCpeCasProcessors().length; // getcasProcessorCount();
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(
Level.FINEST,
this.getClass().getName(),
"initialize",
CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_add_cp_with_index__FINEST",
new Object[] { Thread.currentThread().getName(), aCasProcessorName,
String.valueOf(index) });
}
CpeCasProcessor processor = getCpeDescriptor().getCpeCasProcessors().getCpeCasProcessor(
index - 1);
if (processor.getCheckpoint() == null) {
throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND,
new Object[] { "checkpoint", "casProcessor" }, new Exception(CpmLocalizedMessage
.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] {
Thread.currentThread().getName(), aCasProcessorName,
"<checkpoint>" })));
}
// For remote Cas Processor make sure that the required parameters are defined.
// Specifically, VNS host and port are required. Do validation now. If it fails, the
// ResourceConfigurationException is thrown and we are out here.
if (Constants.DEPLOYMENT_REMOTE.equals(processor.getDeployment())) {
String protocol = DeployFactory.getProtocol(processor, getResourceManager());
if (Constants.VINCI_PROTOCOL.equals(protocol)) {
verifyDeploymentParams(aCasProcessorName, processor.getDeploymentParams());
}
}
if (processorCount == 0) {
newProcessor = processor;
copyCasProcessor(newProcessor, aCasProcessorName);
} else {
// CpeCasProcessor cloneProcessor =
// getCpeDescriptor().getCpeCasProcessors().getCpeCasProcessor(0);
newProcessor = new CpeIntegratedCasProcessorImpl();
newProcessor.setDescriptor("href");
// // Clone casProcessor from an existing one
// newProcessor = cpeDescGen.createcasProcessor(cloneProcessor);
copyCasProcessor(newProcessor, aCasProcessorName);
getCpeDescriptor().getCpeCasProcessors().addCpeCasProcessor(newProcessor, processorCount);// setCpeCasProcessor(processorCount,
// newProcessor);
}
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).log(
Level.FINEST,
"getCpeDescriptor().getCasProcessors().getCasProcessor.getAttributeValue(name) "
+ " "
+ getCpeDescriptor().getCpeCasProcessors().getCpeCasProcessor(
processorCount).getAttributeValue("name"));
UIMAFramework
.getLogger(this.getClass())
.log(
Level.FINEST,
"getCpeDescriptor().getCasProcessors().getCasProcessor("
+ "processorCount).getErrorHandling().getMaxConsecutiveRestarts().getAction() "
+ " "
+ getCpeDescriptor().getCpeCasProcessors().getCpeCasProcessor(
processorCount).getErrorHandling()
.getMaxConsecutiveRestarts().getAction());
}
if (!casProcessorConfigMap.containsKey(aCasProcessorName)) {
casProcessorConfigMap.put(aCasProcessorName, getCpeDescriptor().getCpeCasProcessors()
.getCpeCasProcessor(processorCount));
}
} catch (Exception e) {
throw new ResourceConfigurationException(e);
}
processorCount++;
return newProcessor;
}