use of org.apache.tika.config.ServiceLoader in project tika by apache.
the class ProbabilisticMimeDetectionTestWithTika method setUp.
/** @inheritDoc */
@Before
public void setUp() {
MimeTypes types = MimeTypes.getDefaultMimeTypes();
ServiceLoader loader = new ServiceLoader();
registry = types.getMediaTypeRegistry();
/*
* here is an example with the use of the builder to
* instantiate the object.
*/
Builder builder = new ProbabilisticMimeDetectionSelector.Builder();
proSelector = new ProbabilisticMimeDetectionSelector(types, builder.priorMagicFileType(0.5f).priorExtensionFileType(0.5f).priorMetaFileType(0.5f));
DefaultProbDetector detector = new DefaultProbDetector(proSelector, loader);
// Use a default Tika, except for our different detector
tika = new Tika(detector);
}
use of org.apache.tika.config.ServiceLoader in project tika by apache.
the class HtmlParserTest method testMultiThreadingEncodingDetection.
@Test
public void testMultiThreadingEncodingDetection() throws Exception {
List<EncodingDetector> detectors = new ArrayList<>();
ServiceLoader loader = new ServiceLoader(AutoDetectReader.class.getClassLoader());
detectors.addAll(loader.loadServiceProviders(EncodingDetector.class));
for (EncodingDetector detector : detectors) {
testDetector(detector);
}
}
Aggregations