org.apache.tika.config
Class ServiceLoader

java.lang.Object
  extended by org.apache.tika.config.ServiceLoader

public class ServiceLoader
extends java.lang.Object

Internal utility class that Tika uses to look up service providers.

Since:
Apache Tika 0.9

Constructor Summary
ServiceLoader()
           
ServiceLoader(java.lang.ClassLoader loader)
           
ServiceLoader(java.lang.ClassLoader loader, LoadErrorHandler handler)
           
 
Method Summary
 java.util.Enumeration<java.net.URL> findServiceResources(java.lang.String filePattern)
          Returns all the available service resources matching the given pattern, such as all instances of tika-mimetypes.xml on the classpath, or all org.apache.tika.parser.Parser service files.
<T> java.util.List<T>
loadServiceProviders(java.lang.Class<T> service)
          Returns all the available service providers of the given type.
static void setContextClassLoader(java.lang.ClassLoader loader)
          Sets the context class loader to use for all threads that access this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceLoader

public ServiceLoader(java.lang.ClassLoader loader,
                     LoadErrorHandler handler)

ServiceLoader

public ServiceLoader(java.lang.ClassLoader loader)

ServiceLoader

public ServiceLoader()
Method Detail

setContextClassLoader

public static void setContextClassLoader(java.lang.ClassLoader loader)
Sets the context class loader to use for all threads that access this class. Used for example in an OSGi environment to avoid problems with the default context class loader.

Parameters:
loader - default context class loader, or null to automatically pick the loader

findServiceResources

public java.util.Enumeration<java.net.URL> findServiceResources(java.lang.String filePattern)
Returns all the available service resources matching the given pattern, such as all instances of tika-mimetypes.xml on the classpath, or all org.apache.tika.parser.Parser service files.


loadServiceProviders

public <T> java.util.List<T> loadServiceProviders(java.lang.Class<T> service)
Returns all the available service providers of the given type.

Parameters:
service - service provider interface
Returns:
available service providers


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.