Hi Basant, let’s say if my request body does not have any decision making property in this case payment type, how can I decide which service bean to invoke? E.g my request body looks like { itemUpc: “123”} and I need to invoke service bean related to item service. How can I do that?
Description: Field serviceRegistry in com.orgName.test.handlers.impl.StrategyHandler required a single bean, but 3 were found: - initBaseProcessStrategyBean: defined by method 'initBaseProcessStrategyBean' in class path resource [com/orgName/test/config/serviceLocators/BaseProcessStrategySLConfig.class] - initBaseFileHandlerBean: defined by method 'File1HandlerBean' in class path resource [com/orgName/test/config/serviceLocators/File2HandlerSLConfig.class] - initEcommerceServiceBean: defined by method 'initEcommerceServiceBean' in class path resource [com/orgName/test/config/serviceLocators/File3HandlerSLConfig.class] Action: Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed For each service i should write two files one is File1HandlerServiceRegistry(Interface) and the other File1HandlerSLConfig.java(which is class) cant we do in same files respectively
Please follow my steps thoroughly , check whether you add sterio type annotations in all your implementation or not and also make sure you provided name for it
Should've explained it more like why we need payment registry and how locator is providing bean to registry etc.. may be im a noob Or may be should've been straight forward like directly getting from applicationcontext.getbean(name,service.class) which directly gives bean
Thank you very much for the great explanation ❤
@Basant your videos extremely informative...it has always helped me a lot. Keep learning and keep posting ...
Excellent video, I loved you showed the problems with if statements first and how we can solve it in a nicely way with Service Locator.
Excellent explanation !!
Thanks Basant ! please make more videos on this type patterns which we should use in our projects
Keep up the great work Sir 👍👍
Thanks bro..it is very useful for project .
Nice video sir . Good job
Great video..
Thanks good video ☺️☺️☺️
Great video, thanks for the efforts. Please upload more videos related to design patterns.
After few more means 2 3 concept we will start microservice series with cloud deployment .
if any exception occurred in SLConfig for example requested payment bean is not available .. how it will be handled ?
gud one Bro 😊
Can you please make the flow diagram at the end how the flow works it will be useful for beginners to grab the content easily
Thanks Basant
Can we have multiple service locator resolving different type of services in same spring boot app?
Yes we can
Thank you Friend :)
Hi Basant, let’s say if my request body does not have any decision making property in this case payment type, how can I decide which service bean to invoke? E.g my request body looks like { itemUpc: “123”} and I need to invoke service bean related to item service. How can I do that?
hi sir ,do you know about spark framework used in Java could you please do a video on same
No idea buddy
Tq... Please do some videos on sql interview questions for experienced...
Yes I will . already I prepared docs for it .soon will create
Tq..for u r response...
We should pass the service name in Postman or as parameter? How to pass service param in application?
YRK I passed as a parameter only @PathVariable annotation used to pass input as part of request URL
I am getting the following error -> Consider defining a bean of type 'com.xx.XXRegistry' in your configuration.
Nice one. But, plz jnstall sonar lint.
Description:
Field serviceRegistry in com.orgName.test.handlers.impl.StrategyHandler required a single bean, but 3 were found:
- initBaseProcessStrategyBean: defined by method 'initBaseProcessStrategyBean' in class path resource [com/orgName/test/config/serviceLocators/BaseProcessStrategySLConfig.class]
- initBaseFileHandlerBean: defined by method 'File1HandlerBean' in class path resource [com/orgName/test/config/serviceLocators/File2HandlerSLConfig.class]
- initEcommerceServiceBean: defined by method 'initEcommerceServiceBean' in class path resource [com/orgName/test/config/serviceLocators/File3HandlerSLConfig.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
For each service i should write two files one is File1HandlerServiceRegistry(Interface) and the other File1HandlerSLConfig.java(which is class) cant we do in same files respectively
Please follow my steps thoroughly , check whether you add sterio type annotations in all your implementation or not and also make sure you provided name for it
@@Javatechie when we have multiple service locator interfaces, we should add @Primary to one of the interface. which has solved my problem.
how this is different from stretagy design pattern
Should've explained it more like why we need payment registry and how locator is providing bean to registry etc.. may be im a noob
Or may be should've been straight forward like directly getting from applicationcontext.getbean(name,service.class) which directly gives bean
Hi Basanth, how about autowired map servicesMap;
And in method, just call servicesMap.get("amazonPay").pay(request)
This is what you are doing similar to the factory right