/** * Loads a class and instantiates it * @param className service class name * @param <T> service type * @return instance of service */ public static <T> T newInstance(String className) { return newInstance(className, ServiceLoader.class.getClassLoader()); }
private static List<Detector> getDefaultDetectors( ProbabilisticMimeDetectionSelector sel, ServiceLoader loader) { List<Detector> detectors = loader.loadStaticServiceProviders(Detector.class); ServiceLoaderUtils.sortLoadedClasses(detectors); detectors.add(sel); return detectors; }
@Field(name = "class") public void setRecogniser(String recogniserClass) { this.recogniser = ServiceLoaderUtils.newInstance(recogniserClass); }
/** * Finds all statically loadable detectors and sort the list by name, * rather than discovery order. Detectors are used in the given order, * so put the Tika parsers last so that non-Tika (user supplied) * parsers can take precedence. * * @param loader service loader * @return ordered list of statically loadable detectors */ private static List<Detector> getDefaultDetectors( MimeTypes types, ServiceLoader loader) { List<Detector> detectors = loader.loadStaticServiceProviders(Detector.class); ServiceLoaderUtils.sortLoadedClasses(detectors); // Finally the Tika MimeTypes as a fallback detectors.add(types); return detectors; }
/** * Loads a class and instantiates it * @param className service class name * @param <T> service type * @return instance of service */ public static <T> T newInstance(String className) { return newInstance(className, ServiceLoader.class.getClassLoader()); }
/** * Finds all statically loadable parsers and sort the list by name, * rather than discovery order. CompositeParser takes the last * parser for any given media type, so put the Tika parsers first * so that non-Tika (user supplied) parsers can take precedence. * * @param loader service loader * @return ordered list of statically loadable parsers */ private static List<Parser> getDefaultParsers(ServiceLoader loader, EncodingDetector encodingDetector) { List<Parser> parsers = loader.loadStaticServiceProviders(Parser.class); if (encodingDetector != null) { for (Parser p : parsers) { setEncodingDetector(p, encodingDetector); } } ServiceLoaderUtils.sortLoadedClasses(parsers); return parsers; }
/** * Loads a class and instantiates it * @param className service class name * @param <T> service type * @return instance of service */ public static <T> T newInstance(String className) { return newInstance(className, ServiceLoader.class.getClassLoader()); }
private static List<Detector> getDefaultDetectors( ProbabilisticMimeDetectionSelector sel, ServiceLoader loader) { List<Detector> detectors = loader.loadStaticServiceProviders(Detector.class); ServiceLoaderUtils.sortLoadedClasses(detectors); detectors.add(sel); return detectors; }
@Field(name = "class") public void setRecogniser(String recogniserClass) { this.recogniser = ServiceLoaderUtils.newInstance(recogniserClass); }
private static List<Detector> getDefaultDetectors( ProbabilisticMimeDetectionSelector sel, ServiceLoader loader) { List<Detector> detectors = loader.loadStaticServiceProviders(Detector.class); ServiceLoaderUtils.sortLoadedClasses(detectors); detectors.add(sel); return detectors; }
@Field(name = "class") public void setRecogniser(String recogniserClass) { this.recogniser = ServiceLoaderUtils.newInstance(recogniserClass); }
/** * Finds all statically loadable parsers and sort the list by name, * rather than discovery order. CompositeParser takes the last * parser for any given media type, so put the Tika parsers first * so that non-Tika (user supplied) parsers can take precedence. * * @param loader service loader * @return ordered list of statically loadable parsers */ private static List<Parser> getDefaultParsers(ServiceLoader loader) { List<Parser> parsers = loader.loadStaticServiceProviders(Parser.class); ServiceLoaderUtils.sortLoadedClasses(parsers); return parsers; }
/** * Finds all statically loadable detectors and sort the list by name, * rather than discovery order. Detectors are used in the given order, * so put the Tika parsers last so that non-Tika (user supplied) * parsers can take precedence. * * @param loader service loader * @return ordered list of statically loadable detectors */ private static List<Detector> getDefaultDetectors( MimeTypes types, ServiceLoader loader) { List<Detector> detectors = loader.loadStaticServiceProviders(Detector.class); ServiceLoaderUtils.sortLoadedClasses(detectors); // Finally the Tika MimeTypes as a fallback detectors.add(types); return detectors; }
/** * Finds all statically loadable detectors and sort the list by name, * rather than discovery order. Detectors are used in the given order, * so put the Tika parsers last so that non-Tika (user supplied) * parsers can take precedence. * * @param loader service loader * @return ordered list of statically loadable detectors */ private static List<Detector> getDefaultDetectors( MimeTypes types, ServiceLoader loader) { List<Detector> detectors = loader.loadStaticServiceProviders(Detector.class); ServiceLoaderUtils.sortLoadedClasses(detectors); // Finally the Tika MimeTypes as a fallback detectors.add(types); return detectors; }
/** * Finds all statically loadable parsers and sort the list by name, * rather than discovery order. CompositeParser takes the last * parser for any given media type, so put the Tika parsers first * so that non-Tika (user supplied) parsers can take precedence. * * @param loader service loader * @return ordered list of statically loadable parsers */ private static List<Parser> getDefaultParsers(ServiceLoader loader, EncodingDetector encodingDetector) { List<Parser> parsers = loader.loadStaticServiceProviders(Parser.class); if (encodingDetector != null) { for (Parser p : parsers) { setEncodingDetector(p, encodingDetector); } } ServiceLoaderUtils.sortLoadedClasses(parsers); return parsers; }