[ 
http://issues.apache.org/jira/browse/IBATIS-50?page=comments#action_12414953 ] 

Philippe Laflamme commented on IBATIS-50:
-----------------------------------------

That's great news!

Just a thought on your proposed solution... If your allowing the factory to 
create instances "if it wants to", then I would think that passing the 
statement id would be usefull to identify when to instantiate an object and 
when not to.

Personnally, I would never have a factory that behaves in this manner. It'd be 
looking for trouble to test the statement and react differently. In my mind, 
the factory should create every single instance of the objects needed by 
iBatis.  If the factory doesn't need to do any complex stuff to create an 
object instance then why not let it call class.newInstance on its own?

Anyway, it's just a thought and your proposed solution would solve my original 
problem, so I'm really happy with it!


> 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
>     Assignee: Jeff Butler

>
> 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:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to