Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Container classes in Spring

 
Padma Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the container classes in Spring? I would like to know which classes do we need to use to implement Spring in the business layer.

The design is Struts + Spring + Hibernate.

Lots of Thanks,
Angel.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "container classes"? Do you mean "how do I use Spring as just an IoC container"? If so, I'd start here.
 
Padma Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. My question is what clases do we require to overwrite to work with Spring.

Thanks for the reply. That was instant.

Angel.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think I understand what you're looking for. You want to know what you have to override to use Spring? You don't have to override anything to use Spring, in general. What exactly is it that you're trying to do?
 
Padma Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologize for the confusion. My question was wrong. I was to ask in a different way.

What are the necessary classes of Spring do I need to extend to write my own logic.

for eg, in struts, we have our own classes extending Action Form, Action classes etc.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's one of the best things about Spring! You don't have to extend any Spring classes to use it.
 
Craig Walls
author
Ranch Hand
Posts: 363
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Carman:
That's one of the best things about Spring! You don't have to extend any Spring classes to use it.


That's only partially true. To use Spring IoC, you don't have to subclass or implement anything. Just wire up your POJOs in the XML file and you're set.

But, if you're using some of the sub-frameworks, you may have to subclass or implement some Spring-specific stuff. For example, if you're using Spring MVC, you'll need to *at least* implement the Controller interface and more likely extend one of the many Controller implementation classes that come with Spring.

The author of the original question said that their app is Struts + Spring + Hibernate. In that case, you'll still implement your Struts layer the same as if Spring wasn't a factor (ie, subclass Action). In the middle, it just depends on what you're doing on whether you'll need to subclass Spring-specific stuff or not. In the persistence layer, you'll probably want to write your DAOs to subclass HibernateDaoSupport (although that's optional...you'll just have to manage your Hibernate sessions yourself if you don't).

To sum it up...if you're using only the IoC part of Spring, then you don't need to subclass or implement anything Spring-specific. But when you start using some of Spring's sub-frameworks, you may need to subclass a Spring-specific class here and there...it really just depends on what you're doing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic