db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Armin Waibel" <ar...@code-au-lait.de>
Subject Re: Thread-safe problem with PersistenceBrokerThreadMapping
Date Wed, 19 Feb 2003 12:33:00 GMT
Hi Oliver and Brian,

there is a method
DelegatingPersistenceBroker#getInnermostDelegate()
that do what you want.

I'm currently working on that stuff.
I completely moved the ThreadMapping to
PBFDefaultImpl$PBKeyedPoolableObjectFactory:

public void activateObject(Object key, Object obj) throws Exception
{
       ((PBState) obj).setClosed(false);

PersistenceBrokerThreadMapping.setCurrentPersistenceBroker((PBKey) key,
(PersistenceBroker) obj);
 }

public void passivateObject(Object key, Object obj) throws Exception
{

PersistenceBrokerThreadMapping.unsetCurrentPersistenceBroker((PBKey)
key, (PersistenceBroker) obj);
        // this maybe already done before
        ((PBState) obj).setClosed(true);
}

Will this solve your problems?

regards,
Armin
----- Original Message -----
From: "Charles Anthony" <charles.anthony@hpdsoftware.com>
To: "'OJB Developers List'" <ojb-dev@db.apache.org>
Sent: Wednesday, February 19, 2003 1:19 PM
Subject: RE: Thread-safe problem with PersistenceBrokerThreadMapping


> 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.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
>


Mime
View raw message