You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@opennlp.apache.org by "Richard Zowalla (Jira)" <ji...@apache.org> on 2026/09/17 19:45:00 UTC

[jira] [Commented] (OPENNLP-1972) Add a generic provider SPI for service-loaded components

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

Richard Zowalla commented on OPENNLP-1972:
------------------------------------------

PR: https://github.com/apache/opennlp/pull/1308

> Add a generic provider SPI for service-loaded components
> --------------------------------------------------------
>
>                 Key: OPENNLP-1972
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-1972
>             Project: OpenNLP
>          Issue Type: Improvement
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>              Labels: spi
>             Fix For: 3.0.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Adds to {{opennlp.tools.util.ext}} in opennlp\-api:
> \* {{Provider}}: {{name\(\)}}, {{priority\(\)}}, {{isAvailable\(\)}}, {{supports\(ProviderSpec\)}}, {{create\(ProviderSpec\)}}.
> \* {{Providers>}}: created with {{of\(spi\)}}, {{of\(spi, loader\)}} or {{of\(spi, loader, configuration\)}}; {{installed\(\)}}, {{byName\(name\)}}, {{supporting\(spec\)}}, {{select\(spec\)}}, {{configurationKey\(\)}}, {{disabledKey\(\)}}, {{allowedKey\(\)}}.
> \* {{ProviderSpec}}: an optional URI location plus string options.
> \* {{ProviderResolutionException}} with {{UnsatisfiedProviderException}} and {{AmbiguousProviderException}}.
> Each service interface gets its own SPI sub\-interface and service file, so a lookup only instantiates providers of that service interface. {{select}} considers the available providers that support the spec; {{opennlp.provider.}} narrows them to one name, {{opennlp.provider..disabled}} vetoes names and provider classes and {{opennlp.provider..allowed}} restricts which provider classes may be instantiated at all; the highest priority wins and a tie is ambiguous. The keys are read from {{META\-INF/opennlp/providers.properties}} of the class loader used for the lookup, overridden by system properties, or from a source the application passes.
> A provider that fails to load, has an invalid name or throws from {{name\(\)}} or {{priority\(\)}} is skipped while the providers are looked up; one that throws from {{isAvailable\(\)}} or {{supports\(\)}} is left out of that resolution. A class loader that cannot list or read its files fails the lookup with {{ProviderResolutionException}}.
> The implementation is thread\-safe, keeps no static state so that an application server can undeploy an application, and uses no reflection, so a native image needs no metadata for the lookup itself \(OPENNLP\-1954\).
> {{DocumentAnnotatorProvider}} is the first service interface, with {{StemmerAnnotatorProvider}} in opennlp\-runtime.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)