* @return - Integrated CasProcessor
* @throws ResourceConfigurationException
*/
private CasProcessor produceIntegratedCasProcessor(CpeCasProcessor aCasProcessorType)
throws ResourceConfigurationException {
CasProcessor casProcessor = null;
ResourceSpecifier resourceSpecifier = null;
try {
if (aCasProcessorType != null) {
URL descriptorUrl = getDescriptorURL(aCasProcessorType);
resourceSpecifier = getSpecifier(descriptorUrl);
CpeSofaMappings sofanamemappings = aCasProcessorType.getSofaNameMappings();
HashMap sofamap = new HashMap();
if (sofanamemappings != null) {
CpeSofaMapping[] sofaNameMappingArray = sofanamemappings.getSofaNameMappings();
for (int i = 0; sofaNameMappingArray != null && i < sofaNameMappingArray.length; i++) {
CpeSofaMapping aSofaMap = sofaNameMappingArray[i];
// if no component sofa name, then set it to default
if (aSofaMap.getComponentSofaName() == null)
aSofaMap.setComponentSofaName(CAS.NAME_DEFAULT_TEXT_SOFA);
sofamap.put(aSofaMap.getComponentSofaName(), aSofaMap.getCpeSofaName());
}
}
// Replace parameters in component descriptor with values defined in the CPE descriptor
overrideParameterSettings(resourceSpecifier, aCasProcessorType
.getConfigurationParameterSettings(), "CasProcessor:"
+ aCasProcessorType.getName());
// create child UimaContext and insert into mInitParams map
UimaContextAdmin childContext = uimaContext.createChild(aCasProcessorType.getName(),
sofamap);
Map additionalParams = new HashMap();
additionalParams.put(Resource.PARAM_UIMA_CONTEXT, childContext);
// need this check to do specific CasDataConsumer processing
if (resourceSpecifier instanceof CasConsumerDescription
&& !isDefinitionInstanceOf(CasConsumer.class, resourceSpecifier, descriptorUrl.toString())) {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_producing_cas_data_consumer__FINEST",
new Object[] { Thread.currentThread().getName() });
}
casProcessor = produceCasDataConsumer(CasProcessor.class, resourceSpecifier,
additionalParams);
} else {
// Except for CasDataConsumers, everything else is treated as an AnalysisEngine.
// This includes CAS Consumers, which will automatically be wrapped inside AnalysisEngines
// by the produceAnalysisEngine method. It also handles UriSpecifiers for
// remote services (for either AE or CAS Consumer)
casProcessor = UIMAFramework.produceAnalysisEngine(resourceSpecifier,
getResourceManager(), additionalParams);
}
// Check if CasProcesser has been instantiated
if (casProcessor == null) {
throw new ResourceConfigurationException(new Exception(CpmLocalizedMessage
.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_EXP_instantiation_exception__WARNING", new Object[] {
Thread.currentThread().getName(), aCasProcessorType.getName() })));
}
}
} catch (ResourceConfigurationException e) {
throw e;
} catch (Exception e) {
throw new ResourceConfigurationException(
ResourceInitializationException.CAS_PROCESSOR_INITIALIZE_FAILED,
new Object[] { aCasProcessorType.getName() }, e);
}
// Override the name of the component with the name specified in the cpe descriptor
// Uniqueness of names is enforced on names in the cpe descriptor not those defined
// in the component descriptor
if ( casProcessor != null && aCasProcessorType != null ) {
casProcessor.getProcessingResourceMetaData().setName(aCasProcessorType.getName());
}
return casProcessor;
}