You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ni...@apache.org on 2014/06/09 16:38:16 UTC
svn commit: r1601395 -
/tika/trunk/tika-core/src/main/java/org/apache/tika/config/ServiceLoader.java
Author: nick
Date: Mon Jun 9 14:38:16 2014
New Revision: 1601395
URL: http://svn.apache.org/r1601395
Log:
To support OSGi testing, allow for a test class to find out what class names ServiceLoader.loadStaticServiceProviders will try, helps TIKA-1276
Modified:
tika/trunk/tika-core/src/main/java/org/apache/tika/config/ServiceLoader.java
Modified: tika/trunk/tika-core/src/main/java/org/apache/tika/config/ServiceLoader.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/config/ServiceLoader.java?rev=1601395&r1=1601394&r2=1601395&view=diff
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/config/ServiceLoader.java (original)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/config/ServiceLoader.java Mon Jun 9 14:38:16 2014
@@ -260,22 +260,19 @@ public class ServiceLoader {
}
/**
- * Returns the available static service providers of the given type.
+ * Returns the defined static service providers of the given type, without
+ * attempting to load them.
* The providers are loaded using the service provider mechanism using
- * the configured class loader (if any). The returned list is newly
- * allocated and may be freely modified by the caller.
+ * the configured class loader (if any).
*
- * @since Apache Tika 1.2
+ * @since Apache Tika 1.6
* @param iface service provider interface
- * @return static service providers
+ * @return static list of uninitialised service providers
*/
- @SuppressWarnings("unchecked")
- public <T> List<T> loadStaticServiceProviders(Class<T> iface) {
- List<T> providers = new ArrayList<T>();
+ protected <T> List<String> identifyStaticServiceProviders(Class<T> iface) {
+ List<String> names = new ArrayList<String>();
if (loader != null) {
- List<String> names = new ArrayList<String>();
-
String serviceName = iface.getName();
Enumeration<URL> resources =
findServiceResources("META-INF/services/" + serviceName);
@@ -286,6 +283,27 @@ public class ServiceLoader {
handler.handleLoadError(serviceName, e);
}
}
+ }
+
+ return names;
+ }
+
+ /**
+ * Returns the available static service providers of the given type.
+ * The providers are loaded using the service provider mechanism using
+ * the configured class loader (if any). The returned list is newly
+ * allocated and may be freely modified by the caller.
+ *
+ * @since Apache Tika 1.2
+ * @param iface service provider interface
+ * @return static service providers
+ */
+ @SuppressWarnings("unchecked")
+ public <T> List<T> loadStaticServiceProviders(Class<T> iface) {
+ List<T> providers = new ArrayList<T>();
+
+ if (loader != null) {
+ List<String> names = identifyStaticServiceProviders(iface);
for (String name : names) {
try {