* {@link PluginRuntimeException} instantiating the {@link Parser}.
*/
public Parser getParserById(String id) throws ParserNotFound {
Extension[] extensions = this.extensionPoint.getExtensions();
Extension parserExt = null;
if (id != null) {
parserExt = getExtension(extensions, id);
}
if (parserExt == null) {
parserExt = getExtensionFromAlias(extensions, id);
}
if (parserExt == null) {
throw new ParserNotFound("No Parser Found for id [" + id + "]");
}
// first check the cache
if (this.conf.getObject(parserExt.getId()) != null) {
return (Parser) this.conf.getObject(parserExt.getId());
// if not found in cache, instantiate the Parser
} else {
try {
Parser p = (Parser) parserExt.getExtensionInstance();
this.conf.setObject(parserExt.getId(), p);
return p;
} catch (PluginRuntimeException e) {
if (LOG.isWarnEnabled()) {
LOG.warn("Canno initialize parser " +
parserExt.getDescriptor().getPluginId() +
" (cause: " + e.toString());
}
throw new ParserNotFound("Cannot init parser for id [" + id + "]");
}
}