Author: jukka
Date: Tue May 4 16:04:51 2010
New Revision: 940926
URL: http://svn.apache.org/viewvc?rev=940926&view=rev
Log:
TIKA-419: Allow parser lookup from a custom class loader
Modified:
lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
Modified:
lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
URL:
http://svn.apache.org/viewvc/lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java?rev=940926&r1=940925&r2=940926&view=diff
==============================================================================
---
lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
(original)
+++
lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
Tue May 4 16:04:51 2010
@@ -147,10 +147,21 @@ public class TikaConfig {
}
}
- public TikaConfig() throws MimeTypeException, IOException {
+ /**
+ * Creates a Tika configuration from the built-in media type rules
+ * and all the {...@link Parser} implementations available through the
+ * {...@link ServiceRegistry service provider mechanism} in the given
+ * class loader.
+ *
+ * @since Apache Tika 0.8
+ * @throws MimeTypeException if the built-in media type rules are broken
+ * @throws IOException if the built-in media type rules can not be read
+ */
+ public TikaConfig(ClassLoader loader)
+ throws MimeTypeException, IOException {
ParseContext context = new ParseContext();
Iterator<Parser> iterator =
- ServiceRegistry.lookupProviders(Parser.class);
+ ServiceRegistry.lookupProviders(Parser.class, loader);
while (iterator.hasNext()) {
Parser parser = iterator.next();
for (MediaType type : parser.getSupportedTypes(context)) {
@@ -161,6 +172,19 @@ public class TikaConfig {
}
/**
+ * Creates a Tika configuration from the built-in media type rules
+ * and all the {...@link Parser} implementations available through the
+ * {...@link ServiceRegistry service provider mechanism} in the context
+ * class loader of the current thread.
+ *
+ * @throws MimeTypeException if the built-in media type rules are broken
+ * @throws IOException if the built-in media type rules can not be read
+ */
+ public TikaConfig() throws MimeTypeException, IOException {
+ this(Thread.currentThread().getContextClassLoader());
+ }
+
+ /**
* @deprecated This method will be removed in Apache Tika 1.0
* @see <a
href="https://issues.apache.org/jira/browse/TIKA-275">TIKA-275</a>
*/