public static ReaderProvider createReaderProvider(SearchConfiguration cfg,
SearchFactoryImplementor searchFactoryImplementor) {
Properties props = getProperties( cfg );
String impl = props.getProperty( Environment.READER_STRATEGY );
ReaderProvider readerProvider;
if ( StringHelper.isEmpty( impl ) ) {
//put another one
readerProvider = new SharingBufferReaderProvider();
}
else if ( "not-shared".equalsIgnoreCase( impl ) ) {
readerProvider = new NotSharedReaderProvider();
}
else if ( "shared".equalsIgnoreCase( impl ) ) {
readerProvider = new SharingBufferReaderProvider();
}
//will remove next "else":
else if ( "shared-segments".equalsIgnoreCase( impl ) ) {
readerProvider = new SharingBufferReaderProvider();
}
else {
try {
Class readerProviderClass = ReflectHelper.classForName( impl, ReaderProviderFactory.class );
readerProvider = (ReaderProvider) readerProviderClass.newInstance();
}
catch (ClassNotFoundException e) {
throw new SearchException( "Unable to find readerProvider class: " + impl, e );
}
catch (IllegalAccessException e) {
throw new SearchException( "Unable to instanciate readerProvider class: " + impl, e );
}
catch (InstantiationException e) {
throw new SearchException( "Unable to instanciate readerProvider class: " + impl, e );
}
}
readerProvider.initialize( props, searchFactoryImplementor );
return readerProvider;
}
|