RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Bridging Configuration from Spring to Legacy Frameworks : Page 2

Spring's POJO-based programming model has proven to be a much better way to write, test, and assemble robust Java EE applications, but it works only if you configure your objects with Spring. What happens when you combine Spring with an in-house legacy framework or Java EE technology such as EJBs or servlets?

The only other detail to cover is how your legacy service registers itself so that the Spring configuration can be applied to it. You accomplish this by using the oranjestad class SpringConfigurationBridge, which is called by the service after it has been initialized:

import oranjestad.spring.bootstrap.SpringConfigurationBridge;

public class MyLegacyService extends SomePreIOC_AbstractService {
    Pojo1 pojo1;
    Pojo2 pojo2;

    public void setPojo1(Pojo1 p1) {
   pojo1 = p1;

    public void setPojo2(Pojo2 p2) {
   pojo2 = p2;

    public MyLegacyService(String serviceName) {

    // some pre-dependency injection configure method 
    // called by the legacy framework.
    public void configure(ServiceConfig config) {

            configure(this, "some.service");

With the external bean approach, you have much greater flexibility with services that get created in an intertwined fashion. External beans do the following for your legacy system:

  • Handle all combinations of the legacy services starting before or after Spring
  • Extend dependency injection to your legacy system
  • Add some automatic annotation-based capabilities such as Spring's JMX annotations for creating MBeans to work with your legacy service

This approach can greatly increase the adoption of Spring into a legacy framework by eliminating ugly bean lookups from the legacy service as well as by moving configuration from the legacy system to Spring.

Bryant Harris is a Senior Architect/Development Manager who specializes in middleware and using software as a tool for executing business plans. Bryant also is the founder of the open source Classpath Helper project.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date