May I know what is the difference between:-
Spring
Struts
Struts 2
Hibernate
JavaServer Faces
JavaServer Pages
Tapestry
Are these technologies/framework complementary to each other? Or they are alternatives to each other (after I use one of them, then I don't need to use the other)?
Thanks.
Spring is an IoC container (at least the core of Spring) and is used to wire things using dependency injection. Spring provides additional services like transaction management and seamless integration of various other technologies.
Struts is an action-based presentation framework (but don't use it for a new development).
Struts 2 is an action-based presentation framework, the version 2 of the above (created from a merge of WebWork with Struts).
Hibernate is an object-relational mapping tool, a persistence framework.
JavaServer Faces is component-based presentation framework.
JavaServer Pages is a view technology used by all mentioned presentation framework for the view.
Tapestry is another component-based presentation framework.
So, to summarize:
Struts 2, JSF, Tapestry (and Wicket, Spring MVC, Stripes) are presentation frameworks. If you use one of them, you don't use another.
Hibernate is a persistence framework and is used to persist Java objects in a relational database.
Spring can be used to wire all this together and to provide declarative transaction management.
I don't want to make things more confusing but note that Java EE 6 provides modern, standardized and very nice equivalent of the above frameworks: JSF 2.0 and Facelets for the presentation, JPA 2.0 for the persistence, Dependency Injection, etc. For a new development, this is IMO a serious option, Java EE 6 is a great stack.
See also
Choosing a Java Web Framework now?
Java - JDBC alternatives
JEE6 vs. Spring 3 stack
What to learn for making Java web applications in Java EE 6?
Generally...
Hibernate is used for handling database operations. There is a rich set of database utility functionality, which reduces your number of lines of code. Especially you have to read #Annotation of hibernate. It is an ORM framework and persistence layer.
Spring provides a rich set of the Injection based working mechanism. Currently, Spring is well-known. You have to also read about Spring AOP. There is a bridge between Struts and Hibernate. Mainly Spring provides this kind of utility.
Struts2 provides action based programming. There are a rich set of Struts tags. Struts prove action based programming so you have to maintain all the relevant control of your view.
In Addition, Tapestry is a different framework for Java. In which you have to handle only .tml (template file). You have to create two main files for any class. One is JAVA class and another one is its template. Both names are same. Tapestry automatically calls related classes.
You can see the overview and ranking for yourself here. Hibernate is an ORM, so you can use either struts+Hiberante or spring+hibernate to build a web app. Different web frameworks and many are alternatives to each other.
Spring is an application framework which deals with IOC (Inversion of Control).
Struts 2 is a web application MVC framework which deals with actions.
Hibernate is an ORM (Object-Relational Mapping) that deals with persistent data.
In short,
Struts is for Front-end development of website
Hibernate is for back-end development of website
Spring is for full stack development of website in which
Spring MVC(Model-View-Controller) is for Front-end.
ORM, JDBC for Data Access / Integration(backend). etc
In hibernate you need not bother about how to create table in SQL and you need not to remember connection ,prepared statement like that data is persisted in a database. So, basically it makes a developer's life easy.
Spring is a light weight and open source framework created by Rod Johnson in 2003. Spring is a complete and a modular framework, Spring framework can be used for all layer implementations for a real time application or spring can be used for the development of particular layer of a real time application.
Struts is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May, 2000.
Listed below is the comparison chart of difference between Spring and Strut Framework
Tapestry pages and components are simple POJO's(Plain Old Java Object) consisting of getters and setters for easy access to Java language features.
Difference between Spring, Struts and Hibernate are following:
Spring is an Application Framework but Struts and hibernate is not.
Spring and Hibernate are Light weighted but Struts 2 is not.
Spring and Hibernate has layered architecture but Struts 2 doesn't.
Spring and Hibernate support loose coupling but Struts 2 doesn't.
Struts 2 and Hibernate have tag library but Spring doesn't.
Spring and Hibernate have easy integration with ORM technologies but Struts doesn't.
Struts 2 has easy integration with client-side technologies but Spring and Hibernate don't have.
Related
I have a requirement to amalgamate functionality from some parked Java side-projects into a new application and am trying to make a decision on some of the third-party libraries to use, specifically relating to the UI. I would be very interested to get some feedback from tech arch oriented members on their views in relation to recent java framework trends and experiences.
The legacy projects are a mixed-bunch, all web-based, lots of business logic around CRUDable objects with searches. One uses an in-house framework - very fast, scalable, but with the disadvantages associated with in-house work - learning curve for new devs etc. Another, a Tapestry 5 app - very robust, terrific integration with XFire / CXF for generating web services, rapid UI generation, but with a good learning curve for non-Tapestry types. The third, a Spring 3 app, using JSP 2.0 Tag Files for view layer, with some sprinklings of JQuery for presentation / ajax.
I'm very familiar with Spring and find tag files for the UI with Tiles very effective in terms of low-complexity and performance. I have also recently wrapped up a project that used RichFaces 4 which was successful and came in on time. I like the rich UI that comes for free with RF / IceFaces etc., and have noticed that JSF in its more recent versions has retired JSP altogether.
To cut to the chase, is the restriction of using a component based UI library with clearly defined but unmodifiable behaviour like RF / IF a better fit for a new app than a roll-your-own solution, with tag files / JQuery. I'm more familiar with the latter, but don't want to go down the wrong path at this early stage of a project by adopting an out of date approach. I want to continue using Spring 3 Controllers for RESTful, bookmarkable application entry points - do IF / RF mix with Spring or does a JSF approach remove the MVC obligation completely from Spring?
If the MVC obligation is removed from Spring:
how would the JSF lifecycle integrate with Spring - would it be self-contained and just use IOC for wiring Spring services?
is there good integration with a IF / RF approach for generating web services etc.?
what kind of support do IF / RF have for tablet / mobile?
is Spring needed at all - would managed beans do the trick?
To cut to the chase, is the restriction of using a component based UI library with clearly defined but unmodifiable behaviour like RF / IF a better fit for a new app than a roll-your-own solution, with tag files / JQuery.
It is not one or the other. Java Server Faces is a Component Based Web Framework that allows for the synchronization of server and client state on requests and responses to allow for things like a phase and event model in your applications. Many JSF components utilize jQuery inherently and expand upon rich client controls by wrapping them in server side behavior. It is not unmodifiable behavior by any stretch, just that there is a bit of a learning curve to customize things in a very specific way.
JSF is currently the Oracle recommended approach to Java EE web development.
do IF / RF mix with Spring or does a JSF approach remove the MVC obligation completely from Spring?
how would the JSF lifecycle integrate with Spring - would it be self-contained and just use IOC for wiring Spring services?
JSF is inherently its own MVC framework and with managed properties already has its own baked in Dependency Injection. Core Spring is primarily Depedency Injection so one would think that they are at odds but surprisingly they go together well.
Recent versions of Spring have provided their own EL Resolver implementation for JSF that allows JSF Managed Beans to be handled as Spring beans. This class can even be backfitted into older versions of Spring, which I have done and noticed no issues.
Spring MVC is primarily built on JSP technology, but it is not a core part of Spring. You simply need not include it in a JSF web application if you don't wish to serve JSP pages.
is there good integration with a IF / RF approach for generating web services etc.?
When it comes to web services in a JSF application it is best to remember that JSF doesn't have to define limitations on your web app, nor does it have to define it in its entirety. JSF is merely the front end for JSF page requests. Knowing this your same web application can also serve SOAP or REST based web services of their own, or simply handle these web services at data sources on the server side in your business logic. Another way still is to call external web services from Javascript on your page. Nothing in JSF precludes you from incorporating any element of HTML, Javascript or even newer HTML5 technology.
what kind of support do IF / RF have for tablet / mobile?
Not sure what IF and RF have but I know that Primefaces has an impressive control set for mobile applications that is worth checking out.
is Spring needed at all - would managed beans do the trick?
No absolutely it is not needed. I happen to like Spring though so I use it.
I have several applications that are structured as follows
DataComponent
WebComponent
ThickClientComponent
WebServices
The DataComponent has all the functionality required to access the application's data so it contains the DAOs and the JPA entities. The other three modules are:
WebComponent - A spring MVC application that uses the DataComponent for data acccess
ThickClientComponent- A Swing application that uses the DataComponent for data access
WebServices - A SOAP based services that also uses the DataComponent.
All three projets have the DataComponent as a dependeny in their Maven POM file.
I would like to use a rich client framework like RichFaces, icefaces or primefaces as i need to be able to use the rich components are available in rich client frameworks (i.e. trees, panel, drag and drop etc).
I have looked around and i cant seem to find an example where a Spring MVC application uses a rich client platform. Is it possible? Are the rich client platforms a framework meaning that i have to use either Spring MVC or the rich client platform but not both?
The DataComponent module is spring based.
I suggest you to go for GWT. It is a very good rich client framework and it has a very huge set of components available including drag-and-drop. Also it provides the integration with Spring Framework. You can check out this and this links to know more about its integration.
I have also used smartGWT that is extension of GWT components in one of my project that has backend in Spring framework.
Hope this helps you. Cheers.
Maybe this module will sort you out:
http://static.springsource.org/spring-webflow/docs/2.0-m1/reference/spring-faces.html
You can try ext-js for creating your client side interface. It's heavily java script / ajax based, but that would probably meet your needs. It doesn't really care what your backed tech is, since it works entire through javascript and ajax.
Yess you can use Spring MVC with PrimeFaces but you have to use it with the spring JSF 2 implementation.
If you are thinking to use some faces framework definitely use PrimeFaces.
You could use SpringMVC with JSF but I also recommend to you not to use SpringMVC JSF implementation. Use insted the MyFaces JSF 2 implementation with Primefaces and then link the backing beans with spring.
From my experience this is the best.
But I guess any other options are fine too.
This came as an interview question.
The interviewer asked me if you can use spring for all the purposes and get away without using any of the Java EE framework .
I said yes, but he asked me how about if the application is distributed and what is the point of application servers.
I am not sure about the answer.
Does Spring do everything that the Java EE framework does?
Well, Spring is wide. So you can review point by point. I'm not specialist in Java EE but I'm sure Spring can cover a lot (if not all) of Java EE concerns. And I'm pretty sure Spring can handle most of layers/concerns in an application.
First of all, Spring IOC. You can configure an object graph with Spring IOC. It helps at any layer configuring all the components you need to implement a layer.
Spring-MVC-Web: you can configure an MVC web component in order to handle and serve all web application requests. I think you can make something cool with it. Configure web responses and its necesary configuration with other business elements (including IPC - Inter Process Comunication).
Spring Security is heritage from Acegi. It's a web framework for defining role-defined access to web resources.
I'm not sure if Hessian is Spring's too. Anyway it's lightweight and it helps comunicating with components in other processes à la RMI.
Well... I'm not sure about persistence, but I thing Spring has templates for JDBC, Hibernate, and all, so it can help anyway (as suggestions indicate: JmsTemplate and RestTemplate are available for communication with other business components!).
The core thinking here is: you can make an app from scratch, so in all cases, Spring can provide a framework to ease the difficult/repetitive tasks on every layer. Does Spring does it? Yes.
Please check other features to see if Spring has something for it. I'd bet it.
Deep down, Java EE is a set of specifications (some of which have been contributed by Spring team!)
Spring's mission statement is to 'Simplify Java Development'
It does so using the following techniques:
POJO -> facilitates easy testing
DI -> promotes loose coupling
AOP -> promotes separation of concerns, maintainability etc
Templates -> provides a standard programming model which does the heavy lifting for you
Spring and Java EE do not have a "Vs" relationship.
Using the above techniques, the Spring Framework lets you build (Java EE) standards-based applications more efficiently.
>Does spring do everything that the Java EE framework does ?
Based on what I've said above, the question might be rephrased as 'Does Spring have support/implementations for all the technologies that comprise the Java EE specification?' -
Nope, but it does do what it set out to do and that is simplify development on most Java EE technologies.
That said, the trade-off for this simplification of Java development is that you need to now have significant amount of knowledge (of the Spring Framework) at your fingertips... (comes with practice and google :) )
>Can't we use Spring for distributed java applications?
Sure you can. Spring has a whole lot of Exporters/FactoryBeans and Clients(Templates) for most conceivable use cases.
Yes Spring can be used in a distributed application without Java EE. We have used it to send messages to MQ and update a database both within one XA transactions.
According to this article, Spring can definitely be used on its own in a distributed application.
http://www.wrox.com/WileyCDA/Section/Why-Use-the-Spring-Framework-.id-130098.html
http://www.artima.com/forums/flat.jsp?forum=276&thread=204508
Historically, (5 years ago?) Spring was weak in the distributed applications area, in particular database clustering. That is no longer a concern. I would say that Spring is going even further for distributed computing these days as they are vigorously pursuing cloud technologies which Java EE hasn't approached yet.
In my view the main benefit of Spring was that it did away with some of the more heavyweight components of the Java EE framework (Entity Beans, session beans) and replacing them with a lightweight alternative.
On of the main benefits of Spring as I see it, is that it decouples a lot of components and then uses XML or Annotations of wiring them together. That makes it easy to write Unit Tests (by injecting mock components instead of real ones), which wasn't something easily done when using heavyweight Java EE components (couldn't easily unit test EJB 2.1 Entity Beans).
A lot of Spring concepts have since gone into the Java EE standards, so I would argue that Java EE is no longer a heavyweight option, and Spring works will with Java EE components such as application server managed connection pools (via JNDI), transaction managers, queue managers that can very easily be managed using an application server which can provide additional functionality such as clustering, failover, load-balancing, serving web resources...
Having said that, the people behind Spring (VMWare) have their own application server (tcServer) which is based on Apache Tomcat and provides a lot of the glue used by spring, but is not considered as "heavy" as some of the traditional Application servers (Websphere, Weblogic).
I don't think so. Basically Spring is about integration between Java EE frameworks.
Use spring inegration framwork for this .
Use can uss Akka framwork for managing distributed applications with spring integration .
Akka uses the Actor Model together with Software Transactional Memory to raise the abstraction level and provide a better platform to build correct concurrent and scalable applications.
Take a look at the step by step tutorial that gives more information about how to build a distributed application using Akka framework.
In general, distributed applications are built in Java using Java-RMI that internally uses Java's inbuilt serialization to pass the objects between the nodes.
I'm developing java enterprise web application using EJB 3.1 and I wonder which technology to use on which MVC layer. I have ear, ejb(jar) and war projects.
Is it possible to use something other as persistence layer then JPA implementations (e.g. myBatis) and how? I would like to manage some more difficult queries on my own.
What framework to use in web project (war) except JSF or plain servlets?
I'm familiar with Spring, would it be possible to use Spring in web (war) projects and benefit from its controllers?
Can you explain which technologies are used to develop enterprise web applications?
Thanks.
The best combination would be to use what's already there. JSF 2.0 is already one of the best MVC frameworks, so it would often be a first choice anyway.
When using EJB 3.1, this is almost always in combination with a Java EE implementation, so in that case JSF is already there and simply using it is a no-brainer.
The different technologies in the Java EE stack are made to work with each other, so a typical stack consisting of JSF + CDI + EJB + JPA is the most ideal combination and you'll find the most support for this.
I personally don't think there's any place for Spring in an EJB/CDI stack. Those two technologies are direct competitors that solve the same problem in (slightly) different ways. Combining them will most likely only complicate your code.
For a starter like you, stick with what comes out of the box with Java EE 5/6. So in your case JSF+Facelets, EJB 3.1 and JPA.
I suggest you to read the below books and in the order given
Beginning Java™ EE 6 Platform with GlassFish™ 3
Real World Java EE Patterns Rethinking Best Practices
I am relatively new to web development.
I have a question i want to create the e-commerce webapplication leveraging Java platform (J2EE).
first can some body share his experience about available open-source resources for creating such web-application or open-source e-commerce solution, which is compatible with J2ee frameworks,
and if as i realize that there are only 1 or 2 vendor specific e-commerce solution available in Java then which J2EE frameworks or combination, i could use for creating my own e-commerce solution or web application,
while there are various options and alternatives available and it's difficult to choose one among them for each layer.
any tutorial/ resources.
thanks.
How about this one called Shopizer ? Though it is not based on the Jave EE platform ,it is built by using some popular java technologies nowadays such as Spring and Hibernate.
The system heavily uses Spring IOC and Transaction annotations.
Business objects are Hibernate pojos retreived from an associated DAO
all grouped in a service facade exposed to Struts action classes and
modules. Shopizer supports HSQLDB, Oracle and MySQL databases.
The system is built on Struts 2, Hibernate and Spring. It uses
Hibernate Search / Lucene for indexing and searching. Apache Commons
libraries are used for doing common routines. Reports are generated
using jasper reports. JQuery ui and ajax are heavily used on the ui as
well as DWR and Struts2-jQuery plug-in.
I think you can try apache ofbiz. it is open source. it has range of features and active community.