Hi,
 
That seems like it will do what I need. I'll let you all know what I figure out.
 
Thanks 
 
Rob :) 

________________________________

From: Ron Gallagher [mailto:[EMAIL PROTECTED]
Sent: Mon 31-May-04 4:17 p.m.
To: OJB Users List
Subject: RE: Intercepting updates and inserts



Robert --

Check out these two interfaces:

org.apache.ojb.broker.PBLifeCycleListener
org.apache.ojb.broker.PBStateListener

The PBLifeCycleListener provides callbacks that reflect all object-level
operations (lookup, insert, update, delete).  This is probably what you'll
want to utilize.  The PBStateListener interface provides callbacks that
reflect "PersistenceBroker-level" operations (open, close, begin, commit,
rollback).

Both of the interfaces referenced above extend
org.apache.ojb.broker.PBListener.  So, if you've got an object that
implements one or both of these interfaces, you can use the
org.apache.ojb.broker.PersistenceBroker::addListener(PBListener) method to
register that object as a 'listener'.

On my last project, we made extensive use of these listener interfaces for
the same reasons you've described.  In our situation, we had our own
'factory' object that was used to serve up PersistenceBroker instances, so
it was easy enough for us to set up one or more listeners before we served
up any PersistenceBrokers.

Ron Gallagher
Atlanta, GA
ron dot gallagher at bellsouth dot net


-----Original Message-----
From: Coup, Robert Muir [mailto:[EMAIL PROTECTED]
Sent: Sunday, May 30, 2004 12:51 AM
To: OJB Users List
Subject: Intercepting updates and inserts


Hi all,

We're using OJB to interface our application to an online database
(Postgre) as well as an offline database (HSQLDB). I'm in the process of
writing some simple replication code to allow offline updates to be
reconciled when the data is synchronised with the online database.

What I would like to do is to intercept each update or delete being run
by OJB and log some information about it (statement type, table, user,
time, etc) it to another table. I could make all the persistent objects
implement PersistenceBrokerAware and then do the logging in afterUpdate
and afterDelete, but that isn't a stunningly elegant solution and I was
wondering if there was another place I could hook into which wouldn't
involve making changes to my persistent classes? If not, where would be
the best place to jump into the OJB source to do what I need?

Thanks again,

Rob :)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to