This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes BeanFactory Return Class Rather Than Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "BeanFactory Return Class Rather Than Object" Watch "BeanFactory Return Class Rather Than Object" New topic
Author

BeanFactory Return Class Rather Than Object

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I asked this on the official Spring forums as well so if I get an answer there I will update this thread.

I am using Spring in a desktop application and I have the following class:



To use this I do the following:



Is there anyway to genericize this so that I don't have to cast? Obviously casting is not a big deal. I'm just looking around for minor improvements to my code.

Thanks.


GenRocket - Experts at Building Test Data
Sergey Chunayev
Greenhorn

Joined: Jan 24, 2008
Posts: 6
You can try to do a trick with templates in your DataAccessContext:

At least, with this solution you don't need casting when invoke this method.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Sergey,

Thanks. That is pretty slick. As you said, at least it saves me the cast. One less thing I have to type. Thanks again.
 
jQuery in Action, 2nd edition
 
subject: BeanFactory Return Class Rather Than Object