Re: Problems creating custom appender using JPMS service in 3.0.0-beta3

Volkan Yazıcı <[email protected]> Wed, 4 Dec 2024 14:15:59 +0100
Newsgroups gmane.comp.jakarta.log4j.user,gmane.comp.java.openwebbeans.devel
Message-ID <CABDM8gCytowJS1trbu-9boBOnPtmO0WGwDQFDpCr47SiZW_DKA@mail.gmail.com>
--0000000000001bf2f906287196bc
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I agree with Pavel that users should only be required to

   1. Provide the interface implementation
   2. Create the associated `META-INF/services` file entry
   3. [For Java 9 and above] Update their `module-info.java` accordingly

Anything more than this is non-idiomatic. Telling users "but processors are
helpful", "you can manually create the Java file registering your plugin",
etc. is beating around the bush.

On Fri, Nov 29, 2024 at 10:26=E2=80=AFAM PavelTurk <[email protected]=
> wrote:

> Hi Piotr,
>
> On 11/29/24 10:07, Piotr P. Karwasz wrote:
> > Hi Pavel,
> >
> > On 28.11.2024 19:26, PavelTurk wrote:
> >> Thank you very much for your detailed and quick help.
> >>
> >> However, to tell the truth, I=E2=80=99m a bit confused. I=E2=80=99ve b=
een waiting for a
> long time for Log4j to finally work according to the JPMS rules. But in
> your message, you talk about compile-time and, as I understood, the use o=
f
> some plugin-processor (from your project pom):
> >>
> >>           <annotationProcessorPaths>
> >>             <path>
> >> <groupId>org.apache.logging.log4j</groupId>
> >> <artifactId>log4j-plugin-processor</artifactId>
> >>               <version>3.0.0-beta3</version>
> >>             </path>
> >>           </annotationProcessorPaths>
> >>
> >> Doesn=E2=80=99t all this completely contradict JPMS?
> > > (...)
> >> By the way, I noticed something seemed off when I saw code duplication
> in your project:
> >>
> >> @Configurable(elementType =3D Appender.ELEMENT_TYPE, printObject =3D t=
rue)
> >> @Plugin(ConsoleAppender.PLUGIN_NAME)
> >> public final class ConsoleAppender...
> >>
> >> and
> >>
> >> PluginEntry.builder()
> >>   .setKey("console")
> >> .setClassName("org.apache.logging.log4j.core.appender.ConsoleAppender"=
)
> >>   .setName("Console")
> >>   .setNamespace("Core")
> >>   .setElementType("appender")
> >>   .setPrintable(true)
> >>   .get(),
> >>
> >> Or am I mistaken (which is always possible) and misunderstood
> everything?
> >
> > We have an annotation processor that automatically generates the
> required `PluginService` implementation, I don't see how that contradicts
> the principles behind JPMS.
> ...
>
> Let me explain my point of view. But first of all, I want to emphasize
> that I=E2=80=99m not claiming to be right=E2=80=94I could very well be wr=
ong. I=E2=80=99m simply
> saying that using a processor seems incorrect to me.
>
> In the world of JPMS, there=E2=80=99s a service, we implement it, and we =
add it. I
> haven=E2=80=99t heard of a service + PROCESSOR that needs to be used. Can=
 you point
> out any other projects that involve a service + processor? The reasoning =
is
> that we should only need to know the INTERFACE, and we=E2=80=99ll handle =
the
> IMPLEMENTATION ourselves. After all, it=E2=80=99s possible to do without =
it=E2=80=94for
> example, by writing a PluginService manually, which would scan the module
> itself and return the necessary classes or just data(entries) about them.
> That=E2=80=99s why I said that using a processor here seems odd to me. In=
 general,
> I think code generation should only be used as a last resort=E2=80=94for =
example,
> for JPA metamodels=E2=80=94but that=E2=80=99s just my opinion.
>
> I assume module-info was also generated automatically. The problem is tha=
t
> it=E2=80=99s not present in log4j-core-3.0.0-beta3-sources.jar see [1], b=
ut it does
> exist in log4j-core-3.0.0-beta3.jar see [2]. Additionally, it=E2=80=99s n=
ot in the
> repository see [3]. So, it is not possible to see what is in this file. O=
r
> was I looking in the wrong place?
>
> [1]
> https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/3.0.0-=
beta3/log4j-core-3.0.0-beta3-sources.jar
> [2]
> https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/3.0.0-=
beta3/log4j-core-3.0.0-beta3.jar
> [3]
> https://github.com/apache/logging-log4j2/tree/rel/3.0.0-beta3/log4j-core/=
src/main/java
>
> Best regards, Pavel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

--0000000000001bf2f906287196bc--