• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set a bean property of type java.lang.Class using Spring DI?

 
Philippe Desrosiers
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess the title says it all, but: I have a bean with a property of type java.lang.Class. How can I populate this property using a Spring Context.xml? Is there some sort of Spring ClassFactoryBean I can use?

So, something like this:


Only problem is, there's no such thing as org.springframework.beas.factory.config.ClassFactoryBean.

Has anyone done this before?

On a related note, is there some way to specify the run-time type, for classes that use Generics?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should work with -



As for the second part - that won't work due to Type Erasure.
 
Philippe Desrosiers
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hah! Sweet! Thanks Nathan:-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic