Given an application context, bean id and property name, I need to be able to read the property value. I figured out how to set properties (with appropriate configurer) but not how to read them. I am sure it is so simple, I overlooked it :-)
Given an application context, bean id and property name, I need to be able to read the property value. I figured out how to set properties (with appropriate configurer) but not how to read them. I am sure it is so simple, I overlooked it :-)
Of course, the 'normal' way is to just get the property using the bean you get from the context: String v = beanFromContext.getV();
Do you mean using the factory API directly?
I meant: to find the way to implement:Originally Posted by jbetancourt
String getBeanProperty(String beanName, String propertyName)
without reflection, etc.
You would have to get the context's beanfactory and if its ConfigurableListableBeanFactory, you could get the actual bean definition which then would allow you to get properties and other stuff.
Something like: context.getBeanFactory().getBeanDefinition()
I just did:
Seems to workCode:BeanWrapper wrapper = new BeanWrapperImpl(bean); return wrapper.getPropertyValue(propertyName).toString();