Tag Archives: java

Garbage Collection – Java Performance Tuning

While i was reading the latest Java Magazine (July-August 2013), i came across a topic namely, “Adaptive Size Policy” with regards to one of the important components in JVM, garbage collection.

I researched on this topic and this blog post is my attempt to explain this in some details with good references for follow up reading.

Before going on to explain “Adaptive Size Policy”, i need to cover certain basics in the field of garbage collection. I will be covering this blog under such sub-topic for easy understanding and reading.

JVM Heap in General

JVM heap, aka heap, is divided into two regions, called as generation, namely

  • Young Generation
  • Old Generation

The Young generation region is further divided into sub-regions, namely

  • Eden
  • Survivor Space 1
  • Survivor Space 2

This is how it works when an object is created:

  • The object will be created in Eden and it could be destroyed there itself
  • If the Eden region is full, the object is pushed to Survivor Space 1
  • If the Survivor space 1 is full, the object is pushed to Survivor Space 2
  • The objects which are not destroyed in Survivor Space 2 are retired to the Old Generation region of the heap

To tweak the heap size commonly used Java options as -Xms and -Xmx. You can get a complete list of -X commands that you can use with respect to Java Heap Size, please run the command java -X. Below screenshot shows the various commends that can be used.

Java -X commands which can be used for Heap Management
Java -X commands which can be used for Heap Management

Java Garbage Collection in General

Most of the programming language including Java has a very important feature of automatic memory management, also known as “Garbage Collection”. Objects created during execution of a program, at various stages becomes unreachable and are considered as “garbage”. Over a period of time for managing memory, these garbage is removed and the space is regained for useful staff. Java has very good garbage collection and over a period of time, with some very good engineers working on it, using various algorithms, have made significant progress and enhancement this all important feature.

The core component in the Java SE platform is JVM (Java Virtual Machine). In the case of Oracle JVM, its called as “Oracle’s Hotspot JVM”. We will discuss garbage collection with respect to this Hotspot JVM as GC (Garbage Collection) methodologies differ according to the JVM being used.

Garbage collection is one of the biggest benefit which the Java language provides. If used in a proper manner it will be really beneficial, but if not used cautiously, it can doom your application big time. Some of the considerations with respect to garbage collection which have to be kept in mind are the following:

  • JVM Pause – The time taken by the JVM to do the GC during which the JVM pauses
  • Throughput – The time interval between successive GC

Our goal as an application tuner is to minimize the JVM pause and maximize throughput. There is no hard and fast rule that you can reply on to do this. It comes with experience and the environment in which your JVM/application functions, which will interfere to a greater extend.

There are various GC modes which are possible to be configured using various JVM commend line options. Having said that, these JVM options configured is dependent on various components like the hardware you are running, JVM version etc. to name a few. The default GC mode also depends on the JVM vendor. The various GC modes with respect to Hotspot JVM is as detailed below:-

Serial GC

As the name suggests it is executed by a single thread and requires a complete stop on all the processes carried out by JVM during the execution. The JVM switch for this is specified as -XX:+UseSerialGC

Parallel Scavenge

As the name suggests the collection is parallelized between multiple threads. This also requires the entire JVM operations to be stopped/deferred but during to parallelism, the time required will be reduced to a greater extend. The JVM switch for this is specified as -XX:+UseParallelGC. In modern days due to availability of multicore/multiprocessor this has become more of a norm.

Parallel Old GC

Incremental advancement over Parallel GC mode. I don’t want to go into much more detail, as this post is a head start for beginners to get a primer on GC. The JVM switch for this is specified as -XX:+UseParallelOldGC

Adaptive Size Policy

A special mode of Parallel Scavange in which the JVM automatically adapts and adjust the various heap sizes and does the GC. Might sound a big scary as you might feel that there isn’t much control in overall space allocation by JVM. But IMHO, the java engineers have put lots of effort and experience building this and they shouldn’t be taken as complete wrong and we should have fairly good confidence in using this switch as well. The JVM switch for this is specified as -XX:+UseAdaptiveSizePolicy

Concurrent Mark Sweep (CMS)

Its a low pause collector and the way by which it handles this by using different algorithms for collecting the various heap regions. The JVM switch for this is specified as -XX:+UseConcMarkSweepGC

CMS incremental mode

In this the CMS competes with the CPU cores to perform the GC. The GC thread and application thread works in parallel and in modern day hardware IMHO this is good option. The JVM switch for this is specified as -XX:+CMSIncrementalMode

G1 Garbage Collector

New generation collection mode introduced as part of JVM 1.6. For more details you can find the link to a blog by Alexey Ragozin. The JVM switch for this is specified as -XX:+UseG1GC

Adaptive Size Policy in Detail

Now coming to the main point in this blog, “Adaptive Size Policy”. Since now you have a good idea of the various basics with respect to JVM Heap and JVM GC options, I would be able to explain this concept much easily.

By defining adaptive size policy in a JVM, you are commanding the JVM to adapt itself to the surrounding environment by dynamically re-sizing the heap and its regions so as to attain certain goals already set as follows:

  • Minimize the footprint created by the heap
  • Adhere to the maximum garbage collection JVM pause as desired
  • Adhere to the minimum garbage collection throughput goal as desired

As detailed in the earlier section, to enable this set the JVM switch as follows:

-XX:+UseAdaptiveSizePolicy

To set the desired policy values, you can use the following switches:

-XX:MxGCPauseMillis=nnn – Tells the VM that maximum of nnn milliseconds on less is desired

-XX:GCTimeRatio=nnn – The ratio of GC time to application time

Ideally if you specify the -Xms value to be equal to -Xmx, adaptive size policy is nullified. In cases this might be desirable, but in most of the cases believing the engineers behind this algorithm will surely make your application perform faster and in no case IMHO this should be done whereby a feature is nullified as good amount of research and experience is employed while designing and developing it.

Note:-

Its good to not that options beginning with -X are non-standard, means, need not be supported by all the VM vendors in the market and these are subject to change according to vendor discretion. The options beginning with -XX are non-stable and similar to -X, these are subject to change without notice.

GURU’s with regards to this topic – References

Good Primer – http://blog.ragozin.info/2011/12/garbage-collection-in-hotspot-jvm.html

In simple words – http://www.informit.com/guides/content.aspx?g=java&seqNum=27

Java Hotspot VM options – http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

Complete list of -XX options for Java JVM – http://stas-blogspot.blogspot.co.uk/2011/07/most-complete-list-of-xx-options-for.html

That’s all folks. Thanks once again for all the reference materials, which helped to me learn these concepts and write this blog.

Page Visitors: 4593

Spring Book – Chapter 18 – Remoting

Fundamentally Spring remoting is a Remote Procedure Call (RPC) feature which uses a communication protocol like RMI, HTTP or JMS, to inter-operate across multiple JVM’s. The plumbing involved in actually talking to one another using these protocols and other complexities are hidden away from the developer by employing a proxy object created by Spring.

In this Chapter, we will first go through the basic concepts in remoting and then go on to the support provided by Spring. We will then go on in detail to cover the various remoting technologies which Spring supports in detail.

Basic Concepts

This section provides standard definitions for the basic concepts and terminologies that will be used throughout to explain Spring remoting in detail.

Remote Procedure Call (RPC)

A remote procedure call (RPC) is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction.

– wikipedia.org

Remote Method Invocation (RMI)

Java Remote Method Invocation (Java RMI) enables the programmer to create distributed Java technology-based to Java technology-based applications, in which the methods of remote Java objects can be invoked from other Java virtual machines*, possibly on different hosts. RMI uses object serialization to marshal and unmarshal parameters and does not truncate types, supporting true object-oriented polymorphism.

– oracle.com

Proxy Pattern

Proxy patterns are key for gaining an understanding of Spring remoting. Figure 19-1 shows the UML diagram for the proxy software design pattern.

Figure 19-1. UML diagram of proxy software design pattern

Figure 19-1. UML diagram of proxy software design pattern

In simple terms, a Proxy object is one through which we control access to the actual object on which the functionality lies. Based on the context in which these proxy objects are used, it can be categorized into three types:

  • Virtual Proxy – If you would like to control the creation of resource intensive objects in a lazy fashion (objects will be created only when the application actually uses it for the first time to do something), the heavy objects can be put inside the proxy objects and its creation can be controlled according to the requirement of your application.
  • Remote Proxy – Used to mask the complexity in communication mechanism between remote objects. Spring remoting uses this type of proxy for abstraction.
  • Access Proxy – Used to control the access to a sensitive object by wrapping it with a proxy.
  • Smart Proxy – If you would like to provide additional functionality to the existing object, smart proxies can be created to address this in your application.

The Proxy pattern is one of the most important design patterns because it provides an alternative to extending functionality in Java using inheritance. Another alternative is object composition, where an object (proxy, now you know) forwards method calls to an enclosed object (real subject).

Problems Faced Today

Most of the remoting mechanisms provide a layer of abstraction over the transport details used for communication in a distributed environment. This locks your code to a particular programming model. In present day of application development, locking to any model is not considered a right approach especially with frameworks like Spring being around which allows non-locking integration with other third party technologies and programming models.

In the case of using Java RMI (Remote Method Invocation), your service interface has to extend the java.rmi.Remote interface and your client is forced to catch the java.rmi.RemoteException exception class. This dependency of your code to Java RMI makes your code tightly couple with this programming model. It not only locks you in, but also clutters your business logic with the remoting infrastructure hurting the principle of separation of concerns.

Any enterprise application normally will be using many applications and services that function on different platforms. When the need arise for sharing the data or functions between these existing applications, the need for remoting could arise.

Integration will remain a high priority in coming years, according to Forrester analyst Ken Vollmer, as virtually all enterprise application delivery projects require significant integration among applications, internal data sources, external trading partners, and more and more frequently, external data resources.

To answer these challenges, the main goals on which Spring Remoting was built and the advantages it brings can be summarized as below:

  • Hide plumbing code as much as possible through abstraction—Spring Remoting hides a lot of plumbing code from the developer by the use of service providers in the server side and client proxy in the client side. Due to this the code becomes cleaner and more maintainable in the longer run. Clear separation of concerns and avoiding tangling and scattering of code.
  • Remoting capability by configuring and exposing services declaratively—Spring’s abstraction uses the configuration based approach for remoting. On the server side no code change is required at all and you have the power of exposing your existing services as remote services with ease. In the client side expose remote methods from existing code. You can then use Spring’s dependency injection to wire various objects into your remote objet with ease.
  • Support for multiple protocols and handling exceptions in  a consistent way—Spring offers a consistent way of writing service exporters, and client FactoryBeans for various protocols represents the same approach and is also consistent across. It provides consistency and ease of adoption as the overall flow remains the same irrespective of remoting technology. In addition, due to this consistency, on the server side ,you have the provision of exposing the services using various protocols declaratively. In the client side it brings in easy swapping of various available protocols according to infrastructure and other considerations. It is also easy to switch between remote and local deployment by mere configuration change which is very handy during testing and actual deployment phase.

In the following sections, we will see whether Spring Framework was able to deliver their goals and in what way they allow extension to it following the Spring philosophy.

Page Visitors: 4130

Spring Book – Chapter 15 – Web Application Security with Spring

Security is one of the very important services which any application needs to have in a comprehensive manner taking care of all the essential parts in a very elegant and simple manner. Spring Security framework is used in several domains including government, banking and military applications. Although written in Java, due to its high adoption and success, its architecture is ported to other platforms such as Microsoft .NET and Python to name few.

Spring Security provides declarative security especially for Spring based application. Having said that it has appropriate extension points and pluggability built into it using which it can be even plugged and used with other standard frameworks available in the software industry. Spring Security provides enterprise level authentication and authorization services at the web request level and at the method invocation level for JEE based enterprise software applications.

Security Concepts

Before diving deep into the Security and Spring Security in detail in this Chapter, there are certain terms in the Security world which should be understood in all aspects. This section aims to do just that and armor you with adequate concepts and terminologies which will be used throughout the Chapter.

Principal

Any user, system or a device which performs an action is called as a “Principal”. In simple terms in the case an application, anything which would like to interact with the application can be called as a “Principal”.

Authentication

The process by which the application checks or validates if the interacting “Principal” is who or what it claims to be is called authentication. There are various ways by which authentication process can take place like basic, form, digest, etc.

Credentials

The application does the process of authentication by challenging the principal. The challenge is usually a request by the application to get the principal to pass on valid credentials, usually a username/password combination already stored in a persistent store of any nature as the application please to be. There are various storage mechanisms by which to store the credentials and various authority details like a database, LDAP, etc.

Authorization

After a principal is successfully authenticated, it still needs necessary access rights to perform an action on the application like creating a new record, viewing a page etc. This process makes sure that the principal has necessary access to perform the action.

Secured Item

Any resource or item in an application which requires appropriate access rights to perform action on it is called “Secured Item” or “Secured Resource”.

GrantedAuthority

Spring Security related term and is used to refer to application-wide permissions/access rights granted to a principal.

SecurityContext

It’s the Spring Security object which is responsible for holding authentication and other security related details.

SecurityContextHolder

It’s the Spring Security object which is responsible for providing access to the SecurityContext object. It uses various strategies like ThreadLocal, inherited ThreadLocal and Global to provide the SecurityContext object within an application.

Spring Security Motivation

Spring Security was developed keeping in mind certain considerations. These considerations have become the core motivation on which Spring Security thrives and competes. These motivations can be summarized as shown below:

  • Portability – Spring Security is portable across different containers both commercial and open-source alike in all aspects. Web application using Spring Security can be deployed as is in different containers and can also run in standalone environments. Non-portability in servlet specification security is overcome by Spring Security by not having container specific adapters and role mappings.
  • Flexibility – Spring Security supports almost all the common authentication mechanisms and also keeps adding new supports as new technologies arises making it up-to-date almost all the time. It also provides configurable storage options for user credentials and authorities. Being built on top of Spring, we can do all of these by mere configuration, making it simple and easy.
  • Extensibility – This is high level of extensibility which Spring Security provides in the form of how the principal is defined, where the authentication information stored, how authorization decisions made, where security constraints stored etc. making is highly customizable in nature according to various application requirements.
  • Separation of Concerns – one of the very important motivations on which Spring Security is built on is the level of separation of concerns it provides allowing business logic to completely decouple from the security code. Also security concerns like authentication and authorization is also decoupled from each other making it possible to change authentication process without affecting authorization.
  • Consistency – regardless of mechanisms followed to achieve both authentication and authorization, Spring Security keeps the consistency in all aspects.

Spring Security History

Spring Security was originally called Acegi Security created by Ben Alex in the year 2003. Version 1.0 got release in March 2003. Acegi Security provided declarative security and was extremely powerful and flexible in numerous aspects. Although it had advantages in many aspects it had a big inherent problem in having all configurations in XML making it really cumbersome and sometimes troublesome in various aspects.

In Spring Framework 2.0 version Acegi Security was adopted into it and was renamed as Spring Security. With advances in Spring Framework, came advances in Spring Security. Additional modules kept added on and with Spring namespace configurations slowly became easy and more manageable and paved way to configuration by convention. It applies security rules by extensive use of Servlet filters and Spring AOP. Although Spring Security is Spring-based, it can be used with non-Spring based web applications with ease.

