ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Mathrusse (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Commented: (IBATIS-50) Ability to override the default bean creation mechanism
Date Mon, 27 Mar 2006 19:23:52 GMT
    [ http://issues.apache.org/jira/browse/IBATIS-50?page=comments#action_12372015 ] 

Chris Mathrusse commented on IBATIS-50:

I don't want to bog down this discussion pertaining to whether or not this is a good idea.
The reality is that it would be a nice to have and would solve a great many problems. I would
like to be able to control how my POJO's are instantiated as I would like to have Spring manage
my beans for me. This would give me the ability to, for example, have interceptors for each
of my POJO's.  Currently I am unable to do anything other than allow my Doa layer to handle
some of the complexities that I want to implement. While this solution works for most of my
problems it fails to address some of my more complex issues.

> Ability to override the default bean creation mechanism
> -------------------------------------------------------
>          Key: IBATIS-50
>          URL: http://issues.apache.org/jira/browse/IBATIS-50
>      Project: iBatis for Java
>         Type: Wish
>   Components: SQL Maps
>     Versions: 2.0.9
>     Reporter: Philippe Laflamme

> Currently, iBatis is responsible for creating instances of classes used in result maps.
It relies on the assumption that objects can be obtained using the Class.newInstance() method
(or something equivalent).
> The assumption forces users of the framework to create classes with a no-arg default
constructor. IMHO, this also has the effect of favoring implementation inheritance (extends)
over interface inheritance.
> Although this is not a problem in most cases, the ability to plug in an external instance
factory would provide more flexibility and favor good programming practices. Amongst other
things, it would provide developers the ability write code in terms of interface.
> A simple solution is to provide an extension point where resultMap class instances are
obtained from.
> The simplest form would be:
> public interface InstanceFactory {
>   Object createInstance(Class resultMapClass);
> }
> The default implementation would do something along the lines of:
> [...]
> return resultMapClass.newInstance();
> [...]
> Developers could configure iBatis to either use the default implementation or their own
custom implementation. The setting could be part of the sqlMapConfig file or even per resultMap.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message