tika-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bob Paulin (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TIKA-1910) Tika 2.0 - Decouple Tika Parser Office Module from Other Dependencies
Date Tue, 05 Apr 2016 01:26:25 GMT

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

Bob Paulin commented on TIKA-1910:
----------------------------------

Thinking of a way to pass the ServiceLoader...

Allow Detectors, Parsers, and EncodingDetectors to leverage ServiceLoader in Constructor:
Move object instantiation into the ServiceLoader class (replaces all instances of klass.newInstance()
in ServiceLoader and TikaConfig
{code}
public <T> T createServiceInstance(Class<?> klass)
            throws InstantiationException, IllegalAccessException, InvocationTargetException
{
        T serviceInstance = null;
        try{
            serviceInstance = 
                    (T)klass.getConstructor(ServiceLoader.class).newInstance(this);
        }catch(NoSuchMethodException e) {}
        if(serviceInstance == null)
        {
            serviceInstance = (T) klass.newInstance();
        }
        return serviceInstance;
    }
{code}

Then newInstance becomes
{code}
loaded = loader.createServiceInstance(loadedClass);
{code}

And service classes can have ServiceLoader Constructors:

{code}
     public ChmParser(ServiceLoader serviceLoader) {
        
        this.htmlProxy = serviceLoader.getProxyService("org.apache.tika.parser.html.HtmlParser",
Parser.class, ChmParser.class.getClassLoader());
    }
{code}

Thoughts on this approach?   Or is the no arg constructor sacred?



> Tika 2.0 - Decouple Tika Parser Office Module from Other Dependencies
> ---------------------------------------------------------------------
>
>                 Key: TIKA-1910
>                 URL: https://issues.apache.org/jira/browse/TIKA-1910
>             Project: Tika
>          Issue Type: Improvement
>    Affects Versions: 2.0
>            Reporter: Bob Paulin
>            Assignee: Bob Paulin
>
> Currently the Tika Parser Office Module depends on 
> Tika Parser Web Module
> Tika Parser Package Module
> Tika Parser Text Module
> Using the proxies we can make those dependencies optional so if they are not included
on the classpath the code functions but performs no operation on content that would be parsed
on the optional dependencies.



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

Mime
View raw message