This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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


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: 15302
    
    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: 15302
    
    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.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: BeanFactory Return Class Rather Than Object
 
It's not a secret anymore!