Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BeanFactory Return Class Rather Than Object

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sergey Chunayev
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic