Use AutoService library to generate Java SPI files in Ignite 3
Dear Igniters! In Ignite 3, we have a bunch of classes that utilize the Java SPI (ConfigurationModule and MetricsExporter to name a few). For every interface implementation we need to manually create a file in the META-INF folder. This step can be automated by the AutoService library [1]. I can see the following pros and cons of using this approach: 1. Pros: * Less manual boilerplate, * This is a compile-time only dependency (an annotation and an annotation processor), * Less files to maintain and update/move when corresponding interfaces change. 2. Cons: * A new dependency will be introduced and it looks like the community doesn't like that. I've created a PR [2] with a demonstration how this library can be used in the existing code base. [1] https://github.com/google/auto/tree/main/service [2] https://github.com/apache/ignite-3/pull/1415 -- With regards, Aleksandr Polovtsev
Re: Use AutoService library to generate Java SPI files in Ignite 3
Hi Aleksandr, This suggestion seems useful to me. As Aleksandr pointed out, this is a compile-time dependency, so it doesn't look risky. +1 Thanks, Slava. ср, 7 дек. 2022 г. в 10:20, Aleksandr Polovtsev : > Dear Igniters! In Ignite 3, we have a bunch of classes that utilize the > Java SPI (ConfigurationModule and MetricsExporter to name a few). For every > interface implementation we need to manually create a file in the META-INF > folder. This step can be automated by the AutoService library [1]. > > I can see the following pros and cons of using this approach: > 1. Pros: > * Less manual boilerplate, > * This is a compile-time only dependency (an annotation and an annotation > processor), > * Less files to maintain and update/move when corresponding interfaces > change. > 2. Cons: > * A new dependency will be introduced and it looks like the community > doesn't like that. > > I've created a PR [2] with a demonstration how this library can be used in > the existing code base. > > [1] https://github.com/google/auto/tree/main/service > [2] https://github.com/apache/ignite-3/pull/1415 > > -- > With regards, > Aleksandr Polovtsev >
Re: Use AutoService library to generate Java SPI files in Ignite 3
Hello, I'm all in for this change, thank you for the PR! +1 ср, 7 дек. 2022 г. в 12:15, Вячеслав Коптилин : > Hi Aleksandr, > > This suggestion seems useful to me. > As Aleksandr pointed out, this is a compile-time dependency, so it doesn't > look risky. > > +1 > > Thanks, > Slava. > > > ср, 7 дек. 2022 г. в 10:20, Aleksandr Polovtsev : > > > Dear Igniters! In Ignite 3, we have a bunch of classes that utilize the > > Java SPI (ConfigurationModule and MetricsExporter to name a few). For > every > > interface implementation we need to manually create a file in the > META-INF > > folder. This step can be automated by the AutoService library [1]. > > > > I can see the following pros and cons of using this approach: > > 1. Pros: > > * Less manual boilerplate, > > * This is a compile-time only dependency (an annotation and an > annotation > > processor), > > * Less files to maintain and update/move when corresponding interfaces > > change. > > 2. Cons: > > * A new dependency will be introduced and it looks like the community > > doesn't like that. > > > > I've created a PR [2] with a demonstration how this library can be used > in > > the existing code base. > > > > [1] https://github.com/google/auto/tree/main/service > > [2] https://github.com/apache/ignite-3/pull/1415 > > > > -- > > With regards, > > Aleksandr Polovtsev > > > -- Sincerely yours, Ivan Bessonov
Re: Use AutoService library to generate Java SPI files in Ignite 3
Hello, Very useful change, huge +1 ср, 7 дек. 2022 г. в 13:01, Ivan Bessonov : > Hello, > > I'm all in for this change, thank you for the PR! > > +1 > > ср, 7 дек. 2022 г. в 12:15, Вячеслав Коптилин : > > > Hi Aleksandr, > > > > This suggestion seems useful to me. > > As Aleksandr pointed out, this is a compile-time dependency, so it > doesn't > > look risky. > > > > +1 > > > > Thanks, > > Slava. > > > > > > ср, 7 дек. 2022 г. в 10:20, Aleksandr Polovtsev >: > > > > > Dear Igniters! In Ignite 3, we have a bunch of classes that utilize the > > > Java SPI (ConfigurationModule and MetricsExporter to name a few). For > > every > > > interface implementation we need to manually create a file in the > > META-INF > > > folder. This step can be automated by the AutoService library [1]. > > > > > > I can see the following pros and cons of using this approach: > > > 1. Pros: > > > * Less manual boilerplate, > > > * This is a compile-time only dependency (an annotation and an > > annotation > > > processor), > > > * Less files to maintain and update/move when corresponding > interfaces > > > change. > > > 2. Cons: > > > * A new dependency will be introduced and it looks like the community > > > doesn't like that. > > > > > > I've created a PR [2] with a demonstration how this library can be used > > in > > > the existing code base. > > > > > > [1] https://github.com/google/auto/tree/main/service > > > [2] https://github.com/apache/ignite-3/pull/1415 > > > > > > -- > > > With regards, > > > Aleksandr Polovtsev > > > > > > > > -- > Sincerely yours, > Ivan Bessonov >
Re: Ignite support for IoC beyond spring framework
Hello, I would like to check again status on proposed changes as the pull request went over first (and I think second) cycle of reviews. Looking forward for your feedback and possibility to include these changes in Ignite 2.15 release. Kind regards, Łukasz On 17.10.2022 18:56, Łukasz Dywicki wrote: Going forward over evaluation - I think for naming consistency reasons we shall stay with @InjectResource cause other annotations which bring outside values are @SpringResource, @LoggerResource and @IgniteInstanceResource. Making it @IgniteInject is fine for me too, but it might not fit into existing package contents. WDYT? Best, Łukasz On 17.10.2022 16:48, Łukasz Dywicki wrote: I created https://issues.apache.org/jira/browse/IGNITE-17915. Going to try updating code and see how much impact it will have. Best, Łukasz On 14.10.2022 20:21, Łukasz Dywicki wrote: Hello Semyon, I wasn't sure if deprecation of @SpringResource would be acceptable, if so It gives us more flexibility in bringing IoC adapter layer. Linked code is just fitted into existing boundaries, but I can update it to deal with @IgniteInject. I will register feature request/improvement in JIRA and start working on it next week. Kind regards, Łukasz On 14.10.2022 16:26, Данилов Семён wrote: Hi! This sounds like a good enhancement. Feel free to create a pull request! As I see it, for now we should continue using SpringResource annotation (even if it injects non-spring resources), but at the same time create a new annotation (maybe something like @IgniteInject, I am bad with naming) and deprecate SpringResource annotation. Both annotations should work exactly the same. Then we will have a spring version of injector interface and some generic version that any user can extend and use without spring. WDYT? P.S. You can create a JIRA ticket and mention me there, I'll be happy to review and merge your PR Kind regards, Semyon. Hello, I would like to bring a proposal for Ignite to include support for @SpringResource without spring at all. We currently use ignite without Spring Framework and, to make things harder, under OSGi. As a part of exercise couple weeks ago I implemented support for IoC [1] in environment we run. I did it by simulating spring's ApplicationContext instance expected by IgnitionEx [2] and GridSpringResourceContext. Turns out that Ignite IoC is fine with below API: public interface BeanRegistry { T lookup(Class type); Object lookup(String name); } Given that we look forward to keep use of Ignite I was asked to contribute my work back to your project. Would you be up to discuss, and if agreed, guide me on a shape of ioc updates which would best fit Ignite itself? If you do not expect changes in Spring integration then, maybe we could get a working solution within ignite-osgi itself? Best, Łukasz [1] https://github.com/OpenNMS/horizon-stream/tree/develop/minion/minion-taskset/taskset-worker/src/main/java/org/opennms/horizon/minion/taskset/worker/ignite/resource [2] https://github.com/OpenNMS/horizon-stream/blob/develop/minion/minion-taskset/taskset-worker/src/main/java/org/opennms/horizon/minion/taskset/worker/ignite/IgnitionFactory.java#L15