Hello Everyone,
I am trying to look for a solution for below problem. i have been checking Service Locator design
pattern , and Dependncy Injection, But couldnt get it working.
We have 5 rest service endpoints and once each are triggered, they need to find the right DataProcessorBean and execute it. The problem is each method (or the code executing each endpoint) all has different signatures. (meaning different input parameters and different return type). This was how its designed already. And there is no common interface implementation.
/default - > triggers DefaultController - > Based on the input typeName - > should find the correct DataProcessorBean for the input type name for the Default,
/validate - > triggers ValidateController - > Based on the input typeName - > should find the correct DataProcessorBean for the input type name for the Validate,
Default - > Has a list of beans defined under it.
Validate - > Has a list of beans defined under it.
InputType name can be same and based on the URL Endpoint, it has to fetch corresponding ProcessorBean.
So my requisite is based on inputType and the endpoint, i need to fetch the correct DataPrcoessorBean and execute it.
Currently, the code uses a registry and a Locator , but after upgrading from Spring 2 to Spring 5, I am getting below error. So i am trying to correct to a proper design.
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.LinkedHashMap' to required type 'java.util.Map' for property 'dataProcessorMap'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'com.dataprocessors.impl.CDDProcessor' to required type 'com.dataprocessors.RestDataProcessor' for property 'dataProcessorMap[Check Receipt]': no matching editors or conversion strategy found
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:595)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:609)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:219)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1738)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1694)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1434)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
... 30 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type 'com.dataprocessors.impl.CDDDataProcessor' to required type 'com.dataprocessors.RestDataProcessor' for property 'dataProcessorMap[Check Receipt]': no matching editors or conversion strategy found
Full code below.
Further info i will paste as needed.