Page Visitors: 9515

Spring Book – Chapter 16 – Web Services – Spring WS

In June 2000, Microsoft coined the term “Web Services” when they introduced this as one of the key component of its .NET framework. As other industry players started adopting this, it was evident that this technology would revolutionize distributed computing in the coming years. In the past few years many techniques have been developed to help applications interact with each other, of which prominent one is Web Services by a large extend.

Spring Web Services (Spring WS) follows the strategy of contract-first web services. It focuses more on XML and lesser on Java implementation. The underlying details are completely under the control of developers starting from the contract to the marshalling/unmarshalling details to the endpoint which actually handles the request.

Spring WS being a product of the Spring Framework, offers first class support of using Spring configurations and integrating with Spring framework. It provides ability to plug-in various XML APIs (SAX, DOM, StAX, XOM, and JDOM) to handle XML messages and can always ensure that the XML contract is marshaled correctly into Java objects. It supports JAXB 1 and 2, Castor, XMLBeans, JiBX, and XStream as part of its XML marshalling support.

When you have finished with this Chapter, you will have clear idea of all the terminologies related to web services and will also have a clear idea of the support provided by Spring to create and use web services in your application.

What is a Web Service

A Web service is a method of communication between two electronic devices over the Web (Internet).

– wikipedia.org

A Web service is a unit of managed code that can be remotely invoked using HTTP protocol which allows exposing the functionality of your existing code over the network which other application can use it.

To give you a better explanation of what a web service is, I would like to give you the exact working of web service pictorially shown in Figure 16-1 below.

fig16-01

Figure 16-1. Web service architecture

The various steps involved in actually consuming an already exposed web service can be summarized as below:

  1. The client (web service consumer), queries the UDDI registry to get the details of the service and to locate it in the network (Internet).
  2. The UDDI registry refers the web service requesting client to the WSDL document details.
  3. The requesting client accesses the WSDL document.
  4. The WSDL document gives all the relevant details of the requested web service to the client.
  5. The client now sends SOAP-message request to the actual web server exposing the service.
  6. The web service returns the SOAP-message response which the client receives and does the appropriate processing.

Concepts

Spring hides many of the web service complexities away from the developer. But since some concepts are very crucial in overall understanding of web services, we’ll take a brief look at some these concepts in the following sections.

SOAP Messages

SOAP (Simple Object Access Protocol) is an XML vocabulary that lets programs on separate computers interact across a network via RPC (Remote Procedure Call). A SOAP message can be of three types summarized as below:

  • Method call – it contains name of method and parameters.
  • Method Response -contains the return values.
  • Fault Message – if service throws exception, it produces SOAP fault message. Due to any reason if transport fails, it will give appropriate standard HTTP messages

The SOAP message structure is illustrated in Figure 16-2.

 Figure 16-2. A typical SOAP message structure

Figure 16-2. A typical SOAP message structure

Page Visitors: 9945

Spring Book – Part IV – Enterprise Application Development

Enterprise application requires many services to realize various uses cases. These services are mandatory and form the backbone of the application in many ways. Changing business scenarios requires changing and updating these services at various changes according to demand. With Spring’s capability, this can be achieved very easily catering integration with evolving opens-source technologies and solutions.

This part of the book contains Chapters which will help you in developing enterprise application having all the required enterprise services helping you realize business use case with the help of Spring Framework.

Chapter 16, “Web Services – Spring WS”, introduces you to the Spring’s capability of supporting web services in your application. After reading through this Chapter, you will have clear idea of all the terminologies related to web services and will also have a clear idea of the support provided by Spring to create and use web services in your application.

Chapter 17, “Messaging with Spring”, will initially cover messaging concepts in some detail. Later on we will cover JMS and its components in detail. We will then deep-dive into the support provided by Spring in applying messaging to your application. We will then go through the transaction support by JMS and again what Spring has to offer in this space. Last but not the least, the Chapter concluded with introduction and Spring’s support in achieving global transactions in your application.

