How to best apply Spring, Spring MVC and Hibernate frameworks - spring

I'm an individual programmer, developer and I see a huge demand for the frameworks: Spring, Spring MVC, webflow, and Hibernate. Popular today: Spring MVC, webflow, GWT.
I've been going through the tutorials, and the technology looks awesome !
What I would like to know, is.. It's used in corporate sites, why not for smaller sites. How can I apply these frameworks in building websites ?
I can't imaging doing any kind of serious website building without a modern CMS or Portal framework (whether in Java/php-opensource), And yes, MVC gives you the validation and authentication hooks to be used.
All the demo's on Spring, cover some elementary, contrived example.
If I learn these technologies (and I'm well on my way), how do I put them into practice, and in what context (no pun intented) do I use them ?
I don't want to rebuild a CMS system, but I'd like to employ these frameworks effectively.

You should have a look at Magnolia/Blossom.
Magnolia is a Java (JCR) based Repository, and Blossom some kind of Spring integration.
I used it in one of my project, it worked. (Not all Spring 3.0 Features worked - for example I was not able to map two or more urls to one controller), but it worked) And I was not able to find any other mature Spring based CMS.
At least I belive the power of Spring MVC is more in web based applications than in simple web sites.

Related

Starting with Spring framework

I'm planning to start learning Spring but when I open any spring tutorial, I find many modules like Spring REST, spring MVC etc.
I'm really confused on how to start with spring, from which module to start, how are these modules related to each other, should I go through all the modules??
I tried searching many sites to answer my questions but couldn't find satisfactory ans, so thought of posting here. It would be great if somebody can guide me in this regard.
Spring is a java framework which provides solutions to several problems. So i guess it really depends on what you are planning to learn. The most important to learn first is understanding what Dependency Injection and inversion of control means. When you understand this you will understand why the rest of the frameworks are designed as it is. i suppose learn Spring IoC first since this is basically the core component of Spring Framework. Link: http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/beans.html
After learning Spring IoC, you can go on learning each specific Spring frameworks which address specific problems. For example:
Are you interested in Web development? --> Spring MVC
Are you interested in storing data to database? --> Spring Data
Are you interested in developing web services / web apis --> Spring REST
http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/overview.html
Start with Spring Core Module, which is the heart of entire Spring.
Spring Core Module helps in Injecting Dependencies (java objects) into
the Application at Runtime.
Please refer below URL for more details:
http://www.springbyexample.org/examples/core-concepts.html
A good knowledge of design patterns is essential for learning any framework in Java.
These Youtube videos can give you a good understanding of basic Spring.
As explained in the previous answers, start learning with the Spring core. You need to have a sound knowledge of servlets, JSP, Hibernate (ORM's) to understand the advanced topics.

Whats the difference between Spring and Spring MVC?

I know this is not a programmatic questions.
I am a n00b to this area coming from Java EE background and could not find the difference between the two online (may be I am not a good surfer)
Could someone please share the info?
Spring is a framework alternative to Java EE with three parts:
Dependency injection
Aspect oriented programming.
Libraries for web MVC, persistence, messaging, etc.
Spring MVC is for web MVC. It's one of the many libraries built into Spring. You can use other alternatives (e.g. Struts, SEAM, etc.) if you wish and still use Spring.
spring is enterprise framework designed to solve all your problems for enterprise applications. At present they call it as Spring IO, which can be found at spring.io website.
However, Spring MVC is a framework part of the whole stack available to solve the enterprise solutions. This is framework for writing web applications.

Why to use Spring not JSF (Advantages of spring over JSF)?

i don't know JSF very well, and i have a friend who is using only JSF
and he asked me a very open question, why do you use spring not jsf ?
and because of there are a lot of things about spring in my mind
i wasn't able to give some straight answers
so what are the advantages of spring over JSF ?
Spring and JSF are quite a different frameworks.
JSF is more of a web application framework and you can still use spring with JSF to manage the relationship and creations of the objects.
Spring is more of an entire j2ee application framework/plaform.
Spring MVC and web flow will help you to design web applications similar to JSF.
But spring with its IOC concept also brings a lot of other modules such as dependency injection, aop, DAO, ORM, integration, batch and social tools and much more.
You can also check the JSF-Spring combination - http://www.springsource.org/node/422
JSF is presentation layer, Spring business layer (roughly said), they can be used together and do not compete.
As said before, JSF is a request-driven, MVC web-framework, built around a light-weight IoC container and is designed to simplify and standardize the way UI-layer of a web-application is built.
Spring, on the other hand, is less concerned with UI-layer but its precise definition is hard to formulate. It can be said that the primary function of SF is to tie together different layers of a web application in a standardized way, at the same time abstracting away the implementation details of a particular web technology from the developer. As one of the consequences, the developer is freed from implementing "plumbing" and instead gets working module interconnections which are tested, implemented and used relatively easily. This should provide a boost to productivity and shortens development cycle.
This abstraction can be viewed through various Spring modules - Spring is heavily modularized, so you choose which components of the framework will you be using. Though it features a MVC framework (SpringMVC is mostly written as a reaction to the Jakarta Struts, whom the Spring developers deemed poorly written), Spring lacks a dedicated presentation module so you're free to use most of existing UI technologies (e.g. JSF, GWT-oids, etc.) - once you properly configure them in Spring.
In another words, the "scopes" of JSF and Spring are quite different (though not totally disjunct).

Experiences with integrating spring 3 mvc with GWT?

Given:
Spring 3.0 mvc has excellent REST support with one of the representation being JSON.
GWT simplifies development as UI is developed in java. But by default it uses RPC for client server interaction. But there is an option to use JSON.
Questions:
Can you share experiences with using Spring 3.0 mvc with GWT ?
What is the best approach to integrate these two frameworks?
Is the default GWT's MVP architecture only for client side and does it work well with JSON?
Thanks
Can you share experiences with using Spring 3.0 mvc with GWT ?
Yes. We've successfully built a whole large application around GWT and Spring MVC (1500 source files, 6 months in development).
Spring was the key to the project's success. Only with Spring we were able to test individually some pieces of the application on the server side.
What is the best approach to marry these two frameworks?
Ignore the default Servlet used by GWT and instead create your own Spring controller to handle incoming GWT-RPC requests. This blog post was the key to integrating the two techs.
We also successfully integrated other components: Flash for animated charts and third-party Javascript components for other stuff. These communicate with the server through JSON. So you have two or more kinds of URLs:
the *.rpc urls are for GWT components and are served by the Spring controller for gwt
the *.json urls are for other components and are served by another Spring controller.
Also, in our case, we shunned configuration with annotations and instead preferred configuration with the good old Spring XML files. They make it much more clear what's going on. Except for the #Required annotation; it's great to find spring beans that should be connected but aren't.
Is the default GWT's MVP architecture only for client side and does it work well with JSON?
GWT's MVP architecture works best if you follow the guide lines. Use GWT-RPC communication as Google suggests.
You can still have JSON for other client-side components.
Try this solution: GWT and Spring MVC Integration
It uses 3 classes. Its very simple, declarative and clear.
It's stupid to mix Spring MVC and GWT. Also it's stupid to mix Spring MVC and JSF... It's stupid to mix 2 MVC (MVP) frameworks together. But you can use Spring DI and GWT for sure!
You may want to check out Spring Roo. It will help you get started quickly with Spring MVC, especially when dealing with RESTful URLs. It also provides a means to automatically set up GWT "scaffolding" (GWT code to interact with the Spring MVC backend). Hope it helps!

Is the REST support in Spring 3's MVC Framework production quality yet?

Since Spring 3 was released in December last year, I have been trying out the new REST features in the MVC framework for a small commercial project involving implementing a few RESTful Web Services which consume XML and return XML views using JiBX. I plan to use either Hibernate or JDBC Templates for the data persistence.
As a Spring 2.0 developer, I have found Spring 3's (and 2.5's) new annotations way of doing things quite a paradigm shift and have personally found some of the new MVC annotation features difficult to get up to speed with for non-trivial applications - as such, I am often having to dig for information in forums and blogs that is not apparent from going through the reference guide or from the various Spring 3 REST examples on the web.
For deadline-driven production quality and mission critical applications implementing a RESTful architecture, should I be holding off from Spring 3 and rather be using mature JSR 311 (JAX-RS) compliant frameworks like RESTlet or Jersey for the REST layer of my code (together with Spring 2 / 2.5 to tie things together)? I had no problems using RESTlet 1.x in a previous project and it was quite easy to get up to speed with (no magic tricks behind the scenes), but when starting my current project it initially looked like the new REST stuff in Spring 3's MVC Framework would make life easier.
Do any of you out there have any advice to give on this?
Does anyone know of any commercial / production-quality projects using, or having successfully delivered with, the new REST stuff in Spring 3's MVC Framework.
Many thanks
Glen
We use Spring 3's REST support in a production environment and are very happy with the results. We have about 1600 users and experience no performance issues.
We transitioned from Spring 2.5 (all XML configuration) to Spring 3.0 using Annotations to map our controllers and have been very pleased. Our initial tests show equal to better performance then our previous version and we've seen no bugs in the Spring code.
we have used the rest based implementation with Apache Wink and the results from the wink layer are very good.Our application was scalable with 2 clusters to 3000 requests per second.We did not face any performance issue with the wink layer.I felt that as spring does not provide a JAX-RS AKA JSR 311 we need to settle for another rest based implementation like Jersey or Restlet. If you are already using Spring3.0 please feel free to use JAX-WS support provided by spring's RestTemplate.

Resources