File tree Expand file tree Collapse file tree
tika-annotation-processor/src/main/java/org/apache/tika/annotation
tika-core/src/main/java/org/apache/tika/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -337,6 +337,8 @@ private void writeServiceFiles() {
337337 writer .write ("# Generated by TikaComponentProcessor\n " );
338338 writer .write ("# Do not edit manually\n " );
339339 for (String impl : sortedImplementations ) {
340+ // add comments for Bnd to generate OSGi metadata for Service Mediator spec (https://bnd.bndtools.org/chapters/230-manifest-annotations.html#meta-infservices-annotations)
341+ writer .write ("#@aQute.bnd.annotation.spi.ServiceProvider()\n " );
340342 writer .write (impl );
341343 writer .write ("\n " );
342344 }
Original file line number Diff line number Diff line change 3434import java .util .Set ;
3535import java .util .regex .Pattern ;
3636
37+ import aQute .bnd .annotation .spi .ServiceConsumer ;
38+
39+ import org .apache .tika .detect .Detector ;
3740import org .apache .tika .exception .TikaConfigException ;
41+ import org .apache .tika .parser .Parser ;
3842import org .apache .tika .utils .ServiceLoaderUtils ;
3943
4044/**
4145 * Internal utility class that Tika uses to look up service providers.
46+ * Supports both static service loading using the {@link ServiceLoader} mechanism (and via
47+ * <a href="https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.loader.html">OSGi Service Loader Mediator</a>)
48+ * as well as dynamic loading via OSGi service tracking (from the {@link TikaActivator} class).
49+ * However the Tika parsers don't register as regular OSGi services,
50+ * so the dynamic loading is only used for detectors and parser services from non-Tika bundles.
4251 *
4352 * @since Apache Tika 0.9
4453 */
54+ @ ServiceConsumer (Parser .class )
55+ @ ServiceConsumer (Detector .class )
4556public class ServiceLoader {
4657
4758 /**
Original file line number Diff line number Diff line change 283283
284284 <properties >
285285 <revision >4.0.0-SNAPSHOT</revision >
286+ <javaVersion >17</javaVersion >
286287 <maven .compiler.source>17</maven .compiler.source>
287288 <maven .compiler.target>17</maven .compiler.target>
288289 <maven .compiler.release>17</maven .compiler.release>
14621463 <groupId >org.apache.felix</groupId >
14631464 <artifactId >maven-bundle-plugin</artifactId >
14641465 <version >${maven.bundle.version} </version >
1466+ <configuration >
1467+ <instructions >
1468+ <!-- https://bnd.bndtools.org/instructions/metainf_services.html -->
1469+ <_metainf-services >auto</_metainf-services >
1470+ </instructions >
1471+ </configuration >
1472+ <dependencies >
1473+ <!-- upgrade to a newer version of Bnd to leverage https://bnd.bndtools.org/chapters/230-manifest-annotations.html#meta-infservices-annotations -->
1474+ <dependency >
1475+ <groupId >biz.aQute.bnd</groupId >
1476+ <artifactId >biz.aQute.bndlib</artifactId >
1477+ <version >${biz.aqute.version} </version >
1478+ </dependency >
1479+ </dependencies >
14651480 </plugin >
14661481 <plugin >
14671482 <groupId >org.apache.maven.plugins</groupId >
You can’t perform that action at this time.
0 commit comments