Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdi-dev] Guice to CDI migration

Hi all,

So finally after going through CDI docs (Weld documentation), I gave it a try and found that `@Specializes` is the exact replacement for Guice linked binding. However, `@Alternative` with `@Priority` can do the same and we can have much better control. So that's a better option. Thanks Emily, Matej for the hints.

Regards
--
Amit Mendapara

604, Luxuria Business Hub,
Near V. R. Mall, Dumas Road,
Surat - 395007 (India)
Phone: (+91) 261 297 7840


On Wed, Mar 11, 2020 at 8:34 PM Amit MENDAPARA - Axelor <amit@xxxxxxxxxx> wrote:
Thanks Reza,

You are the motivation I am here on this mailing list to discuss this migration and I think it can be a good case study for others too. I will share my experience for sure. Thank you again.

Regards
--
Amit Mendapara

604, Luxuria Business Hub,
Near V. R. Mall, Dumas Road,
Surat - 395007 (India)
Phone: (+91) 261 297 7840


On Wed, Mar 11, 2020 at 8:28 PM reza_rahman <reza_rahman@xxxxxxxxx> wrote:
Just a small suggestion - it would be awesome if after the migration is done, you could consider writing a blog entry on it. I believe it would be highly appreciated in the community. If you gave me a heads up, I would be delighted to spread the word on it.

Reza Rahman
Jakarta EE Ambassador, Author, Blogger, Speaker

Please note views expressed here are my own as an individual community member and do not reflect the views of my employer.

Sent via the Samsung Galaxy S7, an AT&T 4G LTE smartphone


-------- Original message --------
From: Amit MENDAPARA - Axelor <amit@xxxxxxxxxx>
Date: 3/11/20 1:38 AM (GMT-05:00)
To: cdi developer discussions <cdi-dev@xxxxxxxxxxx>
Subject: Re: [cdi-dev] Guice to CDI migration

Hi Emily,
 
I have tried using "@Alternative" but I have to use qualifiers to inject this alternative. Is there any way we can make the CDI container use the "EnhancedGreetingServiceImpl" automatically without any qualifiers (without any changes in module-a or app itself).
I don't think you need to use any qualifier here. You need to use `@Priority` to enable the alternative. The other way to completely override a bean, you can use `@Specializes`.  By the way, I am not 100% sure what your use case is. A working example helps if you need further assistance.


I never used CDI before so it's new to me and I don't know many of it's concepts (I know guice very well so at least DI and AOP concepts might be similar). So I will try your suggestion but on twitter one user recommended me to check `@Specializes` and that seems the proper solution as per it's javadoc.

The project I am going to migrate is relatively complex and there are few more cases I would like to discuss here. I will try to provide a test case example that covers some of them.

Regards
--
Amit Mendapara
 
_______________________________________________
cdi-dev mailing list
cdi-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdi-dev

Back to the top