Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring RuntimeBeanReference

I have a custom namespace I'm parsing for a Spring project, and I'm having trouble with RuntimeBeanReferences. I have a class MyClass that takes a List. In my beandef file, I have a bean defined of type MyObject named "MyObj".

In my custom namespace parser, I have code that looks like this:

RootBeanDefinition myBean = new RootBeanDefinition(MyClass.class);        
ConstructorArgumentValues cav = new ConstructorArgumentValues();
List list = new LinkedList();
list.add(new RuntimeBeanReference("MyObj"));
cav.addIndexedArgumentValue(0, list);

However, when I lookup the bean through spring, I get an exception saying it can't convert RuntimeBeanReference to MyObject. Do I need to do something specific to force the reference to be resolved?

thanks,

Jeff

like image 701
Jeff Storey Avatar asked Jan 29 '26 08:01

Jeff Storey


1 Answers

I just found it. I need to use a ManagedList instead of a regular LinkedList. The ManagedList (and ManagedMap) will have references resolved by Spring.

like image 61
Jeff Storey Avatar answered Jan 31 '26 01:01

Jeff Storey