[ 
https://issues.apache.org/jira/browse/TIKA-1700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14650483#comment-14650483
 ] 

Nick Burch commented on TIKA-1700:
----------------------------------

Unfortunately, your patch doesn't apply any more, as I refactored a lot of that 
logic just now, sorry!

However, having looked at the patch, I'm not sure it's tackling the problem in 
the right place. Why would you want to set dynamic loading to true or false in 
the tika config xml for a parser? Would we not be better to add an overloaded 
method to TikaConfig that took a ServiceLoader, alongside the ClassLoader one? 
That way, instead of needing to mess around in the config xml, for your OSGi 
case you could instead do:
{code}
  ServiceLoader loader = new ServiceLoader(dynamicClassLoader, 
LoadErrorHandler.THROW, true);
  TikaConfig config = new TikaConfig(new File("/path/to/config.xml").toURL(), 
loader);
{code}
Or have I missed something about the need / use-case?

> tika-config.xml does not provide a way to set ServiceLoader to dynamic
> ----------------------------------------------------------------------
>
>                 Key: TIKA-1700
>                 URL: https://issues.apache.org/jira/browse/TIKA-1700
>             Project: Tika
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.7, 1.8, 1.9, 1.10
>         Environment: OSGi
>            Reporter: Bob Paulin
>         Attachments: TIKA-1700.patch, TIKA-1700A.patch
>
>
> Currently if you create a TikaConfig from a file (ex tika-config.xml).  There 
> is no way to specify that you want to use a ServiceLoader with dynamic set.  
> Prior to tika 1.7 this was not an issue since the during the tika-config.xml 
> parse Tika would instantiate parsers using the default constructor which in 
> turn would instantiate a new ServiceLoader.  The default ServiceLoader 
> constructor sets dynamic to true which allows dynamic loading of parsers.  
> Changes to TikaConfig now cause the tika-config.xml parse to call a 
> constructor which passes the ServiceLoader to be passed as a parameter.  This 
> ServiceLoader is always constructed with a Classloader which will cause 
> dynamic to always be set to false.  This breaks Tika in OSGi environments 
> which depend on dynamic being set to true (for example Apache Sling). 
> I'm proposing adding an xml attribute to the parser element to instantiate 
> the parser with dynamic set to true.  This allows users of tika-config.xml to 
> determine how they want parsers loaded. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to