public static AnalysisEngineDescription createAggregateDescription(
boolean multipleDeploymentAllowed, List<List<String>> overrides, String... descriptorPaths)
throws Exception {
// create the descriptor and set configuration parameters
AnalysisEngineDescription desc = new AnalysisEngineDescription_impl();
resolver.setPathResolverClassLoader(desc.getClass().getClassLoader());
desc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
desc.setPrimitive(false);
ResourceSpecifier[] specifiers = new ResourceSpecifier[descriptorPaths.length];
// Allow scale up
desc.getAnalysisEngineMetaData().getOperationalProperties()
.setMultipleDeploymentAllowed(multipleDeploymentAllowed);
// Stores component names derived from implementation class
List<String> flowNames = new ArrayList<String>();
int inx = 0;
// First produce ResourceSpecifiers from provided descriptors
for (String aeDescription : descriptorPaths) {
/*
aeDescription = Utils.resolvePlaceholderIfExists(aeDescription,
System.getProperties());
XMLInputSource in = null;
if (!aeDescription.endsWith(".xml")) {
aeDescription = aeDescription.replace('.', '/') + ".xml";
URL relativeURL = resolver.resolveRelativePath(getRelativePathWithProtocol(aeDescription));
// URL relativeURL = resolveRelativePath(aeDescription);
in = new XMLInputSource(relativeURL);
} else {
in = new XMLInputSource(aeDescription);
}
// XMLInputSource in = new XMLInputSource(aeDescription);
ResourceSpecifier specifier = UIMAFramework.getXMLParser()
.parseResourceSpecifier(in);
specifiers[inx++] = specifier;
*/
specifiers[inx++] = getResourceSpecifier(aeDescription);
// UimaClassFactory.produceResourceSpecifier(aeDescription);
}
for (String aeDescription : descriptorPaths) {
Import descriptorImport = new Import_impl();
// If user provides a descriptor with .xml at the end, assume he
// wants import by location
if (aeDescription.endsWith(".xml")) {
aeDescription = Utils.resolvePlaceholderIfExists(aeDescription,
System.getProperties());
if (!aeDescription.startsWith("file:")) {
aeDescription = "file:" + aeDescription;
}
descriptorImport.setLocation(aeDescription);
} else {
// uima import by name expects dot separated path as in
// a.b.descriptor and no .xml at the end
descriptorImport.setName(aeDescription);
}
String key = new String(aeDescription);
if (key.startsWith("file:")) {
key = key.substring(5); // skip "file:"
}
if (key.endsWith(".xml")) {
key = key.substring(0, key.indexOf(".xml")); // strip ".xml"
}
// preprocess the ae descriptor name to replace "/" and
// "\" with ".". We will use the ae
// descriptor name as AE key in the aggregate
if (key.indexOf("/") != -1) {
key = key.replaceAll("/", ".");
}
if (key.indexOf("\\") != -1) {
key = key.replaceAll("\\\\", ".");
}
key = key.substring(key.lastIndexOf(".") + 1);
desc.getDelegateAnalysisEngineSpecifiersWithImports().put(key,
descriptorImport);
flowNames.add(key);
}
String fcsn;
if ( (fcsn = DuccPropertiesResolver.getInstance().getProperty(FlowControllerResourceSpecifier)) != null ) {
FlowControllerDeclaration fcd = new FlowControllerDeclaration_impl();
desc.setFlowControllerDeclaration(fcd);
fcd.setImport(new Import_impl());
fcd.setKey(FlowControllerKey);
fcd.getImport().setName(fcsn);
}
FixedFlow fixedFlow = new FixedFlow_impl();
fixedFlow.setFixedFlow(flowNames.toArray(new String[flowNames.size()]));
desc.getAnalysisEngineMetaData().setFlowConstraints(fixedFlow);
addOverrides(overrides, desc, specifiers, flowNames);
return desc;
}