Thanks and you are absolutely right. However, I am mainly trying to rid my 
projects of singletons unless it is absolutely necessary. As you stated, 
getting rid of the singleton would be the only true benefit I'd get. Maybe it's 
not worth it...

----------------------------------------
> From: nicho...@piasecki.name
> To: user-cs@ibatis.apache.org
> Subject: RE: Bootstrapping Ibatis
> Date: Mon, 11 May 2009 12:50:44 -0400
>
> I would put it with your application's initialization code that sets up your
> IoC container, such as Application_Start in the ASP.NET world or Main() in
> WinForms.
>
> Alternatively, you could create a new type called MapperWrapper that
> implements ISqlMapper but calls Configure() when it is first instanced and
> passes all of the method calls into the mapper instance that it is wrapping;
> then you inject that wrapper implementation into your DAOs. This way, the
> assembly containing your Main() or Application_Start wouldn't need to
> reference an iBATIS assembly.
>
> public class MapperWrapper : ISqlMapper
> {
> private ISqlMapper mapper;
>
> public MapperWrapper()
> {
> this.mapper = ConfigureTheMapper();
> }
>
> public int Insert(string map, object param)
> {
> return this.mapper.Insert(map, param);
> }
>
> // ... etc ...
> }
>
> For what it's worth, since the mapper is a dependency of the repository, I'm
> not sure what "bang for the buck" you would get for doing this, as I've
> never seen much value in unit testing (vs integration testing against actual
> test database) an actual DAO implementation.
>
> Good luck!
>
> V/R,
> Nicholas Piasecki
>
> -----Original Message-----
> From: Sal Bass [mailto:salbass...@hotmail.com]
> Sent: Monday, May 11, 2009 12:17 PM
> To: user-cs@ibatis.apache.org
> Subject: Bootstrapping Ibatis
>
>
> How do you guys inject the mapper via IoC into your DAOs / Repositories? I
> want to move away from the singleton approach, and I know using IoC tool I
> can define the mapper's scope as a singleton that way, but where would I put
> the put DomSqlMapBuilder.Configure(sqlMapConfig) code that needs to be
> called the first time an instance is created?
>
> _________________________________________________________________
> Windows LiveT: Keep your life in sync.
> http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009
>
>
_________________________________________________________________
HotmailĀ® has a new way to see what's up with your friends.
http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009

Reply via email to