Chapter 18, “Remoting”, we will first go through the basic concepts in remoting and then go on to the support provided by Spring. We will then go on in detail to cover the various remoting technologies which Spring supports in detail.

Chapter 19, “Tasks and Scheduling”, initially looks into the various concepts dealing with concurrency and then looks into Java support for doing this. Later on it looks into how Spring Framework can support doing this in your application. You should also be able to configure and use Quartz in your Spring application as well have the capability of using JDK’s timer support in your application.

Chapter 20, “Spring Integration”, will help you start with Spring Integration and will aid you in achieving the various integration requirement in your application. I am sure after reading through this Chapter you will have one more weapon up your sleeves which you can use and reap benefits from its high level of integration capabilities.

Chapter 21, “Spring Batch”, similar to other chapters will introduce you to Spring Batch in a comprehensive manner. Batch operation is one among the integral parts of modern day application and Spring’s support comes in the form of Spring Batch and we will deep dive into this in all aspects possible.

Chapter 16: Web Services – Spring WS

Chapter 17: Messaging with Spring

Chapter 18: Remoting

Chapter 19: Tasks and Scheduling

Chapter 20: Spring Integration

Chapter 21: Spring Batch

Page Visitors: 437

Model View Controller 2 architecture

Spring Book – Chapter 12 – Spring and Struts Integration

My humble effort to explain Spring and Struts integration in detail using code samples for easy understanding for my fellow developers and readers.

Apache Struts is more established, more used and well known MVC2 web framework in the Java world. I am sure anyone experienced with web application will surely have had a chance to work with this one of the pioneers in web framework.

Over the past few years there have been so many buzz words in the world of software development like Inversion of Control (IoC), AOP etc. These paradigms has revolutionized the software development and Spring being one of the frameworks adopting these new technologies into it and have become really good at it.

This Chapter makes a big assumption that the reader is conversant with the Struts Framework and that the reader would like to integrate the Spring Framework into the struts application so as to use the capabilities and out-of-box features provided by the Spring Framework.

If you like to take advantage of these features of Spring you do not have to rebuild the application, but you can integrate your existing Struts application with Spring without much hassle. This Chapter will let you do exactly this so that you can take the advantages of both worlds with good level of confidence and comfort. This Chapter is a very simple one and I am sure you will be able to complete it at one go without trouble whatsoever.

Apache Struts

Apache Struts 2 is an elegant, extensible framework for creating enterprise-ready Java web applications. The framework is designed to streamline the full development cycle, from building, to deploying, to maintaining applications over time.

Apache Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts2. This new version of Struts is simpler to use and closer to how Struts was always meant to be.

Apache Struts in an MVC2 Java web framework. MVC2 is a servlet-centric architecture.  MVC2 incorporates a clear separation of view and controller. A controller receives all the requests, retrieves data from a Model and forwards it to next view for presentation.

In MVC2, there is a central Servlet (Controller) which calls business logic (Model) and the forwards it particular JSP page (View) that is why it is also called servlet-centric architecture. Pictorially MVC2 implementation is as shown in Figure 12-1 below.

 Model View Controller 2 architecture

Figure 12-1. MVC2 (Servlet-centric architecture)

WebWork was a Java-based web application framework developed by OpenSymphony which got merged into the current Struts2 web application framework. WebWork is built on top of XWork, which provides a generic command pattern framework as well as an Inversion of Control container.

Advantages of integrating Struts with Spring

The advantages of integrating a Struts application into the Spring Framework are:

  • Spring framework is based on new design approach and was designed to resolve the existing problems of existing Java applications. To a larger extent Spring has been successful in living to the expectations. Integrating Struts application with Spring buys in all the advantages provided out-of-box by Spring.
  • Spring framework lets you apply AOP (aspect-oriented programming technique) rather than object-oriented code. This is quite useful in addressing some very core concerns in any modern day enterprise application.
  • Spring provides more control on struts actions. That may depend on the method of integration you choose which we will cover in detail in the following sections of this Chapter.

