[EMAIL PROTECTED] wrote:
I know OJB has some "event handling" support, and I know there are 42 thousand places to plug different things into OJB. I'd like to see if OJB supports what I need, and the best place to plug in to it.
I have a very complex object heirarchy. I would like to be able to take an action whenever one particular object is loaded - but only after the objects to be loaded (references, collections) have been loaded. What's the best place.
There are two options:
1. you can let your persistent class implement the interface o.a.ojb.broker.PersistenceBrokerAware. You can put your special logic into the callback method
/**
* this method is called as the last operation within a call to
* PersistenceBroker.getObjectByXXX() or
* PersistenceBroker.getCollectionByXXX().
*/
public void afterLookup(PersistenceBroker broker)
throws PersistenceBrokerException;There is a sample for this in tutorial3 section "instance callbacks".
2. You can write a Listener class that implements o.a.ojb.broker.PBLifeCycleListener.
your special logic can be implemented in the callback method
/**
* Called after object instance has been looked up by a
* PersistenceBroker
* @param event
* @throws PersistenceBrokerException
*/
public void afterLookup(PBLifeCycleEvent event)
throws PersistenceBrokerException;The Listener must be registered to the broker in use by broker.addListener.
So which is the best solution? Depends.
1. is very simple, but you'll have OJB specific code in your entity classes.
2. is more tricky to handle, as brokers are normally obtained from a pool and you have to make sure that your specific instance is equipped with a listener. OTOH Entities stay free of OJB code...
cheers, thomas
This message contains information from Equifax Inc. which may be confidential and privileged. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify by 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]
