ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Celentano (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Commented: (IBATIS-50) Ability to override the default bean creation mechanism
Date Thu, 26 Jan 2006 18:35:14 GMT
    [ http://issues.apache.org/jira/browse/IBATIS-50?page=comments#action_12364114 ] 

Joe Celentano commented on IBATIS-50:

I originally replied to the mailing list with my comments, and I see they aren't here, so
I'll add them. This issue has by far the most votes, and seems fairly straightforward to incorporate...

Joe Celentano
Fri, 01 Apr 2005 10:47:19 -0800

Incidentally, I'd like to offer you an example of how the lack of this capability is impacting
my use of another Apache project...

I just mocked up a set of DAOs and SQLMaps using resultset objects created by XMLBeans, not
realizing the problem with Factory creation vs. the newInstance method. XMLBeans are perfect
for holding the results of my queries because the receiving application code can choose from
a variety of xml or Java methods for data access. However, XMLBeans require object creation
via a Factory and cannot be created via iBatis. For example, a PurchaseOrderDocument is created
via PurchaseOrderDocument.Factory.newInstance(). Quite frustrating...

Just my 2 cents.

Joe Celentano

> 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