Spring
There were technical challenges faced by Java developers and organization while developing applications in Java platforms. Spring Framework provides solutions to many of their technical challenges. Reason of popularity of the Spring Framework is not particularly its linking to the Java Enterprise platform, despite the fact, its widely influential integration in this area.
The Spring Framework is well known for providing features which are required to create intricate business applications effectively outside of the programming models. It is also accredited for initiating earlier unfamiliar functionalities into today’s mainstream development practices.
Spring: A Collection of Frameworks
The Spring Framework is a collection of several smaller frameworks. Most of them can work independently as well as can provide improved functionalities when exploit collectively. These frameworks are divided along the building blocks of typical intricate applications:
- Inversion of Control Container: It is an arrangement of application components and lifecycle management of Java objects.
- Aspect-oriented programming Framework: It works with those functionalities which can not be put into practice with Java’s object-oriented programming competencies without making forfeits.
- Data Access Framework: By using JDBC and Object-relational mapping tools, it works with relational database management system on the Java platform, as well as provides solutions to technical challenges which are reusable in massive amount of Java-based environments.
- Transaction Management Framework: It is synchronization of a variety of transaction management API’s and configurative transaction management. It is arranged to achieve the desired result for Java objects.
- Model-view-controller Framework: In it HTTP and Servlet based framework offer many hooks for extension and customization.
- Remote Access Framework: Over computer networks it provides configurative RPC-style export and import of Java objects and also supports RMI, CORBA and HTTP-based protocols including web services (SOAP).
- Authentication and Authorization Framework: It supports many popular and industry standards, protocols, tools and practices by configurative orchestration of authentication and authorization processes.
- Remote Management Framework: Introduction and management of Java objects for local or remote configuration via JMX.
- Messaging Framework: Recording of message listener objects for transparent message usage from message queues via JMS, development of message sending over standard JMS API’s.
- Testing Framework: It provides support classes for writing unit and integration testing.
Brief Description of Spring Framework
Contrasting other frameworks and APIs, Spring doesn’t impose itself completely on to the design of a project. Spring has been divided logically into autonomous packages, which can function separately. It has the elasticity to implement just a few spring packages and leave out most of the packages in spring. The “Spring Framework” would not act badly with this approach and on the other hand supports users to introduce Spring into existing applications. So there is no need to worry that what kind of framework you are using because Spring will work with it properly without causing any problem and in addition Spring will permit you to choose specific packages.
The “Struts” framework is a good framework to improve the ability of the web tier, but the biggest disadvantage is the fact that it provides what is needed only to the web tier and leaves most of the Enterprise tier or middle tier of the application. The Application provides supplementary framework to deal with the enterprise tier and make sure that the new framework incorporates well with the Struts framework. Spring tries to address this problem by providing a comprehensive framework, which comprises of MVC framework, an AOP integration framework, a JDBC integration framework, and an EJB integration framework. It also offers integration modules for O/R mapping tools like Hibernate and JDO.
Spring provides all these without imposing any extra layer on the user side. Spring tries to merge into the existing framework without delay. Spring also provides transaction management support using Java classes, email support packages using framework classes, web services support by using. As we talk about earlier all these packages are not obligatory and spring does not make any of them obligatory. A user can keep on using Struts for the web tier for the database and meanwhile hook spring to provide e-mail services and web services support. Spring is based on the Inversion of Control/Dependency Injection pattern that has been making encircling in message boards all over the Internet.
Using Spring Functionality
The fundamental package in the spring framework is the org.springframework.beans package. Spring framework makes use of JavaBeans and this package provides most of the fundamental functionality to control Java beans and offers the basic infrastructure for the other spring framework classes. This package also provides the basis for the “Dependency injection” pattern, on which spring framework is based.
There are two ways in which clients can use the functionality of the Spring Framework. First is BeanFactory and other is ApplicationContext. The BeanFactory is a basic factory, which stores the information about all the Spring Beans and permits the user to instantiate beans and handle them. The BeanFactory provides programmers with the facilities to realize the basic features of the Spring Framework. The ApplicationContext builds on top of the BeanFactory and come into all the basic features of the Spring Framework.
Life Cycle of a Bean
After initialization of bean, the BeanFactory can use callback methods to change the performance of the bean in the BeanFactory. One of the callback methods is the init-method. The Initializing Bean interface of the factory package provides the ability to do initialization work after properties are arranged for a bean in the BeanFactory. The afterPropertiesSet () method in the Initializing Bean interface permits the user to check if all the properties are set properly or if some operation has to be done after the properties have been set. All Bean classes that need to use this callback method need to execute the Initializing Bean interface and implement the afterPropertiesSet () method. If the initialization work is negligible the user has the elasticity to assign a method within the bean, which will be invoked later than bean properties have been set. The designated method, which would do the initialization, can be then specified in the init-method attribute of the bean. Designating the init-method attribute can help to avoid implementing the Initializing Bean interface.
Features of Spring Framework
Spring comprises of
- Absolutely lightweight container, offering integrated, computerized configuration and wiring of your application objects. The container brings nimbleness and leverage, and application testability and scalability is improved by allowing software components to be first developed and tested in separation, then scaled up for deployment in any environment (J2SE or J2EE).
- A common abstraction layer for transaction management, allowing for pluggable transaction managers, and making it easy to distinguish transactions without dealing with low-level issues. Spring’s transaction support is not tied to J2EE environments.
- A JDBC abstraction layer that offers a significant exception hierarchy (no more pulling vendor codes out of SQLException), make simpler error handling, and greatly reduces the quantity of code you’ll need to write.
- AOP functionality fully incorporated into spring configuration management. You can AOP-enable any object handled by spring, adding features such as declarative transaction management. Spring, without EJB, can have declarative transaction management.
- A flexible MVC web application framework built on core Spring functionality. This framework is extremely configurable via strategy interfaces, and contains multiple view technologies like JSP, Velocity, Tiles, iText, and POI. Note that a Spring middle tier can simply merged with a web tier based on any other web MVC framework, like Struts, WebWork, or Tapestry.
Other String Features:
- Spring can automatically determine the dependent beans with the help of the BeanFactory. This facility can lessen the need to identify properties or constructor arguments.
- Spring can ensure dependencies on a bean. It can check for values that should be set when a bean is initialized. If the check is not completed the BeanFactory will set the default value. This behavior is not compulsory and can be turned on when required.
- Spring can also deal with multiple resource files.
Something good about Spring Framework
Spring framework has become very popular and most people are interested to know that what is new to spring? The answer is simple!
- Spring offers enhanced leverage
- Spring facilitates POJO Programming
- Dependency Injection helps testability
- Inversion of Control Simplifies JDBC
- Spring’s community grow vigorously
Something bad about Spring Framework
Spring container is intelligent enough to autowire relationships between collaborating beans. It means the container will automatically resolve the bean relationships by examining the BeanFactory contents. Some disadvantages it includes are:
- The dependencies and relationships flanked by beans are not clearly stated.
- Auto wiring by type would only work if there is only one example of a specific type instantiated inside the container.
Conclusion
Spring is very recent in the market and provides a new lease of life to framework development. Spring does not try to copy existing solutions; it tries to incorporate with exiting solutions like JDO, AOP and Hibernate. However spring creates a new web framework to replace Struts, as the creators of Spring feel that Struts is not robust enough. Spring would generate great interest in the coming months as more people will become aware of it and find it worthwhile to implement. Spring is portable across application servers, as it does not include any application server or platform specific requirements. This makes it compatible on major application servers like Websphere, Weblogic, Tomcat, Jboss etc. As of now spring can be integrated and used in an eclipse IDE, however as the versions improve spring should be providing support for more IDEs.


(3 votes)
Leave a comment