mirror of https://github.com/apache/lucene.git
SOLR-1612 use isAssignablefrom() and catch noSuchmethodException
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@886690 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d71fd08b71
commit
801f30a955
|
@ -101,24 +101,21 @@ public class EntityProcessorWrapper extends EntityProcessor {
|
|||
}
|
||||
try {
|
||||
Class clazz = DocBuilder.loadClass(trans, context.getSolrCore());
|
||||
if (clazz.newInstance() instanceof Transformer) {
|
||||
if (Transformer.class.isAssignableFrom(clazz)) {
|
||||
transformers.add((Transformer) clazz.newInstance());
|
||||
} else {
|
||||
final Method meth = clazz.getMethod(TRANSFORM_ROW, Map.class);
|
||||
if (meth == null) {
|
||||
String msg = "Transformer :"
|
||||
+ trans
|
||||
+ "does not implement Transformer interface or does not have a transformRow(Map m)method";
|
||||
log.error(msg);
|
||||
throw new DataImportHandlerException(
|
||||
SEVERE, msg);
|
||||
}
|
||||
Method meth = clazz.getMethod(TRANSFORM_ROW, Map.class);
|
||||
transformers.add(new ReflectionTransformer(meth, clazz, trans));
|
||||
}
|
||||
} catch (NoSuchMethodException nsme){
|
||||
String msg = "Transformer :"
|
||||
+ trans
|
||||
+ "does not implement Transformer interface or does not have a transformRow(Map<String.Object> m)method";
|
||||
log.error(msg);
|
||||
wrapAndThrow(SEVERE, nsme,msg);
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to load Transformer: " + aTransArr, e);
|
||||
throw new DataImportHandlerException(SEVERE,
|
||||
e);
|
||||
wrapAndThrow(SEVERE, e,"Unable to load Transformer: " + trans);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue