ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Evans <dsev...@berndtgroup.net>
Subject Re: Using Struts with Spring DAO's in IBATIS
Date Tue, 01 Jul 2008 18:26:15 GMT

I am using Spring DAO and ibatis with struts, without tying the two

I have basically modified the configuration explained here:

I have a ServeletContextListener that creates a singleton configuration
object, using Spring to populate its set of variables that hold
references to daos:

public void contextInitialized(ServletContextEvent event) {
  ServletContext servletContext = event.getServletContext();
  this.springContext =
  CoreApplicationConfig config = CoreApplicationConfig.getInstance();


In my action I do this:

ApplicationConfig config = CoreApplicationConfig.getInstance();
UserDAOService userDaoService = config.getUserDaoService();

If I ever want to replace Spring, my struts actions will never know.


You wrote:
Hi there,
We have an application where we are using Struts as our web framework
and IBATIS in the data layer. We upgraded to the new version of ibatis
which required to upgrade the DAO's to Spring DAO's.

To use the Spring DAO's we started to use spring with struts. The only
purpose of Spring was to inject the dao's into the service classes and
into my Struts Action. However , this approach ties my Struts framework
with Spring. Because, the beans.xml file tries to see Struts Action
classes as Beans to do its injection.




This approach however, ties Ibatis to Spring and forces us to use Spring
in our web layer as well. 

Can I use Spring DAO's without doing dependency injection?
Has anyone used Ibatis Spring DAO's in Struts without making Struts
aware of the existence of Spring. Any pointers are appreciated.

View raw message