aspose file tools*
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: 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BeanFactory Return Class Rather Than Object