[
https://issues.apache.org/jira/browse/TIKA-4700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18068398#comment-18068398
]
ASF GitHub Bot commented on TIKA-4700:
--------------------------------------
kwin commented on code in PR #2714:
URL: https://github.com/apache/tika/pull/2714#discussion_r2989797746
##########
tika-core/src/main/java/org/apache/tika/config/ServiceLoader.java:
##########
@@ -34,14 +34,25 @@
import java.util.Set;
import java.util.regex.Pattern;
+import aQute.bnd.annotation.spi.ServiceConsumer;
+
+import org.apache.tika.detect.Detector;
import org.apache.tika.exception.TikaConfigException;
+import org.apache.tika.parser.Parser;
import org.apache.tika.utils.ServiceLoaderUtils;
/**
* Internal utility class that Tika uses to look up service providers.
+ * Supports both static service loading using the {@link ServiceLoader}
mechanism (and via
+ * <a
href="https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.loader.html">OSGi
Service Loader Mediator</a>)
+ * as well as dynamic loading via OSGi service tracking (from the {@link
TikaActivator} class).
+ * However the Tika parsers don't register as regular OSGi services,
+ * so the dynamic loading is only used for detectors and parser services from
non-Tika bundles.
*
* @since Apache Tika 0.9
*/
+@ServiceConsumer(Parser.class)
+@ServiceConsumer(Detector.class)
Review Comment:
What about the other service interfaces being mentioned at
https://github.com/apache/tika/blob/84166bafb9bffb8ff166ee5f3394de6456555e3d/tika-annotation-processor/src/main/java/org/apache/tika/annotation/TikaComponentProcessor.java#L76-L82?
Are those looked up via this class as well?
> Support OSGi Service Loader Mediator Spec
> -----------------------------------------
>
> Key: TIKA-4700
> URL: https://issues.apache.org/jira/browse/TIKA-4700
> Project: Tika
> Issue Type: Improvement
> Reporter: Konrad Windszus
> Priority: Major
>
> The [Java Service
> Loader|https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html]
> is not properly supported in OSGi cross bundle boundaries due to Classloader
> visibility restrictions. In order to circumvent this limitation the [OSGi
> Service Loader Mediator
> Specification|https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.loader.html]
> defines certain {{Capabilities}} which are used to set up a registry where
> all bundles have access to providers (no matter from which bundles).
> This mechanism is just relying on additional Manifest headers which don't
> impact usability of those JARs outside OSGi.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)