Spring Java Web Development Outsourcing
Technosoft have successfully used Spring framework in different projects for better code management, flexible design and reducing the code on developer side. We have found Inversion of Control as the most important feature offered by Spring.
We have used the following major services offered by Spring framework:
- Inversion of Control / Dependencies Injection
- Transaction Management
- Providing glue login between Hibernate and Tapestry
Following sections contains more details about it.
Wiring Dependencies with an ApplicationContext
We have used Spring framework in both web applications and standalone java applications. Though Spring provides two distinct containers: Bean Factories; simplest containers, and Application contexts; provides application framework services. However for both web and standalone applications we have used ApplicationContexts container that is light weight yet most advanced container.
In web J2EE based Web applications Spring ApplicationContext registry is accessed by using Spring’s ContextLoader. This is achieved by adding a listener, ContextLoaderListener, to a web.xml file:
Injecting Spring Beans from ApplicationContext
In large scale projects where there are numbers of large classes/services we break beans for Spring registry in two files. One is used to hold bean definitions for database connection settings, transaction management settings, DAOs, and Auto-number/Sequences needed for database. Other file contains business layer service classes that are used throughout the application. Bean dependencies are defined in both files using another object in the same file.
Dependency Injection in Web Applications
Tapestry is used as front end of our applications that has rich support for Spring. Spring services are heavily used in each page of UI. Mostly it is done by using annotation provided by Tapestry using code line shown below:
public abstract CustomerService getCustomerService();
Dependency Injection in Standalone Java Applications
In standalone java application beans are again obtained from ApplicationContext using FileSystemXmlApplicationContext that loads context definition from an XML file in the file system. The application context is loaded from the file system by using the code.
FileSystemXmlApplication Context ac = new FileSystem XmlApplicationContext (“applicationContext*.xml”);
And a bean can be obtained as:
CustomerService custService = (CustomerService)ac.getBean (“custService”);
Once we have bean we can simple call methods on it like:
List customerNumList = custService.getAllActive CustomerNum();
Spring Transaction Management
Spring’s HibernateTransactionManager class is used to manage transactions.
Transaction manager needed session factory to connect with DB that is also defined along with Transaction Manager. Also Srping’s hibernate template are used to access database that are also defined in applicationcontext.xml.
Technosoft can provide technical consultancy, further R&D services, as well as help in developing Spring based solutions at very affordable price. We will be happy to work with you and save your IT team’s time on learning curve and development effort.
Our dedicated teams of Microsoft and Sun Certified professionals are ready to help!