This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Spring and the fly likes how to set a bean property of type java.lang.Class using Spring DI? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "how to set a bean property of type java.lang.Class using Spring DI?" Watch "how to set a bean property of type java.lang.Class using Spring DI?" New topic
Author

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

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
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

Joined: Oct 18, 2000
Posts: 4121

It should work with -



As for the second part - that won't work due to Type Erasure.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Hah! Sweet! Thanks Nathan:-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to set a bean property of type java.lang.Class using Spring DI?
 
Similar Threads
Struts Validation in Spring Context
Srping+Hibernate bad configurated causing huge memory consumption
Spring +JAX-RPC +Operation timed out
If Someone Would Help Me to Understand a Spring Configuration Snippet
Invoking Method