Spring Java Web Development Outsourcing
Technosoft has successfully used Spring framework in different projects for better code management, flexible design and reducing the code on the 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 contain more details about it.
Wiring Dependencies with an Application Context
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 the lightweight yet most advanced container.
In web J2EE based Web applications, the 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 the database. Another 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 the 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 a session factory to connect with DB that is also defined along with the Transaction Manager. Also, Spring’s hibernate template are used to access database that is also defined in applicationcontext.xml.
Technosoft can provide technical consultancy, further R&D services, as well as help in developing Spring-based solutions at a very affordable price. We will be happy to work with you and save your IT team’s time on the learning curve and development effort.
Our dedicated teams of Microsoft and Sun Certified professionals are ready to help!