Struts History

Before going through Spring and Struts integration in detail, because of the evolution complexity of Struts, we would have to first go through the Struts history with core focus on the versions. According to the Struts version that you use in your application, the integration methodology changes accordingly.

Struts were originally developed by the programmer and author Craig R. McClanahan and were later taken over by the Apache Software Foundation in 2002. Strut1 with all standard Java technologies and packages of Jakarta assists to create an extensible development environment. However, with the growing demand of web application, Struts 1 does not stand firm and needs to be changed with demand. This leads to the creation of Struts 2, which is more developer friendly with features like Ajax, rapid development and extensibility.

The team of Apache Struts and another J2EE framework, WebWork from OpenSymphony joined hand together to develop an advanced framework with all possible developing features that will make it developer and user friendly.

Even though the new version is Spring 2, we would still cover integration of Spring with Struts 1 as well so that if existing Struts 1 project needs the various capabilities of Spring, they can do so without much hassle.

Page Visitors: 5727

Spring Book – Chapter 11 – Spring Web

Large number of enterprise web applications is developed using Java and forms a very integral part of any organization in modern day. Web applications have become more and more complex and it poses more and more challenges day by day. Having a good web framework should be able to address most of these challenges there by reducing the effort on the developer and allowing them to focus on implementation of actual business logic.

This Chapter introduces you to the Spring Frameworks web support and the various components in the Spring web stack. This is just an introduction to the Spring’s frameworks role in the web application development support.

The Chapter starts off by explaining the Spring web stack and the various components which it comprises. Later on it delves deep into each component and explains each one in detail. Following with the Spring philosophy it then covers the various integration possible with your Spring application. Since some integration is really important, these are covered as separate chapters later on.

A Little History

Before going deep into the Spring web stack, a little history about the Spring web stack development from its early days to present.

Spring started its journey in 2002 and Spring Web was part of the original Spring ecosystem and contained servlet/web tier tool for aiding web application development. Then came Spring Frameworks own MVC framework in the form of Spring MVC. Following the core principles of Spring, it allowed to integrate with other frameworks.

Then came the inclusion of Spring Portlet MVC which was contributed initially by Rutgers in April 2004. John Lewis started contributing changes and it got included in the main Spring code base along with Spring 2.0 release.

Spring Web Flow started as a sub project and its first release was in March 2005. Due to its innovative ideas and good acceptability in the industry after inception, it soon became an independent project and got its independent release version 1.0 released in the same year.

Over the period Spring MVC and Spring Web Flow evolved and is considered among the renounced web technology stack.

Spring Web Stack

Modern day web application posses high level of challenges, including the following:

  • Complexity continues to rise at an alarming rate
  • Necessity of exposing services to a larger audience
  • Ability to give users the best possible experience in the shortest possible of time
  • High expectations
  • Ability to build simpler applications
  • Cloud enablement

Ideally any web framework chosen for web application development should address the above challenges reducing much of the complexity for the developer. Spring provides a full stack web framework by gathering multiple libraries and frameworks useful for web development into a single unified software stack for web developers to use. It tries to address the rising complexities raised by web application development by building on top of the lightweight Spring container. Figure 11-1 shows the various components provided by the Spring web stack for developing web application using this foundation.

Figure 11-1. Spring Web Stack components

The Spring Web Stack gives you:

  • A unified programming model
  • Capability to handle multiple client types using the same foundation
  • Adaptability to choose the right approach according to the required use case

The various Spring web stack components are:

  • Spring Framework and Spring MVC
  • Spring Web Flow
  • Spring Security
  • Spring JavaScript
  • Spring Faces
  • Spring BlazeDS Integration

Page Visitors: 2391