You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Piotr Karwasz (Jira)" <ji...@apache.org> on 2023/10/18 12:28:00 UTC

[jira] [Created] (LOGGING-186) Use ServiceLoader class

Piotr Karwasz created LOGGING-186:
-------------------------------------

             Summary: Use ServiceLoader class
                 Key: LOGGING-186
                 URL: https://issues.apache.org/jira/browse/LOGGING-186
             Project: Commons Logging
          Issue Type: Bug
    Affects Versions: 1.2
            Reporter: Piotr Karwasz


The current service loader code used by {{LogFactory}} predates the {{ServiceLoader}} class introduced in Java 6 by 4 years and is a simplified version of it.

This has many disadvantages:

* the service loader file can *not* have any comments, like a license header or the name of the tool that generated the service file. Commons Logging just takes the first line in the file and uses it as the class name,
 * the Service Loader Mediator OSGi specification allows to use {{ServiceLoader}} in an OSGi environment, but it might ignore direct accesses to {{META-INF/services}} resources (cf. [Apache Aries SPI Fly|https://aries.apache.org/documentation/modules/spi-fly.html]),
 * in a JPMS environment, the {{META-INF/services}} file could even not be there and the service is declared in the module descriptor.



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