List Info

Thread: Auditing capabilities on top of IBatis




Auditing capabilities on top of IBatis
user name
2006-09-28 18:18:46

Any new information about this topic?

I am doing exactly same thing. Instead of custom factory I am using Spring.net.

I need to intercept IBatis right after object is returned (make object under Spring control)

Brian Choi

 

RE: Auditing capabilities on top of IBatis

Rogelio Baucells
Mon, 14 Aug 2006 10:39:14 -0700

Hi Gilles,
 
 
 
Yes I looked at that part of the code in DomSqlMapBuilder but there is
 
no way to set the custom IObjectFactory without modifying the IBatis
 
provided code. If you look at the IObjectFactory instance creation it
 
does not use the property at all:
 
 
 
if (_objectFactory == null)
 
{
 
        _objectFactory = new ...
 
}
 
 
 
And later in the SqlMap creation:
 
 
 
_configScope.SqlMapper = new SqlMapper(_objectFactory, accessorFactory);
 
 
 
 
 
As I said before there is no way to plug your custom IObjectFactory
 
without modifying the IBatis code.
 
 
 
Thanks,
 
 
 ;
RJB
 
 
 
________________________________________
 
From: Gilles Bayon [mailto:[EMAIL PROTECTED] 
 ;
Sent: Monday, August 14, 2006 12:39 PM
 
To: user-csibatis.apache.org
 
Subject: Re: Auditing capabilities on top of IBatis
 
 
 
 
 
On 8/14/06, Rogelio Baucells <[EMAIL PROTECTED]> wrote:
 
 
&nbsp;
Hi,
 
 
 
We have the requirement of implementing auditing at the property level
 
for our object model. We need to audit all changes to public properties
 
and persist the auditing information at the time the entity is been 
 ;
saved. We are evaluating IBatis for such task as the persistence layer
 
and we have a prototype already working. We had to modify some parts of
&nbsp;
IBatis to acomplish this task:
 
&nbsp;
&nbsp;
1- We need to modify the way objects are created, for that we created 
 ;
our own IObjectFactory and returned our own IFactory for the entities we
&nbsp;
need to audit. This IFactory creates a dynamic proxy with some extra
 
functionality needed for the auditing.
 
 
 
We had to modify DomSqlMapBuilder since there is no way to set a custom 
 ;
IObjectFactory at the time of creating a SqlMapper. I think that it
&nbsp;
would be a good enhancement to IBatis having the posibility to specify
 
your own IObjectFactory and set/get accessors.
 
 
 
Look at 
 ;
/// <summary>
&nbsp;
&nbsp; &nbsp; &nbsp;   /// Allow to set a custom object factory, see <see
 
cref="IObjectFactory"/&gt; 
 ;
 &nbsp;   ; &nbsp; /// before configuration
&nbsp;
 ; &nbsp; &nbsp; &nbsp; /// </summary>
 
&nbsp; &nbsp;   ;  public IObjectFactory ObjectFactory
&nbsp;
&nbsp;
 ;
 &nbsp;   ; &nbsp; {
&nbsp;
   ; &nbsp; &nbsp; &nbsp; &nbsp; set { _objectFactory = value; }
&nbsp;
in DomSqlMapBuilder 
 ;
 &nbsp;   ; &nbsp; }
&nbsp;
 ;
 
2- Another thing we needed was the ability to intercept calls to some
&nbsp;
methods in the SqlMap class, the easiest way to accomplish this was
&nbsp;
inheriting from the SqlMapper class but the contructor is internal. Also
&nbsp;
there is no way to change the way the SqlMapper instance is created 
 ;
inside DomSqlMapBuilder and in several places in the code classes are
&nbsp;
using a reference to the SqlMapper class instead of the ISqlMapper
 
interface. We finish doing a hack inside our dynamic proxy
 
implementation of the domain model entities since the change in the 
 ;
IBatis code was a little more complicated than the one before.
 
 
 
I think the ability to extend/modify IBatis functionality is something
 
necessary in some cases and it should be built into the main code base.
 
A functionality similar to the Hibernate interceptors is a good idea or
&nbsp;
the possibility to change the default implementation of
&nbsp;
accessors/factories and the SqlMapper itself are needed in some cases. I
&nbsp;
can work on adding those changes to the main code base if the community 
 ;
think it is necessary.
 
 
 
Thanks,
 
 
 
RJB
 ;
 
 
 
 
CONFIDENTIALITY: This email (including any attachments) may contain
 
confidential, proprietary and privileged information, and unauthorized
&nbsp;
disclosure or use is prohibited. If you received this email in error,
 
please notify the sender and delete this email from your system. Thank
 
you. 
 ;
 
 
 
 
 
 
-- 
 ;
Cheers,
 
Gilles
 
 
 
&lt;a href=";http://www.amazon.com/gp/registry/6JCP7AORB0L";>Wish List</a> 
 ;

 

Auditing capabilities on top of IBatis
user name
2006-09-28 20:05:11
Yes, you can, here some code from Tom Nguyen presentation

DomSqlMapBuilder builder = new DomSqlMapBuilder();
builder.ObjectFactory = new ProxyObjectFactory();
_map = builder.Configure(new System.IO.FileInfo(fileName));


-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE"
>Wish List</a>
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )