Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does spring framework assist in application development?

Tags:

java

spring

Am a bit confused here! how does spring framework assist in general development of an application? I use django framework and i can quickly explain to a layman how all parts fit together(Django, Python, templates, packages etc) to produce an excellent web application, but when i look at spring i get a bit lost! Am looking answers but not limited to the following;

  1. Can someone please tell me how they have used spring to produce applications?
  2. Can someone please point to me some real world applications done in spring ( iread somewhere linkedin.com is done with spring!
  3. Can someone please tell me how this pieces come together ( Strut, javascript, glassfish/jboss, apache, etc and ofcourse spring) to produce an application?
  4. How many separate pieces of software do you need to produce an application using spring?
  5. How easy is it to produce application using spring framework?

I need the gory details :)

Gath

like image 382
Gath Avatar asked Mar 30 '09 05:03

Gath


3 Answers

There are a number of Spring projects, but the initial Spring (POJO) project came about because of the perceived difficulties of working with J2EE. You'll find a number of projects on the SpringSource website that have grown out of this, but rather than being lumped into one framework they've taken a more modular approach. For all the products they produce see:

http://www.springsource.org/projects

Q. Can someone please tell me how they have used spring to produce applications?

Spring provides a number of features, but the most oft used one is that of dependency injection. This allows you to wire together components (e.g. Javabeans) by declaring the relationships in XML/Annotations. The Spring container then reads this information and constructs the bean hierarchy at runtime. A standard way to describe the beans in XML is the Application Context.

http://static.springframework.org/spring/docs/2.0.x/reference/beans.html

Q. Can someone please point to me some real world applications done in spring ( iread somewhere linkedin.com is done with spring!

There are lots of applications built using Spring. I'm not sure of big commercial projects, but I expect there to be many.

Q. Can someone please tell me how this pieces come together ( Strut, javascript, glassfish/jboss, apache, etc and of course spring) to produce an application?

Spring is normally integrated with other frameworks, there are various hooks into these frameworks and you need to look at each one separately in order to understand what they are all about. Struts and Spring framework integration can be found here:

http://www.ibm.com/developerworks/web/library/j-sr2.html

With Glasshfish/JBoss it's more about how you configure your application in relation to Spring rather than the application server. See this:

http://static.springframework.org/spring/docs/2.5.x/reference/web-integration.html

Q. How many separate pieces of software do you need to produce an application using spring?

e.g. A web application would consist of Spring MVC + Spring Backend. A desktop application - Java Swing + Spring backend. In terms of the Spring framework itself (configured with XML) it would involve:

  1. Create your standard JavaBean classes (for services/DTO's/DAO's)

    public class ExampleBean {

    private AnotherBean beanOne;
    private YetAnotherBean beanTwo;
    private int i;
    
    public ExampleBean(
        AnotherBean anotherBean, YetAnotherBean yetAnotherBean, int i) {
        this.beanOne = anotherBean;
        this.beanTwo = yetAnotherBean;
        this.i = i;
    }
    

    }

  2. Declaring beans within your application context file

  3. Integrate Spring with your web application/application via web.xml etc...

These are taken from the Spring docs btw... see:

http://static.springframework.org/spring/docs/2.0.x/reference/beans.html

Q. How easy is it to produce application using spring framework?

Very easy, but again dependent on what you're building. If you're just using the Spring POJO framework to build a service and integration tier then it's fairly simple. If you have to build a web application layer, then it's a little more complicated (not hugely at all) to understand the internals.

Hope that helps...

like image 192
Jon Avatar answered Sep 22 '22 01:09

Jon


  1. Can someone please tell me how they have used spring to produce applications?

Put the Spring JARs in your CLASSPATH, follow the Spring idiom (e.g., interfaces to delineate layers), and use it to glue your code together.

  1. Can someone please point to me some real world applications done in spring ( iread somewhere linkedin.com is done with spring!

Here's one. Running in production now for three years and counting.

  1. Can someone please tell me how this pieces come together ( Strut, javascript, glassfish/jboss, apache, etc and ofcourse spring) to produce an application?

Struts is one choice for web tier; JavaScript is something you can use to make your client dynamic; Glassfish/JBOSS/WebLogic/WebSphere/Tomcat/Spring DM are all app server choices for deploying your Spring app; Apache is an HTTP web server; Spring and your code go on the app server.

  1. How many separate pieces of software do you need to produce an application using spring?

You need an app server and probably a database, a browser, your code and Spring.

  1. How easy is it to produce application using spring framework?

How good a programmer are you? Depends on your knowledge.

Spring certainly made my life easier once I understood it.

like image 26
duffymo Avatar answered Sep 21 '22 01:09

duffymo


Spring is a pretty large framework, it's going to be hard for anyone to summarize everything here. I think the biggest plus for using Spring is its dependency-injection support. It can be used in any type of application, and provides a ton of framework features and utilities. If you are really interested, I'd recommend starting with the docs on springsource.org:

http://www.springsource.org/documentation

There are a lot of tutorials out on the web too. To fully appreciate it, you should try writing a few example apps to get the feel for it, and see what's available.

like image 25
Andy White Avatar answered Sep 22 '22 01:09

Andy White