• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring - DataProcessors Registry and Bean Finder

 
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
karthik Suryanarayanan
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry for posting this under a different forum. Didnt check that and randomly created this post under that group.

karthik Suryanarayanan wrote: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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic