db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Anthony <charles.anth...@hpdsoftware.com>
Subject RE: Thread-safe problem with PersistenceBrokerThreadMapping
Date Wed, 19 Feb 2003 12:19:43 GMT
Hi,

[...]

>I see a probelm: What if the delegate is itself a
>DelegatingPersistenceBroker?

## 
I spotted that too....
##

>A potential way out is as follows:
>
>add amethod 
>
>PersistenceBroker getUltimateDelegate();
>
>to interface PersistenceBroker.  
>The class DelegatingPersistenceBroker implements this as
>
>return getDelegate().getUltimateDelegate();
>
>all other PersistenceBrokers just do 
>
>return this;
>
>Then the above code could avoid instanceof and cast and simply do
>
>PersistenceBrokerThreadMapping.setCurrentPersistenceBroker(pbKey, 
>broker.getUltimateDelegate());
>
##
The only objection I would have would be that adding getUltimateDelegate to
the PB interface would mean that 
a) the PB interface "knows" about delegates, which sort of defeats the point
of hidden delegates
b) further "pollution" on the PN interface.

I would suggest a half way house where the getUltimateDelegate was on the
DelegatingPersistenceBroker class, and that the
PersistenceBrokerFactoryDefaultImpl did 

 if(broker instanceof DelegatingPersistenceBroker)
 {
      PersistenceBrokerThreadMapping.setCurrentPersistenceBroker(pbKey,
      (DelegatingPersistenceBroker)broker).getUltimateDelegate());
 }
 else
 {
      PersistenceBrokerThreadMapping.setCurrentPersistenceBroker(pbKey,
 broker);
 }

Cheers,
Charles.
##


This email and any attachments are strictly confidential and are intended
solely for the addressee. If you are not the intended recipient you must
not disclose, forward, copy or take any action in reliance on this message
or its attachments. If you have received this email in error please notify
the sender as soon as possible and delete it from your computer systems.
Any views or opinions presented are solely those of the author and do not
necessarily reflect those of HPD Software Limited or its affiliates.

 At present the integrity of email across the internet cannot be guaranteed
and messages sent via this medium are potentially at risk.  All liability
is excluded to the extent permitted by law for any claims arising as a re-
sult of the use of this medium to transmit information by or to 
HPD Software Limited or its affiliates.



Mime
View raw message