• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Where to use Spring?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I Know Spring is an application Framework.thats all i know about Spring.

Now i am working Struts+Stateless EJB+ Hibernate Project
If i want to Spring, where i can use in my project?.
If Spring can replace any technology, what that technology would be?.
If i am using in my Project what would be advantage over current architecture?

Thanks in advance
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello...

Spring can be used in all parts of your project. Should it be used? That is really up to you. I think that is the nice part about Spring, you don't have to use it for every layer. I think the most difficult part to learn is the DI aspect of Spring. It is really a simple concept, but can take a while to make sense. Once you "get" it though, you sometimes wonder how you ever worked without it. By being able to inject your beans into your classes, you can code very quickly and switch out implementations quickly.

You can replace Struts with Spring MVC. Spring MVC is a bit different than Struts, but by no means any less effective or usable. I have done projects using both. I am really hooked on the Spring MVC right now, and would probably use it as my MVC framework of choice. (Still need to work with Struts 2 though...that could change my mind.) One of the main advantages I see with Spring MVC over Struts is that your web forms are bound directly to your backing object. So in your Controller (Action in Struts), you don't have to build your object from the form parameters. It will automatically do that, and do any validation that you have written up.

Your EJBs could also be replaced. By using Spring you can just make POJOs and use them. You can apply transactions and security through AOP, and you don't need to have an EJB container. So you could do everything in your web container.

The Hibernate side. We still use Hibernate, but the way Spring can help you here is by using the HibernateTemplate. It has all your connection logic built into it. You just grab your template, and execute your commands. You no longer need to worry about getting a connection, running your command and closing the connection. It is all done for you. And if you want to get away from Hibernate, there are also Templates for other ORMs or just JDBC calls.

Hope this helps...

Nick
 
gopi nath
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Nick
Thank For Your reply.


You can replace Struts with Spring MVC.
Your EJBs could also be replaced.
And if you want to get away from Hibernate, there are also Templates for other ORMs or just JDBC calls.


So Spring can replace Struts ,Ejbs, Hibernate.
So by Using only spring and Jsp we can make an Project Efficiently , am i right?
Is there is any disadvantage in using Spring?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


So Spring can replace Struts ,Ejbs, ...


Yes.


...Hibernate.


No. But it can allow you to easily swap to another ORM.
 
Nick Larson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Paul said. Spring doesn't "replace" hibernate. Hibernate is a great tool, but Spring + Hibernate can make things a lot easier to do.

As far as disadvantages to Spring. I'm sure there are some somewhere. (Can't think of any right off the top of my head.) But Spring as a tool, isn't really a replacement for everything, but a way to make things easy and simple. Things like the JdbcTemplate, HibernateTemplate, JmsTemplate, DI (IoP), Quartz, Spring Security (Acegi), Spring Web Services...really do make things simpler. A lot of times these things are just wrappers on top of other technologies, but these wrappers make it possible to code with very little setup and boiler plate code. Again, back to the HibernateTemplate, this doens't replace Hibernate, as all the work is done by Hibernate, but by using Spring + Hibernate, you can write DAO's and functional code very quickly.

Try working with it for a bit. Do a couple of tutorials that can be found online. (Google Spring tutorial) Check out the example projects that are bundled with the Jars and Source. There are quite a few different ways to do things, and the Spring team does a good job of including example projects.

Nick
 
reply
    Bookmark Topic Watch Topic
  • New Topic