SOLR-1281: SigUpdateProcFactory now uses SolrResourceLoader

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@803560 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Grant Ingersoll 2009-08-12 15:37:13 +00:00
parent f586a2e3b8
commit bf3968ddaf
1 changed files with 4 additions and 25 deletions

View File

@ -33,6 +33,7 @@ import org.apache.solr.request.SolrQueryResponse;
import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.update.DeleteUpdateCommand;
import org.apache.solr.core.SolrResourceLoader;
public class SignatureUpdateProcessorFactory extends
UpdateRequestProcessorFactory {
@ -100,11 +101,13 @@ public class SignatureUpdateProcessorFactory extends
}
class SignatureUpdateProcessor extends UpdateRequestProcessor {
private final SolrQueryRequest req;
public SignatureUpdateProcessor(SolrQueryRequest req,
SolrQueryResponse rsp, SignatureUpdateProcessorFactory factory,
UpdateRequestProcessor next) {
super(next);
this.req = req;
}
@Override
@ -118,7 +121,7 @@ public class SignatureUpdateProcessorFactory extends
Collections.sort(sigFields);
}
Signature sig = (Signature) loadClass(signatureClass);
Signature sig = (Signature) req.getCore().getResourceLoader().newInstance(signatureClass);
sig.init(params);
for (String field : sigFields) {
@ -166,29 +169,5 @@ public class SignatureUpdateProcessorFactory extends
this.enabled = enabled;
}
/**
* Utility method to dynamically load classes
*/
public static Object loadClass(final String clazz) {
Object loadedClass = null;
Class handlerClass = null;
try {
handlerClass = Class.forName(clazz);
} catch (final NoClassDefFoundError e) {
throw new RuntimeException("Cannot find class : " + clazz, e);
} catch (final ClassNotFoundException e) {
throw new RuntimeException("Cannot find class : " + clazz, e);
}
try {
loadedClass = handlerClass.newInstance();
} catch (final InstantiationException e) {
throw new RuntimeException("Cannot create instance of : " + clazz, e);
} catch (final IllegalAccessException e) {
throw new RuntimeException("Cannot create instance of : " + clazz, e);
}
return loadedClass;
}
}