int procIndex = 2;
// First check if casProcessors have been previously been added. If not, add them
// to a descriptor.
boolean create = false;
int numProcessors = 0;
CpeCasProcessors processorList = getCpeDescriptor().getCpeCasProcessors();
// Check if added casProcessors using addCasProcessor API. If not create needed
// casProcessors and add descriptor paths
if (processorCount == 0) {
create = true;
// the list contains two other entires besides casProcessors. Namely collection iterator
// and cas Initializer. So to get # of casProcessors in the list subtract 2 non-casProcessor
// entries.
numProcessors = aList.size() - procIndex;
} else {
numProcessors = processorList.getAllCpeCasProcessors().length;
}
CpeCasProcessor newProcessor = null;
// Now add each casProcessor to a descriptor
for (int i = 0; i < numProcessors; i++) {
String[] casProcInfo = (String[]) aList.get(procIndex + i);
if (create) {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_create_new_cp_from_list__FINEST",
new Object[] { Thread.currentThread().getName(), casProcInfo[0] });
}
// The list suppose to contain an array of Strings of size 2.
// Where the the first element is the name of the CasProcessor
// and the second is the descriptor path
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_from_list__FINEST",
new Object[] { Thread.currentThread().getName(), casProcInfo[0] });
}
newProcessor = addCasProcessor(casProcInfo[0]);
} else {
newProcessor = processorList.getCpeCasProcessor(i);
}
if (newProcessor != null) {
newProcessor.setDescriptor(casProcInfo[1]);
}
}