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 Java applications. Though Spring provides two seperate 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.
J2EE based web applications use Spring’s ContextLoader to access the Spring ApplicationContext registry. To achieve this, we add a listener, ContextLoaderListener, to a web.xml file:
org.springframework.web. context.ContextLoaderListener
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 file holds bean definitions for database connection settings, transaction management settings, DAOs, and Auto-number/Sequences needed for the database. Business layer service classes are available in other file. Both files use another object in the same file to define bean dependencies
Dependency Injection in Web Applications
Our web applications use tapestry as the front end 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:
@InjectObject (“spring:customerService”)
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 to obtain a bean:
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
It uses Spring’s HibernateTransactionManager class to manage transactions.
Transaction manager needs a session factory to connect with DB defined along with the Transaction Manager. Also, Spring’s hibernate templates access database defined in applicationcontext.xml.
org.hibernate.dialect. OracleDialect
classpath:/my/package/ business/model
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!