public static BackendQueueProcessor createBackend(String backend,
DirectoryBasedIndexManager indexManager,
WorkerBuildContext buildContext,
Properties properties) {
final BackendQueueProcessor backendQueueProcessor;
if ( StringHelper.isEmpty( backend ) || "lucene".equalsIgnoreCase( backend ) ) {
backendQueueProcessor = new LuceneBackendQueueProcessor();
}
else if ( "jms".equalsIgnoreCase( backend ) ) {
backendQueueProcessor = ClassLoaderHelper.instanceFromName(
BackendQueueProcessor.class,
JMS_BACKEND_QUEUE_PROCESSOR,
"JMS backend ",
buildContext.getServiceManager()
);
}
else if ( "blackhole".equalsIgnoreCase( backend ) ) {
backendQueueProcessor = new BlackHoleBackendQueueProcessor();
}
else if ( "jgroupsMaster".equals( backend ) ) {
backendQueueProcessor = createJGroupsQueueProcessor( JGROUPS_MASTER_SELECTOR, buildContext );
}
else if ( "jgroupsSlave".equals( backend ) ) {
backendQueueProcessor = createJGroupsQueueProcessor( JGROUPS_SLAVE_SELECTOR, buildContext );
}
else if ( "jgroups".equals( backend ) ) {
Class<?> selectorClass = ClassLoaderHelper.classForName(
JGROUPS_AUTO_SELECTOR,
"JGroups node selector ",
buildContext.getServiceManager()
);
final Constructor constructor;
final Object autoNodeSelector;
try {
constructor = selectorClass.getConstructor( String.class );
autoNodeSelector = constructor.newInstance( indexManager.getIndexName() );
}
catch (Exception e) {
throw log.getUnableToCreateJGroupsBackendException( e );
}
backendQueueProcessor = createJGroupsQueueProcessor( autoNodeSelector, buildContext.getServiceManager() );
}
else {
ServiceManager serviceManager = buildContext.getServiceManager();
backendQueueProcessor = ClassLoaderHelper.instanceFromName(
BackendQueueProcessor.class,
backend,
"processor",
serviceManager
);
}
backendQueueProcessor.initialize( properties, buildContext, indexManager );
return backendQueueProcessor;
}